"use client"; import { useState, useEffect } from "react"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@kandev/ui/dialog"; import { Input } from "@kandev/ui/input"; import { Label } from "@kandev/ui/label"; import { Button } from "@kandev/ui/button"; import { createExecutorProfile } from "@/lib/api/domains/settings-api"; import type { ExecutorProfile } from "@/lib/types/http"; import { useTranslation } from "react-i18next"; type ExecutorProfileDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; executorId: string; onSaved?: (profile: ExecutorProfile) => void; }; export function ExecutorProfileDialog({ open, onOpenChange, executorId, onSaved, }: ExecutorProfileDialogProps) { const { t } = useTranslation(); const [name, setName] = useState(""); const [saving, setSaving] = useState(false); const [error, setError] = useState(null); useEffect(() => { if (open) { setName(""); setError(null); } }, [open]); const handleSave = async () => { if (!name.trim()) return; setSaving(true); setError(null); try { const created = await createExecutorProfile(executorId, { name: name.trim(), }); onOpenChange(false); onSaved?.(created); } catch (err) { setError(err instanceof Error ? err.message : t("executors:failedToCreateProfile")); } finally { setSaving(false); } }; return ( {t("executors:newProfile")} {t("executors:createANewProfileForThis")}
setName(e.target.value)} placeholder={t("executors:eGProductionDevelopment", { example: t("executors:profileNameExample"), })} autoFocus />
{error &&

{error}

}
); }