route changes

This commit is contained in:
Ilgeldi 2025-02-16 14:20:28 +05:00
parent 87771711e2
commit 40546c8a3d
6 changed files with 84 additions and 70 deletions

View File

@ -1,12 +1,12 @@
'use client'; "use client";
import Image from 'next/image'; import Image from "next/image";
import Link from 'next/link'; import Link from "next/link";
import { usePathname } from 'next/navigation'; import { usePathname } from "next/navigation";
import { useContext, useEffect, useRef, useState } from 'react'; import { useContext, useEffect, useRef, useState } from "react";
import GlobalContext from '@/context/GlobalContext'; import GlobalContext from "@/context/GlobalContext";
import close from '@/public/close-white.svg'; import close from "@/public/close-white.svg";
const MobileMenu = () => { const MobileMenu = () => {
const path = usePathname() ?? '/'; const path = usePathname() ?? "/";
const { burgerOpen, setBurgerOpen } = useContext(GlobalContext).burgerContext; const { burgerOpen, setBurgerOpen } = useContext(GlobalContext).burgerContext;
const onClickCloseBurgerHandler = () => { const onClickCloseBurgerHandler = () => {
@ -18,17 +18,20 @@ const MobileMenu = () => {
useEffect(() => { useEffect(() => {
const handleOutsideClick = (event: MouseEvent) => { const handleOutsideClick = (event: MouseEvent) => {
if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) { if (
dropdownRef.current &&
!dropdownRef.current.contains(event.target as Node)
) {
setDropDownOpened(false); setDropDownOpened(false);
} }
}; };
// Attach the event listener to the document // Attach the event listener to the document
document.addEventListener('click', handleOutsideClick); document.addEventListener("click", handleOutsideClick);
// Cleanup the event listener when the component unmounts // Cleanup the event listener when the component unmounts
return () => { return () => {
document.removeEventListener('click', handleOutsideClick); document.removeEventListener("click", handleOutsideClick);
}; };
}, []); }, []);
@ -39,10 +42,10 @@ const MobileMenu = () => {
<div className="container"> <div className="container">
<div className="w-full h-screen flex flex-col gap-10"> <div className="w-full h-screen flex flex-col gap-10">
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<Link href={'/'} className="logo"> <Link href={"/"} className="logo">
<Image <Image
priority priority
src={'/logo.png'} src={"/logo.png"}
alt="logo" alt="logo"
unoptimized unoptimized
unselectable="off" unselectable="off"
@ -53,7 +56,8 @@ const MobileMenu = () => {
</Link> </Link>
<div <div
className="relative w-[24px] h-[24px] cursor-pointer " className="relative w-[24px] h-[24px] cursor-pointer "
onClick={() => setBurgerOpen(false)}> onClick={() => setBurgerOpen(false)}
>
<Image src={close} fill alt="menu" /> <Image src={close} fill alt="menu" />
</div> </div>
</div> </div>
@ -69,41 +73,47 @@ const MobileMenu = () => {
</li> */} </li> */}
<li> <li>
<Link <Link
href={'/treasury'} href={"/treasury"}
onClick={() => onClickCloseBurgerHandler()} onClick={() => onClickCloseBurgerHandler()}
className="block text-3xl text-white transition-all font-roboto font-bold dark:text-white" className="block text-3xl text-white transition-all font-roboto font-bold dark:text-white"
style={ style={
path.includes('treasury') || path.includes('video/') path.includes("treasury") || path.includes("video/")
? { color: '#FFAB48' } ? { color: "#FFAB48" }
: {} : {}
}> }
>
Hazyna Hazyna
</Link> </Link>
</li> </li>
<li> <li>
<Link <Link
href={'/live'} href={"/live"}
onClick={() => onClickCloseBurgerHandler()} onClick={() => onClickCloseBurgerHandler()}
className="block text-3xl text-white transition-all font-roboto font-bold dark:text-white" className="block text-3xl text-white transition-all font-roboto font-bold dark:text-white"
style={path.includes('live') ? { color: '#FFAB48' } : {}}> style={path.includes("live") ? { color: "#FFAB48" } : {}}
>
Göni Ýaýlym Göni Ýaýlym
</Link> </Link>
</li> </li>
<li> <li>
<Link <Link
href={'/advert'} href={"/advert"}
onClick={() => onClickCloseBurgerHandler()} onClick={() => onClickCloseBurgerHandler()}
className="block text-3xl text-white transition-all font-roboto font-bold dark:text-white" className="block text-3xl text-white transition-all font-roboto font-bold dark:text-white"
style={path.includes('advert') ? { color: '#FFAB48' } : {}}> style={path.includes("advert") ? { color: "#FFAB48" } : {}}
>
Mahabat Mahabat
</Link> </Link>
</li> </li>
<li> <li>
<Link <Link
href={'/contact_us'} href={"/contact_us"}
onClick={() => onClickCloseBurgerHandler()} onClick={() => onClickCloseBurgerHandler()}
style={path.includes('contact_us') ? { color: '#FFAB48' } : {}} style={
className="font-roboto font-bold text-white text-3xl dark:text-white transition-all"> path.includes("contact_us") ? { color: "#FFAB48" } : {}
}
className="font-roboto font-bold text-white text-3xl dark:text-white transition-all"
>
Habarlaşmak üçin Habarlaşmak üçin
</Link> </Link>
</li> </li>
@ -111,7 +121,8 @@ const MobileMenu = () => {
<div <div
ref={dropdownRef} ref={dropdownRef}
className="flex flex-col cursor-pointer relative" className="flex flex-col cursor-pointer relative"
onClick={() => setDropDownOpened(!dropDownOpened)}> onClick={() => setDropDownOpened(!dropDownOpened)}
>
<div className="flex items-center gap-[8px]"> <div className="flex items-center gap-[8px]">
<span className="block text-3xl text-white transition-all font-roboto font-bold"> <span className="block text-3xl text-white transition-all font-roboto font-bold">
Interaktiw Interaktiw
@ -123,8 +134,9 @@ const MobileMenu = () => {
viewBox="0 0 24 24" viewBox="0 0 24 24"
fill="none" fill="none"
className={`${ className={`${
dropDownOpened ? '' : 'rotate-180' dropDownOpened ? "" : "rotate-180"
} transition-all ease-in duration-150`}> } transition-all ease-in duration-150`}
>
<path <path
d="M7.41 15.41L12 10.83L16.59 15.41L18 14L12 8L6 14L7.41 15.41Z" d="M7.41 15.41L12 10.83L16.59 15.41L18 14L12 8L6 14L7.41 15.41Z"
fill="#fff" fill="#fff"
@ -135,56 +147,68 @@ const MobileMenu = () => {
<div <div
className={` flex flex-col gap-4 rounded-[8px] transition-all duration-150 ${ className={` flex flex-col gap-4 rounded-[8px] transition-all duration-150 ${
dropDownOpened dropDownOpened
? 'h-fit opacity-100 pointer-events-auto py-[16px] px-[24px]' ? "h-fit opacity-100 pointer-events-auto py-[16px] px-[24px]"
: ' h-0 opacity-0 pointer-events-none' : " h-0 opacity-0 pointer-events-none"
}`}> }`}
>
<Link <Link
href={'/quiz'} href={"/quiz"}
className="block text-2xl text-white transition-all font-roboto font-bold " className="block text-2xl text-white transition-all font-roboto font-bold "
style={path.includes('quiz') ? { color: '#FFAB48' } : {}} style={
path.includes("quiz") ? { color: "#FFAB48" } : {}
}
onClick={() => { onClick={() => {
setDropDownOpened(false); setDropDownOpened(false);
onClickCloseBurgerHandler(); onClickCloseBurgerHandler();
}}> }}
>
Bäsleşik Bäsleşik
</Link> </Link>
<Link <Link
href={'/vote'} href={"/vote"}
className="block text-2xl text-white transition-all font-roboto font-bold " className="block text-2xl text-white transition-all font-roboto font-bold "
style={path.includes('vote') ? { color: '#FFAB48' } : {}} style={
path.includes("vote") ? { color: "#FFAB48" } : {}
}
onClick={() => { onClick={() => {
setDropDownOpened(false); setDropDownOpened(false);
onClickCloseBurgerHandler(); onClickCloseBurgerHandler();
}}> }}
>
Ses bermek Ses bermek
</Link> </Link>
<Link <Link
href={'https://shop.turkmentv.gov.tm/'} href={"https://shop.turkmentv.gov.tm/"}
className="block text-2xl text-white transition-all font-roboto font-bold" className="block text-2xl text-white transition-all font-roboto font-bold"
onClick={() => { onClick={() => {
setDropDownOpened(false); setDropDownOpened(false);
onClickCloseBurgerHandler(); onClickCloseBurgerHandler();
}}> }}
>
TV market TV market
</Link> </Link>
<Link <Link
href={'/prizes/auth'} href={"/prizes/auth"}
className="block text-2xl text-white transition-all font-roboto font-bold" className="block text-2xl text-white transition-all font-roboto font-bold"
style={path.includes('prizes') ? { color: '#FFAB48' } : {}} style={
path.includes("prizes") ? { color: "#FFAB48" } : {}
}
onClick={() => { onClick={() => {
setDropDownOpened(false); setDropDownOpened(false);
onClickCloseBurgerHandler(); onClickCloseBurgerHandler();
}}> }}
>
Sowgatlar Sowgatlar
</Link> </Link>
<Link <Link
href={'/cekilis/auth'} href={"/b"}
className="block text-2xl text-white transition-all font-roboto font-bold" className="block text-2xl text-white transition-all font-roboto font-bold"
style={path.includes('cekilis') ? { color: '#FFAB48' } : {}} style={path.includes("b") ? { color: "#FFAB48" } : {}}
onClick={() => { onClick={() => {
setDropDownOpened(false); setDropDownOpened(false);
onClickCloseBurgerHandler(); onClickCloseBurgerHandler();
}}> }}
>
Bije Bije
</Link> </Link>
</div> </div>
@ -193,9 +217,10 @@ const MobileMenu = () => {
<li> <li>
<Link <Link
target="_blank" target="_blank"
href={'https://turkmentv.gov.tm/mahabat/admin/user/login'} href={"https://turkmentv.gov.tm/mahabat/admin/user/login"}
onClick={() => onClickCloseBurgerHandler()} onClick={() => onClickCloseBurgerHandler()}
className="font-roboto font-bold text-white text-3xl dark:text-white transition-all p-2 bg-red-500 rounded-lg "> className="font-roboto font-bold text-white text-3xl dark:text-white transition-all p-2 bg-red-500 rounded-lg "
>
Ýaýlym tertibi Ýaýlym tertibi
</Link> </Link>
</li> </li>

View File

@ -138,9 +138,9 @@ const Nav = () => {
Sowgatlar Sowgatlar
</Link> </Link>
<Link <Link
href={'/cekilis/auth'} href={'/b'}
className="block min-w-fit text-lg text-white transition-all font-roboto font-bold" className="block min-w-fit text-lg text-white transition-all font-roboto font-bold"
style={path.includes('cekilis') ? { color: '#FFAB48' } : {}} style={path.includes('b') ? { color: '#FFAB48' } : {}}
onClick={() => setDropDownOpened(false)}> onClick={() => setDropDownOpened(false)}>
Bije Bije
</Link> </Link>

View File

@ -4,36 +4,25 @@ import LotteryRulesSection from "@/components/lottery/rules/LotteryRulesSection"
import LotteryCountDown from "@/components/lottery/countDown/LotteryCountDown"; import LotteryCountDown from "@/components/lottery/countDown/LotteryCountDown";
import Link from "next/link"; import Link from "next/link";
import { authenticateLottery } from "@/api"; import { authenticateLottery } from "@/api";
import { redirect } from "next/navigation"; import { useRouter } from "next/navigation";
import { getLotteryStatus } from "@/lib/actions"; import { getLotteryStatus } from "@/lib/actions";
import LotteryWinners from "./LotteryWinners"; import LotteryWinners from "./LotteryWinners";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { ILotteryResponse } from "@/models/lottery/lottery.model";
const LotteryMain = () => { const LotteryMain = () => {
const [lotteryData, setLotteryData] = useState<any>(); const [lotteryData, setLotteryData] = useState<any>();
const router = useRouter();
useEffect(() => { useEffect(() => {
async function getData() { async function getData() {
const phone = document.cookie const phone = localStorage.getItem("phoneNumber");
.split("; ") const key = localStorage.getItem("key");
[
document.cookie
.split("; ")
.findIndex((item) => item.startsWith("phoneNumber="))
].split("=")[1];
const key = document.cookie
.split("; ")
[
document.cookie
.split("; ")
.findIndex((item) => item.startsWith("key="))
].split("=")[1];
if (phone && key) { if (phone && key) {
const res = await authenticateLottery(phone, key); const res = await authenticateLottery(phone, key);
setLotteryData(res); setLotteryData(res);
} else { } else {
redirect("/cekilis/auth"); localStorage.clear();
router.push("/b/auth");
} }
} }
@ -77,7 +66,7 @@ const LotteryMain = () => {
<div className="w-full"> <div className="w-full">
<div className="container"> <div className="container">
<Link <Link
href="/cekilis/auth" href="/b/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" 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 Çykmak

View File

@ -36,9 +36,9 @@ const LotteryAuthForm = () => {
if (response.errorMessage) { if (response.errorMessage) {
setError(response.errorMessage); setError(response.errorMessage);
} else { } else {
document.cookie = `phoneNumber=${phoneNumber};path=/;max-age=3600;`; localStorage.setItem("phoneNumber", phoneNumber);
document.cookie = `key=${key};path=/;max-age=3600;`; localStorage.setItem("key", key);
router.replace("/cekilis"); router.replace("/b");
} }
} catch (err) { } catch (err) {
setError("Telefon belgisi ýa-da açar nädogry"); setError("Telefon belgisi ýa-da açar nädogry");