"use client"; import { useQuizResults, useResultsLoading } from "@/store/store"; import React, { useState } from "react"; const QuizResultsSearch = ({ id }: { id: string }) => { const [phone, setPhone] = useState(""); const { setError, setResultData } = useQuizResults(); const { setLoading } = useResultsLoading(); const handleSearchSubmit = async (event: any) => { if (event.key === "Enter" && phone.length === 8) { event.preventDefault(); try { setLoading(true); const response = await fetch( `https://sms.turkmentv.gov.tm/api/quiz/${id}/search_netije`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ phone }), } ); // Handle the response as needed const data = await response.json(); setLoading(false); if (!data.error) { setResultData([data.data]); } else { setResultData([]); setError("Telefon belgisi tapylmady"); } } catch (error) { console.log(error); } } }; return (

Öz jogaplaryňyzy görüň

setPhone(e.target.value)} onKeyDown={(e) => handleSearchSubmit(e)} maxLength={8} minLength={8} />
); }; export default QuizResultsSearch;