import { useTranslation } from "react-i18next"; import { Trash2, Plus } from "lucide-react"; import { Input } from "@/components/input"; import { Button } from "@/components/button"; import type { ServiceGridConfig, ServiceGridItem, WidgetEditFormProps, } from "@/types/homepage-types"; export function ServiceGridEditForm({ config, onChange, }: WidgetEditFormProps) { const { t } = useTranslation(); const { services, columns, showLabels, iconSize } = config; const updateItem = (i: number, patch: Partial) => { onChange({ ...config, services: services.map((s, idx) => (idx === i ? { ...s, ...patch } : s)), }); }; const removeItem = (i: number) => onChange({ ...config, services: services.filter((_, idx) => idx !== i) }); const addItem = () => onChange({ ...config, services: [...services, { label: "", url: "" }] }); return (
{services.map((s, i) => (
updateItem(i, { label: e.target.value })} placeholder={t("homepage.linkLabel")} className="h-7 text-xs flex-1" /> updateItem(i, { url: e.target.value })} placeholder="https://..." className="h-7 text-xs flex-1" />
))}
{([2, 3, 4] as const).map((c) => ( ))}
{(["sm", "md", "lg"] as const).map((s) => ( ))}
); }