From 16cc50a958cf01f3a2728e28b04e16a4d4da28b9 Mon Sep 17 00:00:00 2001
From: Kakabay <2kakabayashyrberdyew@gmail.com>
Date: Tue, 24 Dec 2024 00:32:36 +0500
Subject: [PATCH] code clean up
---
app/(main)/lottery/page.tsx | 105 ++++--------------
components/lottery/LotteryHeader.tsx | 46 ++++++++
.../lottery/winners/LotteryWinnersList.tsx | 9 +-
constants/lottery.ts | 6 +
lib/hooks/useLottery.ts | 41 +++++++
typings/lottery/lottery.types.ts | 25 +++++
6 files changed, 146 insertions(+), 86 deletions(-)
create mode 100644 components/lottery/LotteryHeader.tsx
create mode 100644 constants/lottery.ts
create mode 100644 lib/hooks/useLottery.ts
create mode 100644 typings/lottery/lottery.types.ts
diff --git a/app/(main)/lottery/page.tsx b/app/(main)/lottery/page.tsx
index 9b5ad10..4199863 100644
--- a/app/(main)/lottery/page.tsx
+++ b/app/(main)/lottery/page.tsx
@@ -1,103 +1,42 @@
"use client";
-import { useState } from "react";
import { useLotteryAuth } from "@/store/useLotteryAuth";
import ProtectedRoute from "@/components/lottery/auth/ProtectedRoute";
-import { Queries } from "@/api/queries";
-import Loader from "@/components/Loader";
-import LotteryWinnersSection from "@/components/lottery/LotteryWinnersSection";
-import RollingCounter from "@/components/lottery/RollingCounter/RollingCounter";
-import RollingCounterWorking from "@/components/lottery/RollingCounter/RollingCounterWorking";
-import LotteryCountDown from "@/components/lottery/countDown/LotteryCountDown";
-import LotteryCountDownAllert from "@/components/lottery/countDown/countDownAllert/LotteryCountDownAllert";
-import LotteryForm from "@/components/lottery/form/LotteryForm";
-import LotteryRulesSection from "@/components/lottery/rules/LotteryRulesSection";
-import Image from "next/image";
-import { useRouter } from "next/navigation";
-import { useEffect } from "react";
+import { useLottery } from "@/lib/hooks/useLottery";
+import { LOTTERY_CONFIG } from "@/constants/lottery";
+import LotteryHeader from "@/components/lottery/LotteryHeader";
+import LotteryCounter from "@/components/lottery/RollingCounter/RollingCounter";
-const Page = () => {
+import LotteryWinnersSection from "@/components/lottery/LotteryWinnersSection";
+import LotteryRulesSection from "@/components/lottery/rules/LotteryRulesSection";
+
+const LotteryPage = () => {
const { lotteryData } = useLotteryAuth();
- const [lotteryStatus, setLotteryStatus] = useState<
- "not-started" | "started" | "ended"
- >("not-started");
- const [currentNumber, setCurrentNumber] = useState("22-22-22-22-22");
+ const { status, currentNumber } = useLottery(
+ LOTTERY_CONFIG.START_DATE,
+ LOTTERY_CONFIG.END_DATE
+ );
return (
- {lotteryData.data.description}
-
+ {description}
+
- {lotteryData.data.title}
-
- )}
- {lotteryData.data.description && (
-
+ {title}
+
+
The results after each stage will be shown here.
++ The results after each stage will be shown here. +