diff --git a/components/lottery/auth/LotteryAuthForm.tsx b/components/lottery/auth/LotteryAuthForm.tsx index 3ea84ed..a6e982e 100644 --- a/components/lottery/auth/LotteryAuthForm.tsx +++ b/components/lottery/auth/LotteryAuthForm.tsx @@ -1,20 +1,20 @@ -"use client"; +'use client'; -import { Queries } from "@/api/queries"; -import { useState, FormEvent } from "react"; -import { useRouter } from "next/navigation"; -import { useLotteryAuth } from "@/store/useLotteryAuth"; +import { Queries } from '@/api/queries'; +import { useState, FormEvent } from 'react'; +import { useRouter } from 'next/navigation'; +import { useLotteryAuth } from '@/store/useLotteryAuth'; const LotteryAuthForm = () => { - const [phone, setPhone] = useState(""); - const [code, setCode] = useState(""); + const [phone, setPhone] = useState(''); + const [code, setCode] = useState(''); const [error, setError] = useState(null); const [isLoading, setIsLoading] = useState(false); const router = useRouter(); const setAuth = useLotteryAuth((state) => state.setAuth); const validatePhone = (value: string) => { - const phoneRegex = /^99363\d{6}$/; + const phoneRegex = /^993\d{8}$/; return phoneRegex.test(value); }; @@ -28,12 +28,12 @@ const LotteryAuthForm = () => { setError(null); if (!validatePhone(phone)) { - setError("Telefon belgisi nädogry formatda"); + setError('Telefon belgisi nädogry'); return; } if (!validateCode(code)) { - setError("Kod nädogry formatda"); + setError('Açar nädogry'); return; } @@ -42,19 +42,19 @@ const LotteryAuthForm = () => { try { const response = await Queries.authenticateLottery(phone, code); setAuth(response, phone, code); - router.replace("/lottery"); + router.replace('/lottery'); } catch (err) { - console.error("Authentication error:", err); - setError("Telefon belgisi ýa-da kod nädogry"); + console.error('Authentication error:', err); + setError('Telefon belgisi ýa-da açar nädogry'); } finally { setIsLoading(false); } }; const handlePhoneChange = (e: React.ChangeEvent) => { - const value = e.target.value.replace(/\D/g, ""); // Remove non-digits + const value = e.target.value.replace(/\D/g, ''); // Remove non-digits if (value.length <= 11) { - // Limit to 11 digits (99363 + 6 digits) + // Limit to 11 digits (993 + 8 digits) setPhone(value); } }; @@ -70,13 +70,15 @@ const LotteryAuthForm = () => { return (
+ className="bg-lightSurfaceContainer rounded-[24px] md:p-[40px] sm:p-[24px] p-[16px] w-[530px] flex flex-col gap-[24px]">

Lotereýa giriş

+ { className="px-[16px] py-[12px] bg-lightPrimaryContainer rounded-[12px] outline-none text-lightOnSurfaceVariant text-textSmall leading-textSmall" placeholder="99363XXXXXX" required + id="phone" />
+ + { className="px-[16px] py-[12px] bg-lightPrimaryContainer rounded-[12px] outline-none text-lightOnSurfaceVariant text-textSmall leading-textSmall" placeholder="5-0105639808" required + id="code" />
- {error && ( -

- {error} -

- )} + {error &&

{error}

}
);