Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/audience/src/entities/auth/api/auth.ts
Original file line number Diff line number Diff line change
@@ -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<AuthStatusResponse>(END_POINT.GET_AUTH_STATUS);
13 changes: 13 additions & 0 deletions apps/audience/src/entities/auth/model/query-options.ts
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 5 additions & 0 deletions apps/audience/src/entities/auth/types/response.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface AuthStatusResponse {
authenticated: boolean;
email: string;
userType: "AUDIENCE"| "ORGANIZER"| null;
}
9 changes: 8 additions & 1 deletion apps/audience/src/pages/notice-list/notice-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions apps/audience/src/shared/constants/end-point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 1 addition & 0 deletions apps/audience/src/shared/constants/query-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Loading