import { useState } from "react";
import { MarkdownEditor } from "~/components/MarkdownEditor";
import { Button } from "~/ui/Button";
import { SelectField, TextField } from "~/ui/Field";
import { ErrorBanner } from "~/ui/Callout";
export type AdvisoryValues = {
title: string;
description: string;
severity: "low" | "moderate" | "high" | "critical";
cveId: string | null;
cweIds: string | null;
ecosystem: "npm" | "pip" | "go" | "cargo" | "rubygems" | "composer" | "other" | null;
packageName: string | null;
affectedVersions: string | null;
patchedVersions: string | null;
};
const SEVERITIES = [
{ value: "low", label: "Low" },
{ value: "moderate", label: "Moderate" },
{ value: "high", label: "High" },
{ value: "critical", label: "Critical" },
] as const;
const ECOSYSTEMS = [
{ value: "", label: "Not specified" },
{ value: "npm", label: "npm" },
{ value: "pip", label: "pip" },
{ value: "go", label: "Go" },
{ value: "cargo", label: "Cargo" },
{ value: "rubygems", label: "RubyGems" },
{ value: "composer", label: "Composer" },
{ value: "other", label: "Other" },
] as const;
function severityOf(value: FormDataEntryValue | null): AdvisoryValues["severity"] {
return SEVERITIES.find((option) => option.value === value)?.value ?? "moderate";
}