import { Banner, Button, Input, InputArea, LayerCard, LinkButton, Select } from "@refs/design-system"; import { TagIcon } from "@refs/design-system/icons"; import { LabelBadge, LabelPicker } from "@refs/design-system"; import { MAX_BODY_LENGTH, MAX_TITLE_LENGTH, NONE, type Choice, type Label } from "@refs/backend/contract"; import { useState } from "react"; import { Form, useNavigation } from "react-router"; import { useLabelCreation } from "./label-creation"; export interface TaskFormValues { title: string; body: string; repo: string; assignee: string; } function optionItems(options: readonly Choice[], empty?: string): Record { return Object.fromEntries([...(empty ? [[NONE, empty]] : []), ...options.map((option) => [option.id, option.name])]); } export function TaskForm({ values, repos, people, labels, initialLabels = [], error, cancelHref, }: { values: TaskFormValues; repos: readonly Choice[]; people: readonly Choice[]; labels: readonly Label[]; initialLabels?: string[]; error?: string; cancelHref: string; }) { const submitting = useNavigation().state === "submitting"; const creation = useLabelCreation(); const [selected, setSelected] = useState(initialLabels); const chosen = labels.filter((label) => selected.includes(label.id)); return (
{error && }
Labels
{chosen.map((label) => ( ))} setSelected((previous) => (checked ? [...new Set([...previous, id])] : previous.filter((value) => value !== id)))} trigger={ } />
{selected.map((id) => ( ))}
Cancel
); }