import { LightButton } from "@/design-system/base/button"; import { Input } from "@/design-system/base/input"; import { LocaleSelector } from "@/components/ui/LocaleSelector"; import { X } from "lucide-react"; import { useRef, useState } from "react"; import { useTranslations } from "next-intl"; interface AddTextPairModalProps { isOpen: boolean; onClose: () => void; onAdd: ( text1: string, text2: string, language1: string, language2: string, ) => void; } export function AddTextPairModal({ isOpen, onClose, onAdd, }: AddTextPairModalProps) { const t = useTranslations("folder_id"); const input1Ref = useRef(null); const input2Ref = useRef(null); const [language1, setLanguage1] = useState("english"); const [language2, setLanguage2] = useState("chinese"); if (!isOpen) return null; const handleAdd = () => { if ( !input1Ref.current?.value || !input2Ref.current?.value || !language1 || !language2 ) return; const text1 = input1Ref.current.value; const text2 = input2Ref.current.value; if ( typeof text1 === "string" && typeof text2 === "string" && typeof language1 === "string" && typeof language2 === "string" && text1.trim() !== "" && text2.trim() !== "" && language1.trim() !== "" && language2.trim() !== "" ) { onAdd(text1, text2, language1, language2); input1Ref.current.value = ""; input2Ref.current.value = ""; } }; return (
{ if (e.key === "Enter") { e.preventDefault(); handleAdd(); } }} >

{t("addNewTextPair")}

{t("text1")}
{t("text2")}
{t("language1")}
{t("language2")}
{t("add")}
); }