diff --git a/src/app/community/page.tsx b/src/app/community/page.tsx index 08cc8fcd..166e1094 100644 --- a/src/app/community/page.tsx +++ b/src/app/community/page.tsx @@ -3,7 +3,7 @@ import React from 'react' import Footer from '@/components/Footer/Footer' import UniversityCard from '@/components/universityCommunity/universityCommunityCart' import { useGetUserSubscribedCommunityGroups } from '@/services/university-community' -import Loading from '../loading' +import Loading from '@/components/atoms/Loading' interface CommunityType { _id: string diff --git a/src/app/loading.tsx b/src/components/atoms/Loading/index.tsx similarity index 100% rename from src/app/loading.tsx rename to src/components/atoms/Loading/index.tsx diff --git a/src/hooks/useCookie.ts b/src/hooks/useCookie.ts index 89bbe0e7..888ed700 100644 --- a/src/hooks/useCookie.ts +++ b/src/hooks/useCookie.ts @@ -1,5 +1,5 @@ 'use client' -import { useState, useEffect } from 'react' +import { useState, useEffect, useCallback } from 'react' const useCookie = (cookieName: string): [string, (value: string, expirationDate: string) => void, () => void] => { const [cookieValue, setCookieValue] = useState('') @@ -10,15 +10,18 @@ const useCookie = (cookieName: string): [string, (value: string, expirationDate: setCookieValue(cookie ? cookie.split('=')[1] : '') }, [cookieName]) - const setCookie = (value: string, expirationDate: string): void => { - document.cookie = `${cookieName}=${value}; expires=${new Date(expirationDate).toUTCString()}; path=/` - setCookieValue(value) - } + const setCookie = useCallback( + (value: string, expirationDate: string): void => { + document.cookie = `${cookieName}=${value}; expires=${new Date(expirationDate).toUTCString()}; path=/` + setCookieValue(value) + }, + [cookieName] + ) - const deleteCookie = (): void => { + const deleteCookie = useCallback((): void => { document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/` setCookieValue('') - } + }, [cookieName]) return [cookieValue, setCookie, deleteCookie] } diff --git a/src/services/community-timeline.ts b/src/services/community-timeline.ts index 6b0a8692..bde1dfe7 100644 --- a/src/services/community-timeline.ts +++ b/src/services/community-timeline.ts @@ -155,6 +155,7 @@ export function useGetTimelinePosts() { const state = useQuery({ queryKey: ['timelinePosts'], queryFn: () => getAllTimelinePosts(cookieValue), + enabled: !!cookieValue, }) let errorMessage = null