testing again

This commit is contained in:
Kakabay 2025-01-29 18:49:28 +05:00
parent bd79394c89
commit 5f15114f96
2 changed files with 43 additions and 38 deletions

View File

@ -34,6 +34,8 @@ const LotteryPage = () => {
if (response.errorMessage) { if (response.errorMessage) {
// If authentication fails, redirect to the auth page // If authentication fails, redirect to the auth page
console.log("redirecting form lottery/");
router.replace("/lottery/auth"); router.replace("/lottery/auth");
} else { } else {
// ✅ Set the authenticated state // ✅ Set the authenticated state
@ -53,7 +55,7 @@ const LotteryPage = () => {
checkAuth(); checkAuth();
}, [router, setAuth]); }, [router, setAuth]);
if (isLoading) { if (isLoading && !lotteryData?.data) {
<div className="flex w-full h-[90vh] justify-center items-center"> <div className="flex w-full h-[90vh] justify-center items-center">
<Loader /> <Loader />
</div>; </div>;
@ -61,48 +63,50 @@ const LotteryPage = () => {
return ( return (
<ProtectedRoute> <ProtectedRoute>
<div className="flex flex-col md:gap-[128px] gap-[80px] font-roboto md:pt-[64px] sm:pt-[48px] pt-[40px] ms:pb-[128px] pb-[80px] text-lightOnSurface"> {lotteryData?.data && (
{lotteryData && ( <div className="flex flex-col md:gap-[128px] gap-[80px] font-roboto md:pt-[64px] sm:pt-[48px] pt-[40px] ms:pb-[128px] pb-[80px] text-lightOnSurface">
<div className="flex flex-col sm:gap-[64px] gap-[40px]"> {lotteryData && (
<LotteryHeader <div className="flex flex-col sm:gap-[64px] gap-[40px]">
title={lotteryData.data.title} <LotteryHeader
description={lotteryData.data.description} title={lotteryData.data.title}
image={lotteryData.data.image} description={lotteryData.data.description}
smsCode={lotteryData.data.sms_code} image={lotteryData.data.image}
startDate={lotteryData.data.start_time} smsCode={lotteryData.data.sms_code}
/> startDate={lotteryData.data.start_time}
/>
{status === "not-started" ? ( {status === "not-started" ? (
<div className="container"> <div className="container">
<LotteryCountDown <LotteryCountDown
lotteryStatus={status} lotteryStatus={status}
setLotteryStatus={setStatus} setLotteryStatus={setStatus}
endDate={lotteryData.data.end_time} endDate={lotteryData.data.end_time}
startDate={lotteryData.data.start_time} startDate={lotteryData.data.start_time}
/> />
</div> </div>
) : null} ) : null}
</div> </div>
)}
<LotteryRulesSection />
<div className="flex flex-col gap-10">
{lotteryData && (status === "ended" || status === "started") && (
<LotteryWinnersSection lotteryStatus={status} />
)} )}
<div className="w-full">
<div className="container"> <LotteryRulesSection />
<Link
href="/lottery/auth" <div className="flex flex-col gap-10">
className="sm:text-textLarge sm:leading-textLarge text-[16px] rounded-full leading-[24px] sm:py-[12px] py-[8px] w-full flex justify-center items-center border-2 border-lightPrimary hover:bg-lightPrimary font-medium text-lightPrimary hover:text-lightOnPrimary disabled:opacity-50 transition-all duration-300" {lotteryData && (status === "ended" || status === "started") && (
> <LotteryWinnersSection lotteryStatus={status} />
Çykmak )}
</Link> <div className="w-full">
<div className="container">
<Link
href="/lottery/auth"
className="sm:text-textLarge sm:leading-textLarge text-[16px] rounded-full leading-[24px] sm:py-[12px] py-[8px] w-full flex justify-center items-center border-2 border-lightPrimary hover:bg-lightPrimary font-medium text-lightPrimary hover:text-lightOnPrimary disabled:opacity-50 transition-all duration-300"
>
Çykmak
</Link>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> )}
</ProtectedRoute> </ProtectedRoute>
); );
}; };

View File

@ -23,6 +23,7 @@ const ProtectedRoute = ({ children }: { children: React.ReactNode }) => {
if (response.errorMessage) { if (response.errorMessage) {
// If authentication fails, redirect to the auth page // If authentication fails, redirect to the auth page
console.log("redirecting form protected route");
router.replace("/lottery/auth"); router.replace("/lottery/auth");
} else { } else {
// ✅ Set the authenticated state // ✅ Set the authenticated state