diff --git a/src/components/Avatar/index.tsx b/src/components/Avatar/index.tsx index b96f0124..dad6c567 100644 --- a/src/components/Avatar/index.tsx +++ b/src/components/Avatar/index.tsx @@ -1,6 +1,6 @@ import classNames from 'classnames/bind'; -import { SVGS } from '@/constants/index'; +import { SVGS } from '@/constants'; import styles from './Avatar.module.scss'; diff --git a/src/components/Pagination/index.tsx b/src/components/Pagination/index.tsx index e5dbfd34..f395d998 100644 --- a/src/components/Pagination/index.tsx +++ b/src/components/Pagination/index.tsx @@ -1,6 +1,6 @@ import classNames from 'classnames/bind'; -import { SVGS } from '@/constants/index'; +import { SVGS } from '@/constants'; import usePagination from '@/hooks/usePagination'; diff --git a/src/components/header/Alarm/index.tsx b/src/components/header/Alarm/index.tsx index 68e5f55a..cf16ea3d 100644 --- a/src/components/header/Alarm/index.tsx +++ b/src/components/header/Alarm/index.tsx @@ -1,6 +1,4 @@ -import Image from 'next/image'; - -import { MouseEventHandler, RefObject } from 'react'; +import { RefObject } from 'react'; import classNames from 'classnames/bind'; @@ -14,11 +12,13 @@ const { full, empty } = SVGS.alarm; type AlarmProps = { isAlarmExisted: boolean; isActivated: boolean; - onClick: MouseEventHandler; - alarmRef: RefObject; + onClick: () => void; + alarmRef?: RefObject; }; const Alarm = ({ isAlarmExisted, isActivated, onClick, alarmRef }: AlarmProps) => { + const { url, alt } = isAlarmExisted ? full : empty; + return ( ); diff --git a/src/components/header/AlarmCard/index.tsx b/src/components/header/AlarmCard/index.tsx index 43d62e10..a9cabec5 100644 --- a/src/components/header/AlarmCard/index.tsx +++ b/src/components/header/AlarmCard/index.tsx @@ -1,15 +1,7 @@ -import Image from 'next/image'; - -import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { AxiosError } from 'axios'; import classNames from 'classnames/bind'; -import { deleteMyNotification } from '@/apis/queryFunctions'; -import { QUERY_KEYS } from '@/apis/queryKeys'; -import { API_ERROR_MESSAGE, SVGS } from '@/constants'; -import { getElapsedTimeToKST, splitTitleByDelimiter } from '@/utils'; +import { SVGS } from '@/constants'; -import { ConfirmModal, ModalButton } from '@/components/commons/modals'; import useToggleButton from '@/hooks/useToggleButton'; import styles from './AlarmCard.module.scss'; @@ -21,66 +13,32 @@ type AlarmCardProps = { id: number; content: string; createdAt: string; + onClick: (id: number) => void; }; -const AlarmCard = ({ id, content, createdAt }: AlarmCardProps) => { +const AlarmCard = ({ id, content, createdAt, onClick }: AlarmCardProps) => { const { isVisible: hoverState, handleToggleClick: handleToggleState } = useToggleButton(); - const { isVisible: is404Open, handleToggleClick: handle404Click } = useToggleButton(); - - const { title, MaxCount } = splitTitleByDelimiter(content); - const refinedContent = title + (MaxCount.match(/\(.*$/)?.[0] ?? ''); - - const queryClient = useQueryClient(); - - const { mutate: deleteAlarmMutation } = useMutation({ - mutationFn: deleteMyNotification, - onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: [QUERY_KEYS.myNotifications.get], - }); - }, - onError: (error) => { - if ((error as AxiosError)?.response?.status === 404) { - handle404Click(); - } - }, - }); - - const handleDeleteNotification = (id: number) => { - deleteAlarmMutation(id); - }; return ( - <> -
-
-

{refinedContent}

- -
- {getElapsedTimeToKST(createdAt)} +
+
+

{content}

+
- 닫기} - > - + {createdAt} +
); }; diff --git a/src/components/header/AlarmList/index.tsx b/src/components/header/AlarmList/index.tsx index 8c62d8a7..630836e5 100644 --- a/src/components/header/AlarmList/index.tsx +++ b/src/components/header/AlarmList/index.tsx @@ -1,95 +1,62 @@ import { RefObject } from 'react'; -import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { AxiosError } from 'axios'; import classNames from 'classnames/bind'; -import { deleteMyNotifications } from '@/apis/queryFunctions'; -import { QUERY_KEYS } from '@/apis/queryKeys'; -import { API_ERROR_MESSAGE } from '@/constants'; - -import { ConfirmModal, ModalButton } from '@/components/commons/modals'; -import AlarmCard from '@/components/layout/header/AlarmCard'; -import EmptyAlarm from '@/components/layout/header/EmptyAlarm'; -import useToggleButton from '@/hooks/useToggleButton'; - -import { NotificationResponse } from '@/types'; +import AlarmCard from '@/components/header/AlarmCard'; +import EmptyAlarm from '@/components/header/EmptyAlarm'; import styles from './AlarmList.module.scss'; const cx = classNames.bind(styles); +type Notification = { + id: number; + content: string; + createdAt: string; +}; + type AlarmListProps = { - notifications: NotificationResponse[]; + notifications: Notification[]; totalCount: number; alarmListRef: RefObject; + handleDelete: (id: number) => void; + handleDeleteAll: () => void; + emptyAlarmText: string; }; -const AlarmList = ({ notifications, totalCount, alarmListRef }: AlarmListProps) => { - const { isVisible: is404Open, handleToggleClick: handle404Click } = useToggleButton(); - - const queryClient = useQueryClient(); - - const { mutate: deleteAlarmMutations } = useMutation({ - mutationFn: deleteMyNotifications, - onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: [QUERY_KEYS.myNotifications.get], - }); - }, - onError: (error) => { - if ((error as AxiosError)?.response?.status === 404) { - handle404Click(); - } - }, - }); - - const extractednotificationIds = (notifications: NotificationResponse[]): number[] => { - return notifications.map((notification) => notification.id); - }; - - const handleDeleteAllNotifications = () => { - if (notifications.length > 0) { - deleteAlarmMutations(extractednotificationIds(notifications)); - } - }; - +const AlarmList = ({ + notifications, + totalCount, + alarmListRef, + handleDelete, + handleDeleteAll, + emptyAlarmText, +}: AlarmListProps) => { return ( - <> -
-
-
- 알림 - {totalCount} -
- -
-
- {notifications[0] ? ( -
    - {notifications.map(({ id, content, createdAt }) => ( -
  • - -
  • - ))} -
- ) : ( - - )} +
+
+
+ 알림 + {totalCount}
+ +
+
+ {notifications[0] ? ( +
    + {notifications.map(({ id, content, createdAt }) => ( +
  • + +
  • + ))} +
+ ) : ( + + )}
- 닫기} - > - +
); }; diff --git a/src/components/header/DrawerMenu/index.tsx b/src/components/header/DrawerMenu/index.tsx index 9e811afe..973beee7 100644 --- a/src/components/header/DrawerMenu/index.tsx +++ b/src/components/header/DrawerMenu/index.tsx @@ -1,12 +1,6 @@ -import Image from 'next/image'; -import Link from 'next/link'; - -import { MouseEventHandler } from 'react'; - import classNames from 'classnames/bind'; -import { GAME_NAME_LIST_EN, SVGS } from '@/constants'; -import { formatGameToLink } from '@/utils'; +import { SVGS } from '@/constants'; import styles from './DrawerMenu.module.scss'; @@ -14,22 +8,23 @@ const cx = classNames.bind(styles); const { url, alt } = SVGS.close.active; type DrawerMenuProps = { - onClick: MouseEventHandler; + menuList: string[]; + onClick: () => void; }; -const DrawerMenu = ({ onClick }: DrawerMenuProps) => { +const DrawerMenu = ({ menuList, onClick }: DrawerMenuProps) => { return (