import LightButton from "@/components/buttons/LightButton"; import Input from "@/components/Input"; import { X } from "lucide-react"; import { useRef } from "react"; import { PairUpdateInput } from "../../../../generated/prisma/models"; import { TextPair } from "./InFolder"; import { useTranslations } from "next-intl"; interface UpdateTextPairModalProps { isOpen: boolean; onClose: () => void; textPair: TextPair; onUpdate: (id: number, tp: PairUpdateInput) => void; } export default function UpdateTextPairModal({ isOpen, onClose, onUpdate, textPair, }: UpdateTextPairModalProps) { const t = useTranslations("folder_id"); const input1Ref = useRef(null); const input2Ref = useRef(null); const input3Ref = useRef(null); const input4Ref = useRef(null); if (!isOpen) return null; const handleUpdate = () => { if ( !input1Ref.current?.value || !input2Ref.current?.value || !input3Ref.current?.value || !input4Ref.current?.value ) return; const text1 = input1Ref.current.value; const text2 = input2Ref.current.value; const locale1 = input3Ref.current.value; const locale2 = input4Ref.current.value; if ( typeof text1 === "string" && typeof text2 === "string" && typeof locale1 === "string" && typeof locale2 === "string" && text1.trim() !== "" && text2.trim() !== "" && locale1.trim() !== "" && locale2.trim() !== "" ) { onUpdate(textPair.id, { text1, text2, locale1, locale2 }); input1Ref.current.value = ""; input2Ref.current.value = ""; } }; return (
{ if (e.key === "Enter") { e.preventDefault(); handleUpdate(); } }} >

{t("updateTextPair")}

{t("text1")}
{t("text2")}
{t("locale1")}
{t("locale2")}
{t("update")}
); }