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 { 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<string | null>(null);
const [isLoading, setIsLoading] = useState(false);
const router = useRouter();
@ -17,9 +17,6 @@ const LotteryAuthForm = () => {
const phoneRegex = /^993\d{8}$/;
const isValid = phoneRegex.test(value);
console.log('Phone Input:', value);
console.log('Regex Check Result:', isValid);
return isValid;
};
@ -27,9 +24,6 @@ const LotteryAuthForm = () => {
const codeRegex = /^.+-\d{10}$/; // Any characters before "-", exactly 10 digits after
const isValid = codeRegex.test(value);
console.log('Code Input:', value);
console.log('Regex Check Result:', isValid);
return isValid;
};
@ -37,15 +31,13 @@ const LotteryAuthForm = () => {
e.preventDefault();
setError(null);
console.log('Submitting Phone:', phone);
if (!validatePhone(phone)) {
setError('Telefon belgisi nädogry');
setError("Telefon belgisi nädogry");
return;
}
if (!validateCode(code)) {
setError('Açar nädogry');
setError("Açar nädogry");
return;
}
@ -55,24 +47,24 @@ const LotteryAuthForm = () => {
const response = await Queries.authenticateLottery(phone, code);
if (response.errorMessage) {
setError('Telefon belgisi ýa-da açar nädogry');
setError(response.errorMessage);
} else {
localStorage.setItem('lotteryPhone', phone);
localStorage.setItem('lotteryCode', code);
localStorage.setItem("lotteryPhone", phone);
localStorage.setItem("lotteryCode", code);
setAuth(response, phone, code);
router.replace('/lottery');
router.replace("/lottery");
}
} catch (err) {
console.error('Authentication error:', err);
setError('Telefon belgisi ýa-da açar nädogry');
console.error("Authentication error:", err);
setError("Telefon belgisi ýa-da açar nädogry");
} finally {
setIsLoading(false);
}
};
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) {
setPhone(value);
}
@ -88,13 +80,17 @@ const LotteryAuthForm = () => {
return (
<form
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">
Lotereýa giriş
Giriş
</h1>
<div className="flex flex-col gap-[16px]">
<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
</label>
<input
@ -108,7 +104,10 @@ const LotteryAuthForm = () => {
/>
</div>
<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
</label>
@ -122,13 +121,18 @@ const LotteryAuthForm = () => {
id="code"
/>
</div>
{error && <p className="text-lightError text-textSmall leading-textSmall">{error}</p>}
{error && (
<p className="text-lightError text-textSmall leading-textSmall">
{error}
</p>
)}
</div>
<button
type="submit"
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">
{isLoading ? 'Ýüklenilýär...' : 'Giriş'}
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ş"}
</button>
</form>
);

View File

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