import { useCallback, useState } from "react"; import { Button, Dialog, DialogActions, DialogBody, DialogContent, DialogSurface, DialogTitle, Field, Input, MessageBar, MessageBarBody, Switch, } from "@fluentui/react-components"; interface SourceFormValues { name: string; url: string; enabled: boolean; } interface SourceFormDialogProps { open: boolean; mode: "add" | "edit"; initial: SourceFormValues; saving: boolean; error: string | null; onClose: () => void; onSubmit: (values: SourceFormValues) => void; } export function SourceFormDialog({ open, mode, initial, saving, error, onClose, onSubmit, }: SourceFormDialogProps): React.JSX.Element { const [values, setValues] = useState(initial); const handleOpen = useCallback((): void => { setValues(initial); }, [initial]); return ( { if (!data.open) onClose(); }} > {mode === "add" ? "Add Blocklist Source" : "Edit Blocklist Source"}
{error && ( {error} )} { setValues((p) => ({ ...p, name: d.value })); }} placeholder="e.g. Blocklist.de — All" /> { setValues((p) => ({ ...p, url: d.value })); }} placeholder="https://lists.blocklist.de/lists/all.txt" /> { setValues((p) => ({ ...p, enabled: d.checked })); }} />
); }