diff --git a/api/index.ts b/api/index.ts index c970bde..7fa80be 100644 --- a/api/index.ts +++ b/api/index.ts @@ -35,6 +35,6 @@ export async function authenticateLottery(phone: string, code: string) { } } -export const revalidateTagName = async (tag: string) => { - revalidateTag(tag); +export const revalidateTagName = async (tag: string, profile: string = "default") => { + revalidateTag(tag, profile); }; diff --git a/app/(main)/live/page.tsx b/app/(main)/live/page.tsx index 0289411..d609309 100644 --- a/app/(main)/live/page.tsx +++ b/app/(main)/live/page.tsx @@ -38,7 +38,7 @@ const page = () => { height={'100%'} width={'100%'} controls - url={channel.source} + src={channel.source} playing={true} key={v4()} /> diff --git a/app/(main)/treasury/[video_id]/page.tsx b/app/(main)/treasury/[video_id]/page.tsx index 2f02a85..e37d480 100644 --- a/app/(main)/treasury/[video_id]/page.tsx +++ b/app/(main)/treasury/[video_id]/page.tsx @@ -28,6 +28,7 @@ const VideoItem = async ({ params }: IParams) => { await queryClient.prefetchInfiniteQuery({ queryKey: ['video', 'all'], queryFn: () => Queries.getVideos(''), + initialPageParam: 1, }); await queryClient.prefetchInfiniteQuery({ queryKey: ['videos', 'infinite', ''], @@ -36,11 +37,12 @@ const VideoItem = async ({ params }: IParams) => { '?' + String( new URLSearchParams({ - page: pageParam, + page: String(pageParam), per_page: '8', }), ), ), + initialPageParam: 1, }); const dehydratedState = dehydrate(queryClient); diff --git a/app/(main)/treasury/page.tsx b/app/(main)/treasury/page.tsx index e162ae7..06de2a2 100644 --- a/app/(main)/treasury/page.tsx +++ b/app/(main)/treasury/page.tsx @@ -33,11 +33,12 @@ const Treasury = async () => { '?' + String( new URLSearchParams({ - page: pageParam, + page: String(pageParam), per_page: '8', }), ), ), + initialPageParam: 1, }); const dehydratedState = dehydrate(queryClient); diff --git a/app/(prizes)/prizes/[user_id]/page.tsx b/app/(prizes)/prizes/[user_id]/page.tsx index d04c6fc..95579ac 100644 --- a/app/(prizes)/prizes/[user_id]/page.tsx +++ b/app/(prizes)/prizes/[user_id]/page.tsx @@ -1,6 +1,6 @@ 'use client'; import PrizeCard from '@/components/prizes/PrizeCard'; -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import axios from 'axios'; import { useQuery, useQueryClient } from '@tanstack/react-query'; import { GiftsType } from '@/typings/gifts/gifts.type'; @@ -22,19 +22,20 @@ const PrizesPage = ({ params }: { params: { user_id: string } }) => { const mobile = useMediaQuery('(max-width: 768px)'); // Fetching data using TanStack Query - const { data, isLoading, error } = useQuery( - [`gifts-${params.user_id}`, params.user_id], // Query key using user_id - () => + const { data, isLoading, error } = useQuery({ + queryKey: [`gifts-${params.user_id}`, params.user_id], + queryFn: () => 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'); - }, - }, - ); + }); + + // Handle error with redirect + useEffect(() => { + if (error) { + router.push('/prizes/auth'); + } + }, [error, router]); if (isLoading) return ( @@ -49,6 +50,10 @@ const PrizesPage = ({ params }: { params: { user_id: string } }) => { return null; // Return null since the redirect will occur } + if (!data) { + return null; + } + return (
diff --git a/components/CustomSelect.tsx b/components/CustomSelect.tsx index 6944ea1..31a22d4 100644 --- a/components/CustomSelect.tsx +++ b/components/CustomSelect.tsx @@ -1,5 +1,5 @@ 'use client'; -import { useRef, useState } from 'react'; +import React, { useRef, useState } from 'react'; import { motion } from 'framer-motion'; import { v4 } from 'uuid'; import { BiSolidDownArrow } from 'react-icons/bi'; @@ -28,7 +28,7 @@ const CustomSelect = ({ const ref = useRef(null); const [input, setInput] = useState(); - useOnClickOutside(ref, () => setOpen(false)); + useOnClickOutside(ref as React.RefObject, () => setOpen(false)); return (
setOpen(!open)}> {label ? ( diff --git a/components/VideoList.tsx b/components/VideoList.tsx index 3334f26..c120f2d 100644 --- a/components/VideoList.tsx +++ b/components/VideoList.tsx @@ -25,15 +25,15 @@ const VideoList = ({ isSlides }: IProps) => { queryKey: ['videos', 'infinite', params ? params : ''], queryFn: ({ pageParam = 1 }) => params.search !== '' - ? Queries.getVideos('?' + String(new URLSearchParams({ ...params, page: pageParam }))) + ? Queries.getVideos('?' + String(new URLSearchParams({ ...params, page: String(pageParam) }))) : Queries.getVideos( - '?' + String(new URLSearchParams({ ...noSearchParams, page: pageParam })), + '?' + String(new URLSearchParams({ ...noSearchParams, page: String(pageParam) })), ), getNextPageParam: (prevData) => prevData.meta.last_page > prevData.meta.current_page ? prevData.meta.current_page + 1 : null, - keepPreviousData: true, + initialPageParam: 1, }); if (isLoading) return ; diff --git a/components/VideoPlayer.tsx b/components/VideoPlayer.tsx index 53266ed..159cd7d 100644 --- a/components/VideoPlayer.tsx +++ b/components/VideoPlayer.tsx @@ -45,7 +45,7 @@ const VideoPlayer = ({ maxHeight, maxWidth, video_id }: IProps) => { ); } - const mutation = useMutation(() => addViews()); + const mutation = useMutation({ mutationFn: () => addViews() }); const onPlayHandler = () => { if (!hasStartedPlaying) { diff --git a/components/dashboard/FilterTable.tsx b/components/dashboard/FilterTable.tsx index 36509b1..1b7fd0a 100644 --- a/components/dashboard/FilterTable.tsx +++ b/components/dashboard/FilterTable.tsx @@ -2,7 +2,7 @@ import clsx from 'clsx'; import { AnimatePresence, motion } from 'framer-motion'; -import { MouseEvent, useContext, useEffect, useRef, useState } from 'react'; +import React, { MouseEvent, useContext, useEffect, useRef, useState } from 'react'; import { Calendar } from '../ui/calendar'; import { format } from 'date-fns'; import { SmsContext } from '@/context/SmsContext'; @@ -51,7 +51,7 @@ const FilterTable = () => { setCalendar(false); }; - useOnClickOutside(calendarRef, handleClickOutside); + useOnClickOutside(calendarRef as React.RefObject, handleClickOutside); const checkSortActive = () => { if (activeSort === 'asc' || datee || searchFecth) { diff --git a/components/home/SmallSwiperNews.tsx b/components/home/SmallSwiperNews.tsx index dbaefc0..a56f8ff 100644 --- a/components/home/SmallSwiperNews.tsx +++ b/components/home/SmallSwiperNews.tsx @@ -19,8 +19,6 @@ const SmallSwiperNews = () => { if (isFetching) return ; if (error) return

{JSON.stringify(error)}

; - console.log(!!null); - return (
{ prevData.meta.last_page > prevData.meta.current_page ? prevData.meta.current_page + 1 : null, + initialPageParam: 1, }); const news = data!.pages.flatMap((data) => data.data)[0]; diff --git a/components/news/NewsGrid.tsx b/components/news/NewsGrid.tsx index c5a287c..cd8deed 100644 --- a/components/news/NewsGrid.tsx +++ b/components/news/NewsGrid.tsx @@ -23,7 +23,7 @@ const NewsGrid = ({ title, isExtendable, isSlides, perPage = 8 }: IProps) => { prevData.meta.last_page > prevData.meta.current_page ? prevData.meta.current_page + 1 : null, - keepPreviousData: true, + initialPageParam: 1, }); // const { data, isLoading, isFetchingNextPage, error, hasNextPage, fetchNextPage } = // useInfiniteQuery({ diff --git a/components/prizes/PrizeCard.tsx b/components/prizes/PrizeCard.tsx index 7039cd8..dd087cf 100644 --- a/components/prizes/PrizeCard.tsx +++ b/components/prizes/PrizeCard.tsx @@ -112,8 +112,8 @@ const PrizeCard = ({ diff --git a/components/prizes/SmsForm.tsx b/components/prizes/SmsForm.tsx index e6460cf..3082774 100644 --- a/components/prizes/SmsForm.tsx +++ b/components/prizes/SmsForm.tsx @@ -73,9 +73,9 @@ const SmsForm: React.FC = () => {
); diff --git a/components/treasury/ReactionsBlock.tsx b/components/treasury/ReactionsBlock.tsx index 4870b5f..82b2300 100644 --- a/components/treasury/ReactionsBlock.tsx +++ b/components/treasury/ReactionsBlock.tsx @@ -25,13 +25,12 @@ const ReactionsBlock = ({ video_id }: IProps) => { }); } - const mutationLikes = useMutation(() => addLikes()); - const mutationDisLikes = useMutation(() => addDisLikes()); + const mutationLikes = useMutation({ mutationFn: () => addLikes() }); + const mutationDisLikes = useMutation({ mutationFn: () => addDisLikes() }); const { data, error } = useQuery({ queryKey: ['video', video_id, mutationLikes, mutationDisLikes], queryFn: () => Queries.getVideo(video_id), - keepPreviousData: true, }); if (error) return

{JSON.stringify(error)}

; diff --git a/components/ui/calendar.tsx b/components/ui/calendar.tsx index d91726e..5abdd8e 100644 --- a/components/ui/calendar.tsx +++ b/components/ui/calendar.tsx @@ -47,8 +47,12 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }: C ...classNames, }} components={{ - IconLeft: ({ ...props }) => , - IconRight: ({ ...props }) => , + Chevron: ({ orientation }) => + orientation === 'left' ? ( + + ) : ( + + ), }} {...props} /> diff --git a/tailwind.config.ts b/tailwind.config.ts index 700b5e5..bde4585 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -1,7 +1,7 @@ import type { Config } from 'tailwindcss'; const config = { - darkMode: ['class'], + darkMode: 'class', content: [ './pages/**/*.{ts,tsx}', './components/**/*.{ts,tsx}', diff --git a/tsconfig.json b/tsconfig.json index e06a445..a1f1d20 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,11 @@ { "compilerOptions": { - "target": "es5", - "lib": ["dom", "dom.iterable", "esnext"], + "target": "ES2017", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "allowJs": true, "skipLibCheck": true, "strict": true, @@ -9,10 +13,10 @@ "noEmit": true, "esModuleInterop": true, "module": "esnext", - "moduleResolution": "node", + "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "preserve", + "jsx": "react-jsx", "incremental": true, "plugins": [ { @@ -20,9 +24,20 @@ } ], "paths": { - "@/*": ["./*"] + "@/*": [ + "./*" + ] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules"] + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts", + ".next/dev/types/**/*.ts" + ], + "exclude": [ + "node_modules", + "config" + ] }