From 481158dd851a05ceba1d69c4dd403f6e8b0eabb6 Mon Sep 17 00:00:00 2001 From: imnyang Date: Wed, 24 Dec 2025 13:30:13 +0900 Subject: [PATCH] feat: Implement input dialog for secret code submission and result display --- src/components/txt.tsx | 93 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 81 insertions(+), 12 deletions(-) diff --git a/src/components/txt.tsx b/src/components/txt.tsx index d244e17..329adc8 100644 --- a/src/components/txt.tsx +++ b/src/components/txt.tsx @@ -1,5 +1,16 @@ import Image from "next/image"; +import { useState } from "react"; import { useIsMobile } from "@/hooks/use-mobile"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; interface TXTProps { onHover?: (position: { x: number; y: number } | null) => void; @@ -7,21 +18,79 @@ interface TXTProps { export default function TXT({ onHover }: TXTProps) { const isMobile = useIsMobile(); + const [openInput, setOpenInput] = useState(false); + const [openResult, setOpenResult] = useState(false); + const [key, setKey] = useState(""); + const [error, setError] = useState(""); + const [content, setContent] = useState(""); + + const handleSubmit = async () => { + setError(""); + setContent(""); + try { + const response = await fetch(`https://api.imnya.ng/secret?key=${encodeURIComponent(key)}`); + const data = await response.text(); + if (data === "false") { + setError("아니요?"); + } else { + setOpenInput(false); + setOpenResult(true); + setContent(data); + } + } catch (_err) { + console.error(_err); + setError("오류가 발생했습니다"); + } + }; if (isMobile) return null; return ( -
onHover?.({ x: 16, y: 16 })} - onMouseLeave={() => onHover?.(null)} - onClick={() => { - alert("왜 편법을 쓰지?"); - window.location.reload(); - }} - > - txt - 비밀.txt -
+ <> + + + + + 비밀 코드 입력 + + 비밀 코드를 입력하세요. + + +
+ setKey(e.target.value)} + /> + {error &&

{error}

} +
+ + + +
+
+ + + + 비밀.txt + + {content} + + + + + + + + ); } \ No newline at end of file