import { useTranslation } from "react-i18next"; import { Trash2, Plus } from "lucide-react"; import { Input } from "@/components/input"; import { Button } from "@/components/button"; import type { PingStatusConfig, PingUrl, WidgetEditFormProps, } from "@/types/homepage-types"; export function PingStatusEditForm({ config, onChange, }: WidgetEditFormProps) { const { t } = useTranslation(); const { urls, refreshInterval, showLatency } = config; const updateUrl = (i: number, patch: Partial) => { onChange({ ...config, urls: urls.map((u, idx) => (idx === i ? { ...u, ...patch } : u)), }); }; const removeUrl = (i: number) => onChange({ ...config, urls: urls.filter((_, idx) => idx !== i) }); const addUrl = () => onChange({ ...config, urls: [...urls, { label: "", url: "" }] }); return (
{urls.map((u, i) => (
updateUrl(i, { label: e.target.value })} placeholder={t("homepage.pingLabel")} className="h-7 text-xs flex-1" /> updateUrl(i, { url: e.target.value })} placeholder="https://..." className="h-7 text-xs flex-1" />
))}
onChange({ ...config, refreshInterval: Math.max(10, Number(e.target.value)), }) } className="h-8 text-xs" />
); }