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

View File

@ -138,9 +138,9 @@ const Nav = () => {
Sowgatlar
</Link>
<Link
href={'/cekilis/auth'}
href={'/b'}
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)}>
Bije
</Link>

View File

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

View File

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