From db2c990744f04a2d27f081a8cbb8e63120f2a20e Mon Sep 17 00:00:00 2001 From: Kakabay <2kakabayashyrberdyew@gmail.com> Date: Mon, 14 Oct 2024 19:16:15 +0500 Subject: [PATCH] cimmit --- app/(prizes)/prizes/[user_id]/page.tsx | 166 ++++++++++++------------- app/(prizes)/prizes/auth/page.tsx | 24 ++-- components/MobileMenu.tsx | 4 +- components/Nav.tsx | 4 +- 4 files changed, 99 insertions(+), 99 deletions(-) diff --git a/app/(prizes)/prizes/[user_id]/page.tsx b/app/(prizes)/prizes/[user_id]/page.tsx index 9d24e23..6254e18 100644 --- a/app/(prizes)/prizes/[user_id]/page.tsx +++ b/app/(prizes)/prizes/[user_id]/page.tsx @@ -1,90 +1,90 @@ -// 'use client'; -// import PrizeCard from '@/components/prizes/PrizeCard'; -// import { useState } from 'react'; -// import axios from 'axios'; -// import { useQuery, useQueryClient } from '@tanstack/react-query'; -// import { GiftsType } from '@/typings/gifts/gifts.type'; -// import { useRouter } from 'next/navigation'; +'use client'; +import PrizeCard from '@/components/prizes/PrizeCard'; +import { useState } from 'react'; +import axios from 'axios'; +import { useQuery, useQueryClient } from '@tanstack/react-query'; +import { GiftsType } from '@/typings/gifts/gifts.type'; +import { useRouter } from 'next/navigation'; -// // Define the expected shape of the fetched data -// interface Prize { -// id: number; -// name: string; -// description: string; -// } +// Define the expected shape of the fetched data +interface Prize { + id: number; + name: string; + description: string; +} -// const PrizesPage = ({ params }: { params: { user_id: string } }) => { -// const [selectedPrize, setSelectedPrize] = useState(null); -// const queryClient = useQueryClient(); -// const router = useRouter(); +const PrizesPage = ({ params }: { params: { user_id: string } }) => { + const [selectedPrize, setSelectedPrize] = useState(null); + const queryClient = useQueryClient(); + const router = useRouter(); -// // Fetching data using TanStack Query -// const { data, isLoading, error } = useQuery( -// [`gifts-${params.user_id}`, params.user_id], // Query key using user_id -// () => -// axios -// .get(`https://sms.turkmentv.gov.tm/api/gifts/${params.user_id}`) -// .then((response) => response.data), -// { -// // Handle error with onError callback to trigger the redirect -// onError: () => { -// router.push('/prizes/auth'); -// }, -// }, -// ); + // Fetching data using TanStack Query + const { data, isLoading, error } = useQuery( + [`gifts-${params.user_id}`, params.user_id], // Query key using user_id + () => + axios + .get(`https://sms.turkmentv.gov.tm/api/gifts/${params.user_id}`) + .then((response) => response.data), + { + // Handle error with onError callback to trigger the redirect + onError: () => { + router.push('/prizes/auth'); + }, + }, + ); -// if (isLoading) -// return ( -//
-// Loading... -//
-// ); + if (isLoading) + return ( +
+ Loading... +
+ ); -// // Log the error to the console, even if redirecting -// if (error) { -// console.error('Error loading prizes:', error.message); -// return null; // Return null since the redirect will occur -// } + // Log the error to the console, even if redirecting + if (error) { + console.error('Error loading prizes:', error.message); + return null; // Return null since the redirect will occur + } -// return ( -//
-//
-//
-//

-// {data.data.title} -//

-//

-// Поздравляю с победой в викторине! Вы стали победителем и получаете возможность выбрать -// подарок по своему выбору. Пожалуйста, ознакомьтесь с доступными вариантами подарков и -// сообщите нам ваше предпочтение. С нетерпением ждем вашего выбора, чтобы доставить вам -// заслуженный приз! -//

-//
-//

-// Есть вопросы? Обратись XYXYXY! -//

-//
-//
-// {data.data.gifts && -// data.data.gifts.map((prize, i) => ( -// -// ))} -//
-//
-// ); -// }; + // return ( + //
+ //
+ //
+ //

+ // {data.data.title} + //

+ //

+ // Поздравляю с победой в викторине! Вы стали победителем и получаете возможность выбрать + // подарок по своему выбору. Пожалуйста, ознакомьтесь с доступными вариантами подарков и + // сообщите нам ваше предпочтение. С нетерпением ждем вашего выбора, чтобы доставить вам + // заслуженный приз! + //

+ //
+ //

+ // Есть вопросы? Обратись XYXYXY! + //

+ //
+ //
+ // {data.data.gifts && + // data.data.gifts.map((prize, i) => ( + // + // ))} + //
+ //
+ // ); +}; -// export default PrizesPage; +export default PrizesPage; diff --git a/app/(prizes)/prizes/auth/page.tsx b/app/(prizes)/prizes/auth/page.tsx index 0a78f49..a6d2392 100644 --- a/app/(prizes)/prizes/auth/page.tsx +++ b/app/(prizes)/prizes/auth/page.tsx @@ -1,14 +1,14 @@ -// import SmsForm from '@/components/prizes/SmsForm'; -// import React from 'react'; +import SmsForm from '@/components/prizes/SmsForm'; +import React from 'react'; -// const page = () => { -// return ( -//
-//
-// -//
-//
-// ); -// }; +const page = () => { + // return ( + //
+ //
+ // + //
+ //
+ // ); +}; -// export default page; +export default page; diff --git a/components/MobileMenu.tsx b/components/MobileMenu.tsx index 87d3bbe..e67a281 100644 --- a/components/MobileMenu.tsx +++ b/components/MobileMenu.tsx @@ -167,7 +167,7 @@ const MobileMenu = () => { }}> TV market - { onClickCloseBurgerHandler(); }}> Sowgatlar - + */} diff --git a/components/Nav.tsx b/components/Nav.tsx index 2287086..95f2f08 100644 --- a/components/Nav.tsx +++ b/components/Nav.tsx @@ -140,13 +140,13 @@ const Nav = () => { onClick={() => setDropDownOpened(false)}> SMS ulgamy - setDropDownOpened(false)}> Sowgatlar - + */}