+
{lotteryData && (
-
- )}
+
+
- {lotteryData ? (
- status === 'not-started' ? (
-
-
-
- ) : (
-
-
-
- )
- ) : null}
+ {status === "not-started" ? (
+
+
+
+ ) : null}
+
+ )}
- {(status === 'ended' || status === 'started') &&
}
+ {lotteryData && (status === "ended" || status === "started") && (
+
+
+
+
+ )}
);
diff --git a/app/globals.css b/app/globals.css
index 684f5a8..00190b0 100644
--- a/app/globals.css
+++ b/app/globals.css
@@ -93,7 +93,8 @@ html {
}
.text-stroke {
- text-shadow: -1px -1px 0 white, 1px -1px 0 white, -1px 1px 0 white, 1px 1px 0 white;
+ text-shadow: -1px -1px 0 white, 1px -1px 0 white, -1px 1px 0 white,
+ 1px 1px 0 white;
}
.big-swiper .swiper-pagination-bullet {
@@ -121,20 +122,20 @@ html {
.small-swiper .swiper-button-next:after {
color: white;
- content: url('/arrow-right-small.svg');
+ content: url("/arrow-right-small.svg");
}
.small-swiper .swiper-button-prev:after {
color: white;
- content: url('/arrow-left-small.svg');
+ content: url("/arrow-left-small.svg");
}
.big-swiper .swiper-button-next:after {
color: white;
- content: url('/arrow-right-big.svg');
+ content: url("/arrow-right-big.svg");
}
.big-swiper .swiper-button-prev:after {
color: white;
- content: url('/arrow-left-big.svg');
+ content: url("/arrow-left-big.svg");
}
video {
@@ -187,15 +188,15 @@ big {
@apply bg-[#E6E6FA] rounded-xl py-3 px-4 placeholder:text-[#BCBCD6] outline-none;
}
- .calendar [aria-label='Go to next month'] {
+ .calendar [aria-label="Go to next month"] {
@apply shadow-sm transition-all;
}
- .calendar [aria-label='Go to previous month'] {
+ .calendar [aria-label="Go to previous month"] {
@apply shadow-sm transition-all;
}
- .day-styles [name='day'] {
+ .day-styles [name="day"] {
@apply p-4 text-textDarkt leading-[140%] bg-purple-600 rounded-full;
}
@@ -261,20 +262,12 @@ big {
}
.wheel-circle {
- background: url('/wheel-circle.svg');
+ background: url("/wheel-circle.svg");
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}
-.rolling-number {
- font-size: 80px;
- letter-spacing: -1%;
- padding: 0px 16px;
-
- @apply text-lightOnPrimary;
-}
-
.index-module_slot__DpPgW {
overflow: visible !important;
/* height: auto !important; */
@@ -303,11 +296,53 @@ big {
} */
.slot-seperator {
- content: url('/dash.svg');
+ content: url("/dash.svg");
background-position: center;
background-size: cover;
background-repeat: no-repeat;
- margin: 0 20px;
+ @apply md:mx-5;
+}
+
+.rolling-number {
+ @apply text-lightOnPrimary md:text-[80px] md:leading-[88px] -tracking-[1%] md:px-4;
+}
+
+@media (max-width: 1025px) {
+ .rolling-number {
+ @apply text-[48px] px-2;
+ }
+}
+
+@media (max-width: 1024px) {
+ .slot-seperator {
+ content: url("/dash-md.svg");
+ @apply mx-2;
+ }
+}
+
+@media (max-width: 1025px) {
+ .rolling-number {
+ @apply text-[48px] px-2;
+ }
+}
+
+@media (max-width: 426px) {
+ .rolling-number {
+ @apply text-[24px] px-1;
+ }
+}
+
+@media (max-width: 320px) {
+ .rolling-number {
+ @apply text-[16px] px-1;
+ }
+}
+
+@media (max-width: 426px) {
+ .slot-seperator {
+ content: url("/dash-sm.svg");
+ @apply mx-2;
+ }
}
.confetti-piece {
@@ -324,7 +359,8 @@ big {
transform: translateX(0) translateY(0) rotate(0deg);
}
50% {
- transform: translateX(calc(var(--end-x) / 2)) translateY(-30vh) rotate(180deg);
+ transform: translateX(calc(var(--end-x) / 2)) translateY(-30vh)
+ rotate(180deg);
}
100% {
opacity: 0;
diff --git a/components/lottery/LotteryWinnersSection.tsx b/components/lottery/LotteryWinnersSection.tsx
index 2488b88..91e4439 100644
--- a/components/lottery/LotteryWinnersSection.tsx
+++ b/components/lottery/LotteryWinnersSection.tsx
@@ -1,34 +1,43 @@
-'use client';
+"use client";
-import { useState, useEffect, useRef } from 'react';
-import { useLotteryAuth } from '@/store/useLotteryAuth';
-import { LotteryWinnerDataSimplified } from '@/typings/lottery/lottery.types';
-import LotteryWinnersList from './winners/LotteryWinnersList';
-import LotterySlotCounter from './slotCounter/LotterySlotCounter';
-import ReactConfetti from 'react-confetti';
-import { useWindowSize } from 'react-use';
+import { useState, useEffect, useRef } from "react";
+import { useLotteryAuth } from "@/store/useLotteryAuth";
+import { LotteryWinnerDataSimplified } from "@/typings/lottery/lottery.types";
+import LotteryWinnersList from "./winners/LotteryWinnersList";
+import LotterySlotCounter from "./slotCounter/LotterySlotCounter";
+import ReactConfetti from "react-confetti";
+import { useWindowSize } from "react-use";
+import LotteryCountDownAllert from "./countDown/countDownAllert/LotteryCountDownAllert";
-const WEBSOCKET_URL = 'wss://sms.turkmentv.gov.tm/ws/lottery?dst=0506';
+const WEBSOCKET_URL = "wss://sms.turkmentv.gov.tm/ws/lottery?dst=0506";
const PING_INTERVAL = 25000;
const SLOT_COUNTER_DURATION = 20000;
-const LotteryWinnersSection = () => {
+const LotteryWinnersSection = ({
+ lotteryStatus,
+}: {
+ lotteryStatus: string;
+}) => {
// UI States
const [winners, setWinners] = useState
([]);
- const [currentNumber, setCurrentNumber] = useState('00-00-00-00-00');
+ const [currentNumber, setCurrentNumber] = useState("00-00-00-00-00");
const [isConfettiActive, setIsConfettiActive] = useState(false);
- const [wsStatus, setWsStatus] = useState<'connecting' | 'connected' | 'error'>('connecting');
+
+ const [wsStatus, setWsStatus] = useState<
+ "connecting" | "connected" | "error"
+ >("connecting");
const { width, height } = useWindowSize();
const { lotteryData } = useLotteryAuth();
const [isSlotCounterAnimating, setIsSlotCounterAnimating] = useState(false);
- const [pendingWinner, setPendingWinner] = useState(null);
+ const [pendingWinner, setPendingWinner] =
+ useState(null);
// Refs
const wsRef = useRef(null);
const pingIntervalRef = useRef();
const mountedRef = useRef(false);
- console.log(isConfettiActive, 'isConfettiActive');
+ console.log(isConfettiActive, "isConfettiActive");
// Initialize winners from lottery data
useEffect(() => {
@@ -39,7 +48,9 @@ const LotteryWinnersSection = () => {
ticket: winner.ticket,
}));
setWinners(simplifiedWinners);
- setCurrentNumber(lotteryData.data.winners.at(-1)?.ticket || '00-00-00-00-00');
+ setCurrentNumber(
+ lotteryData.data.winners.at(-1)?.ticket || "00-00-00-00-00"
+ );
}
}, [lotteryData]);
@@ -52,21 +63,21 @@ const LotteryWinnersSection = () => {
const socket = new WebSocket(WEBSOCKET_URL);
wsRef.current = socket;
- socket.addEventListener('open', () => {
+ socket.addEventListener("open", () => {
if (!mountedRef.current) return;
- console.log('WebSocket Connected');
- setWsStatus('connected');
+ console.log("WebSocket Connected");
+ setWsStatus("connected");
pingIntervalRef.current = setInterval(() => {
if (socket.readyState === WebSocket.OPEN) {
- socket.send(JSON.stringify({ type: 'ping' }));
+ socket.send(JSON.stringify({ type: "ping" }));
}
}, PING_INTERVAL);
});
- socket.addEventListener('message', async (event) => {
+ socket.addEventListener("message", async (event) => {
if (!mountedRef.current) return;
- console.log('Message received:', event.data);
+ console.log("Message received:", event.data);
try {
const newWinner = JSON.parse(event.data);
@@ -82,7 +93,9 @@ const LotteryWinnersSection = () => {
setCurrentNumber(winnerData.ticket);
// Wait for slot counter animation
- await new Promise((resolve) => setTimeout(resolve, SLOT_COUNTER_DURATION));
+ await new Promise((resolve) =>
+ setTimeout(resolve, SLOT_COUNTER_DURATION)
+ );
setIsConfettiActive(true);
setWinners((prev) => [...prev, winnerData]);
@@ -111,30 +124,30 @@ const LotteryWinnersSection = () => {
}, 5000);
}
} catch (error) {
- console.error('Error processing message:', error);
+ console.error("Error processing message:", error);
setIsSlotCounterAnimating(false);
setPendingWinner(null);
}
});
- socket.addEventListener('error', (error) => {
+ socket.addEventListener("error", (error) => {
if (!mountedRef.current) return;
- console.error('WebSocket Error:', error);
- setWsStatus('error');
+ console.error("WebSocket Error:", error);
+ setWsStatus("error");
});
- socket.addEventListener('close', () => {
+ socket.addEventListener("close", () => {
if (!mountedRef.current) return;
- console.log('WebSocket Closed');
- setWsStatus('error');
+ console.log("WebSocket Closed");
+ setWsStatus("error");
if (pingIntervalRef.current) {
clearInterval(pingIntervalRef.current);
}
});
} catch (error) {
- console.error('Error creating WebSocket:', error);
- setWsStatus('error');
+ console.error("Error creating WebSocket:", error);
+ setWsStatus("error");
}
};
@@ -154,7 +167,7 @@ const LotteryWinnersSection = () => {
return (
- {wsStatus === 'error' && (
+ {wsStatus === "error" && (
Connection error. Please refresh the page.
@@ -170,12 +183,12 @@ const LotteryWinnersSection = () => {
tweenDuration={10000}
run={true}
colors={[
- 'linear-gradient(45deg, #5D5D72, #8589DE)',
- 'linear-gradient(45deg, #E1E0FF, #575992)',
- '#8589DE',
- '#575992',
- '#E1E0FF',
- '#BA1A1A',
+ "linear-gradient(45deg, #5D5D72, #8589DE)",
+ "linear-gradient(45deg, #E1E0FF, #575992)",
+ "#8589DE",
+ "#575992",
+ "#E1E0FF",
+ "#BA1A1A",
]}
/>
@@ -183,10 +196,13 @@ const LotteryWinnersSection = () => {