import { useTranslation } from "react-i18next" import { Button } from "@/components/ui/button" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog" import { Input } from "@/components/ui/input" import { providerConfigNameActionMode, type ProviderConfigNameDialogState, } from "./hooks/use-provider-config-name-dialog" interface ProviderConfigNameDialogProps { state: ProviderConfigNameDialogState | null isSubmitting: boolean onOpenChange: (open: boolean) => void onNameChange: (name: string) => void onSubmit: () => Promise } export function ProviderConfigNameDialog({ state, isSubmitting, onOpenChange, onNameChange, onSubmit, }: ProviderConfigNameDialogProps) { const { t } = useTranslation() let dialogTitle = "" if (state?.mode === providerConfigNameActionMode.Create) { dialogTitle = t("PROVIDER_CREATE_CONFIG") } else if (state?.mode === providerConfigNameActionMode.Rename) { dialogTitle = t("CONFIG_RENAME") } else if (state?.mode === providerConfigNameActionMode.Copy) { dialogTitle = t("COPY_PICBED_CONFIG") } const handleSubmit = () => { onSubmit().catch(() => { // The submit handler already reports failures via toast. }) } return ( {dialogTitle} {t("UPLOADER_CONFIG_NAME")} onNameChange(event.target.value)} onKeyDown={(event) => { if (event.key === "Enter") { event.preventDefault() handleSubmit() } }} /> ) }