diff --git a/apps/audience/src/entities/auth/api/auth.ts b/apps/audience/src/entities/auth/api/auth.ts new file mode 100644 index 00000000..60e5d188 --- /dev/null +++ b/apps/audience/src/entities/auth/api/auth.ts @@ -0,0 +1,8 @@ +import { get } from '@amp/apis'; + +import type { AuthStatusResponse } from '@entities/auth/types/response'; + +import { END_POINT } from '@shared/constants/end-point'; + +export const getAuthStatus = () => + get(END_POINT.GET_AUTH_STATUS); diff --git a/apps/audience/src/entities/auth/model/query-options.ts b/apps/audience/src/entities/auth/model/query-options.ts new file mode 100644 index 00000000..04399b0e --- /dev/null +++ b/apps/audience/src/entities/auth/model/query-options.ts @@ -0,0 +1,13 @@ +import { queryOptions } from '@tanstack/react-query'; + +import { getAuthStatus } from '@entities/auth/api/auth'; + +import { USERS_QUERY_KEY } from '@shared/constants/query-key'; + +export const AUTH_QUERY_OPTIONS = { + AUTH_STATUS: () => + queryOptions({ + queryKey: USERS_QUERY_KEY.AUTH_STATUS(), + queryFn: () => getAuthStatus(), + }), +} as const; diff --git a/apps/audience/src/entities/auth/types/response.ts b/apps/audience/src/entities/auth/types/response.ts new file mode 100644 index 00000000..6ff2ee8c --- /dev/null +++ b/apps/audience/src/entities/auth/types/response.ts @@ -0,0 +1,5 @@ +export interface AuthStatusResponse { + authenticated: boolean; + email: string; + userType: "AUDIENCE"| "ORGANIZER"| null; +} diff --git a/apps/audience/src/pages/notice-list/notice-list.tsx b/apps/audience/src/pages/notice-list/notice-list.tsx index b351b524..dbebeb63 100644 --- a/apps/audience/src/pages/notice-list/notice-list.tsx +++ b/apps/audience/src/pages/notice-list/notice-list.tsx @@ -17,10 +17,11 @@ import { formatDday } from '@amp/shared/utils'; import { useToggleWishListMutation } from '@features/usecase/toggle-wishlist/use-toggle-wishlist-mutation'; +import { AUTH_QUERY_OPTIONS } from '@entities/auth/model/query-options'; import { NOTICES_QUERY_OPTIONS } from '@entities/notice/model/query-options'; import { CATEGORY_CODE_BY_LABEL } from '@shared/constants/category-label'; -import { NAV_PATH } from '@shared/constants/path'; +import { NAV_PATH, ROUTE_PATH } from '@shared/constants/path'; import { useNotificationsSubscribeMutation } from '@shared/hooks/use-festival-notification'; import { useLiveStatus } from '@shared/hooks/use-live-status'; import LiveStatusSheet from '@shared/ui/live-status-sheet/live-status-sheet'; @@ -42,6 +43,8 @@ const NoticeListPage = () => { NOTICES_QUERY_OPTIONS.BANNER(festivalId), ); + const { data: statusData } = useQuery(AUTH_QUERY_OPTIONS.AUTH_STATUS()); + const { data } = useQuery( NOTICES_QUERY_OPTIONS.LIST(festivalId, { page: 0, @@ -98,6 +101,10 @@ const NoticeListPage = () => { : null; const handleAlertClick = () => { + if (statusData?.authenticated === false) { + navigate(ROUTE_PATH.AUTH_REQUIRED); + return; + } overlay.open(({ isOpen, close, unmount }) => { const handleConfirmAlert = async () => { try { diff --git a/apps/audience/src/shared/constants/end-point.ts b/apps/audience/src/shared/constants/end-point.ts index 5f578a86..15c13686 100644 --- a/apps/audience/src/shared/constants/end-point.ts +++ b/apps/audience/src/shared/constants/end-point.ts @@ -37,4 +37,5 @@ export const END_POINT = { // Auth POST_LOGOUT: '/auth/logout', POST_ONBOARDING_COMPLETE: '/auth/onboarding/complete', + GET_AUTH_STATUS: '/auth/status', } as const; diff --git a/apps/audience/src/shared/constants/query-key.ts b/apps/audience/src/shared/constants/query-key.ts index 2cfd8fc4..b3a364b3 100644 --- a/apps/audience/src/shared/constants/query-key.ts +++ b/apps/audience/src/shared/constants/query-key.ts @@ -61,4 +61,5 @@ export const USERS_QUERY_KEY = { ], NICKNAME: () => [...USERS_QUERY_KEY.ALL, 'nickname'], + AUTH_STATUS: () => [...USERS_QUERY_KEY.ALL, 'auth-status'], } as const;