diff --git a/apps/admin/src/pages/HomePage/index.tsx b/apps/admin/src/pages/HomePage/index.tsx index 6c7e60d4..873cdeff 100644 --- a/apps/admin/src/pages/HomePage/index.tsx +++ b/apps/admin/src/pages/HomePage/index.tsx @@ -44,7 +44,7 @@ const HomePage = () => { const { data: userProfileData, isLoading: isUserProfileLoading } = useUserProfile(); const { data: showList = [], isLoading: isShowListLoading } = useShowList(); const { data: settlementBanners } = useSettlementBanners(); - const { data: popupData } = usePopup(); + const { data: popupData } = usePopup('HOME'); usePopupDialog(popupData); const { imgPath, nickname = '', userCode } = userProfileData ?? {}; diff --git a/apps/admin/src/pages/Landing/index.tsx b/apps/admin/src/pages/Landing/index.tsx index a50160a7..39bf3c64 100644 --- a/apps/admin/src/pages/Landing/index.tsx +++ b/apps/admin/src/pages/Landing/index.tsx @@ -2,8 +2,12 @@ import { Footer } from '@boolti/ui'; import { Header, KeyVisual, MoreInformation, OrganizerSection, UserSection } from './components'; import Styled from './LandingPage.styles'; +import { usePopup } from '@boolti/api'; +import usePopupDialog from '~/hooks/usePopupDialog'; const LandingPage = () => { + const { data: popupData } = usePopup('HOME'); + usePopupDialog(popupData); return ( <> diff --git a/packages/api/src/queries/usePopup.ts b/packages/api/src/queries/usePopup.ts index eb770ed9..4ba7d1fc 100644 --- a/packages/api/src/queries/usePopup.ts +++ b/packages/api/src/queries/usePopup.ts @@ -1,7 +1,8 @@ import { useQuery } from '@tanstack/react-query'; import { queryKeys } from '../queryKey'; +import { PopupViewType } from '../types'; -const usePopup = () => useQuery(queryKeys.popup.info); +const usePopup = (view: PopupViewType) => useQuery(queryKeys.popup.info(view)); export default usePopup; diff --git a/packages/api/src/queryKey.ts b/packages/api/src/queryKey.ts index c0e302d9..3f8ad376 100644 --- a/packages/api/src/queryKey.ts +++ b/packages/api/src/queryKey.ts @@ -25,6 +25,7 @@ import { TicketStatus, TicketType, Popup, + PopupViewType, } from './types'; import { AdminShowDetailResponse, @@ -134,8 +135,7 @@ export const adminShowQueryKeys = createQueryKeys('adminShow', { }), settlementStatement: (showId: number) => ({ queryKey: [showId], - queryFn: () => - instance.get(`sa-api/v1/shows/${showId}/settlement-statements/last/file`).blob(), + queryFn: () => instance.get(`sa-api/v1/shows/${showId}/settlement-statements/last/file`).blob(), }), ticketSalesInfo: (showId: number) => ({ queryKey: [showId], @@ -453,10 +453,10 @@ export const castTeamQueryKeys = createQueryKeys('castTeams', { }); export const popupQueryKeys = createQueryKeys('popup', { - info: { - queryKey: null, - queryFn: () => fetcher.get('web/papi/v1/popup'), - }, + info: (view: PopupViewType) => ({ + queryKey: [view], + queryFn: () => fetcher.get(`web/papi/v1/popup/${view}`), + }), }); export const queryKeys = mergeQueryKeys( diff --git a/packages/api/src/types/popup.ts b/packages/api/src/types/popup.ts index a0d11683..f0b90e92 100644 --- a/packages/api/src/types/popup.ts +++ b/packages/api/src/types/popup.ts @@ -2,9 +2,10 @@ export interface Popup { id: number; type: 'EVENT' | 'NOTICE'; eventUrl: string | null; - view: 'Home'; noticeTitle: string | null; description: string; startDate: string; endDate: string; } + +export type PopupViewType = 'HOME' | 'SHOW' | 'LANDING';