text content cahnged

This commit is contained in:
Kakabay 2025-01-24 18:20:37 +05:00
parent 1318e84044
commit 318fb775a4
2 changed files with 40 additions and 39 deletions

View File

@ -1,13 +1,13 @@
'use client'; "use client";
import { Queries } from '@/api/queries'; import { Queries } from "@/api/queries";
import { useState, FormEvent } from 'react'; import { useState, FormEvent } from "react";
import { useRouter } from 'next/navigation'; import { useRouter } from "next/navigation";
import { useLotteryAuth } from '@/store/useLotteryAuth'; import { useLotteryAuth } from "@/store/useLotteryAuth";
const LotteryAuthForm = () => { const LotteryAuthForm = () => {
const [phone, setPhone] = useState(''); const [phone, setPhone] = useState("");
const [code, setCode] = useState(''); const [code, setCode] = useState("");
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const router = useRouter(); const router = useRouter();
@ -17,9 +17,6 @@ const LotteryAuthForm = () => {
const phoneRegex = /^993\d{8}$/; const phoneRegex = /^993\d{8}$/;
const isValid = phoneRegex.test(value); const isValid = phoneRegex.test(value);
console.log('Phone Input:', value);
console.log('Regex Check Result:', isValid);
return isValid; return isValid;
}; };
@ -27,9 +24,6 @@ const LotteryAuthForm = () => {
const codeRegex = /^.+-\d{10}$/; // Any characters before "-", exactly 10 digits after const codeRegex = /^.+-\d{10}$/; // Any characters before "-", exactly 10 digits after
const isValid = codeRegex.test(value); const isValid = codeRegex.test(value);
console.log('Code Input:', value);
console.log('Regex Check Result:', isValid);
return isValid; return isValid;
}; };
@ -37,15 +31,13 @@ const LotteryAuthForm = () => {
e.preventDefault(); e.preventDefault();
setError(null); setError(null);
console.log('Submitting Phone:', phone);
if (!validatePhone(phone)) { if (!validatePhone(phone)) {
setError('Telefon belgisi nädogry'); setError("Telefon belgisi nädogry");
return; return;
} }
if (!validateCode(code)) { if (!validateCode(code)) {
setError('Açar nädogry'); setError("Açar nädogry");
return; return;
} }
@ -55,24 +47,24 @@ const LotteryAuthForm = () => {
const response = await Queries.authenticateLottery(phone, code); const response = await Queries.authenticateLottery(phone, code);
if (response.errorMessage) { if (response.errorMessage) {
setError('Telefon belgisi ýa-da açar nädogry'); setError(response.errorMessage);
} else { } else {
localStorage.setItem('lotteryPhone', phone); localStorage.setItem("lotteryPhone", phone);
localStorage.setItem('lotteryCode', code); localStorage.setItem("lotteryCode", code);
setAuth(response, phone, code); setAuth(response, phone, code);
router.replace('/lottery'); router.replace("/lottery");
} }
} catch (err) { } catch (err) {
console.error('Authentication error:', err); console.error("Authentication error:", err);
setError('Telefon belgisi ýa-da açar nädogry'); setError("Telefon belgisi ýa-da açar nädogry");
} finally { } finally {
setIsLoading(false); setIsLoading(false);
} }
}; };
const handlePhoneChange = (e: React.ChangeEvent<HTMLInputElement>) => { const handlePhoneChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const value = e.target.value.replace(/\\D/g, ''); const value = e.target.value.replace(/\\D/g, "");
if (value.length <= 11) { if (value.length <= 11) {
setPhone(value); setPhone(value);
} }
@ -88,13 +80,17 @@ const LotteryAuthForm = () => {
return ( return (
<form <form
onSubmit={handleSubmit} onSubmit={handleSubmit}
className="bg-lightSurfaceContainer rounded-[24px] md:p-[40px] sm:p-[24px] p-[16px] w-[530px] flex flex-col gap-[24px]"> className="bg-lightSurfaceContainer rounded-[24px] md:p-[40px] sm:p-[24px] p-[16px] w-[530px] flex flex-col gap-[24px]"
>
<h1 className="md:text-display3 sm:text-[32px] text-[24px] font-[500] md:leading-display3"> <h1 className="md:text-display3 sm:text-[32px] text-[24px] font-[500] md:leading-display3">
Lotereýa giriş Giriş
</h1> </h1>
<div className="flex flex-col gap-[16px]"> <div className="flex flex-col gap-[16px]">
<div className="flex flex-col gap-[8px]"> <div className="flex flex-col gap-[8px]">
<label htmlFor="phone" className="font-base-medium text-lightOnSurface cursor-pointer"> <label
htmlFor="phone"
className="font-base-medium text-lightOnSurface cursor-pointer"
>
Telefon Telefon
</label> </label>
<input <input
@ -108,7 +104,10 @@ const LotteryAuthForm = () => {
/> />
</div> </div>
<div className="flex flex-col gap-[8px]"> <div className="flex flex-col gap-[8px]">
<label htmlFor="code" className="font-base-medium text-lightOnSurface cursor-pointer"> <label
htmlFor="code"
className="font-base-medium text-lightOnSurface cursor-pointer"
>
Açar Açar
</label> </label>
@ -122,13 +121,18 @@ const LotteryAuthForm = () => {
id="code" id="code"
/> />
</div> </div>
{error && <p className="text-lightError text-textSmall leading-textSmall">{error}</p>} {error && (
<p className="text-lightError text-textSmall leading-textSmall">
{error}
</p>
)}
</div> </div>
<button <button
type="submit" type="submit"
disabled={isLoading || !phone || !code} disabled={isLoading || !phone || !code}
className="sm:text-textLarge sm:leading-textLarge text-[16px] leading-[24px] sm:py-[12px] py-[8px] w-full flex justify-center items-center rounded-[12px] bg-lightPrimary font-medium text-lightOnPrimary disabled:opacity-50"> className="sm:text-textLarge sm:leading-textLarge text-[16px] leading-[24px] sm:py-[12px] py-[8px] w-full flex justify-center items-center rounded-[12px] bg-lightPrimary font-medium text-lightOnPrimary disabled:opacity-50"
{isLoading ? 'Ýüklenilýär...' : 'Giriş'} >
{isLoading ? "Ýüklenilýär..." : "Giriş"}
</button> </button>
</form> </form>
); );

View File

@ -1,4 +1,4 @@
import { useLotteryAuth } from '@/store/useLotteryAuth'; import { useLotteryAuth } from "@/store/useLotteryAuth";
interface IProps { interface IProps {
title: string; title: string;
@ -13,18 +13,15 @@ const LotteryRulesSection = () => {
<div className="container"> <div className="container">
<div className="flex flex-col md:gap-8 gap-6"> <div className="flex flex-col md:gap-8 gap-6">
<h2 className="md:font-heading-1-regular sm:text-[32px] text-[26px] sm:leading-[40px] leading-[34px]"> <h2 className="md:font-heading-1-regular sm:text-[32px] text-[26px] sm:leading-[40px] leading-[34px]">
Bijäniň düzgünleri: Düzgünleri:
</h2> </h2>
<div className="flex sm:flex-row flex-col gap-6"> <div className="flex sm:flex-row flex-col gap-6">
<div className="flex flex-col md:gap-4 sm:gap-2 gap-4 bg-lightSurfaceContainer sm:py-4 md:px-8 sm:px-6 py-3 px-4 rounded-[12px] w-full"> <div className="flex flex-col bg-lightSurfaceContainer sm:py-4 md:px-8 sm:px-6 py-3 px-4 rounded-[12px] w-full">
<h3 className="md:font-heading-5-regular sm:text-[20px] text-[18px] sm:leading-[24px] leading-[28px]">
Umumy düzgünler:
</h3>
<ul className="list-disc flex flex-col md:gap-4 gap-2 pl-[16px]"> <ul className="list-disc flex flex-col md:gap-4 gap-2 pl-[16px]">
{lotteryData?.data.rules?.map((item, i) => ( {lotteryData?.data.rules?.map((item, i) => (
<li className="font-small-regular" key={i}> <li className="font-small-regular" key={i}>
{item.content} {item.title}
</li> </li>
))} ))}
</ul> </ul>
@ -32,7 +29,7 @@ const LotteryRulesSection = () => {
<div className="flex flex-col md:gap-4 sm:gap-2 gap-4 bg-lightSurfaceContainer sm:py-4 md:px-8 sm:px-6 py-3 px-4 rounded-[12px] w-full"> <div className="flex flex-col md:gap-4 sm:gap-2 gap-4 bg-lightSurfaceContainer sm:py-4 md:px-8 sm:px-6 py-3 px-4 rounded-[12px] w-full">
<h3 className="md:font-heading-5-regular sm:text-[20px] text-[18px] sm:leading-[24px] leading-[28px]"> <h3 className="md:font-heading-5-regular sm:text-[20px] text-[18px] sm:leading-[24px] leading-[28px]">
Siziň açar sözleriňiz: Siziň kodlaryňyz:
</h3> </h3>
<ul className="list-disc flex flex-col md:gap-4 gap-2 pl-[16px]"> <ul className="list-disc flex flex-col md:gap-4 gap-2 pl-[16px]">
{lotteryData?.user_lottery_numbers.map((item, i) => ( {lotteryData?.user_lottery_numbers.map((item, i) => (