diff --git a/src/apis/reservation.ts b/src/apis/reservation.ts index 7d931cc7..53c0c71c 100644 --- a/src/apis/reservation.ts +++ b/src/apis/reservation.ts @@ -36,7 +36,7 @@ export const getLatestReservation = async (): Promise => { }; // 사업자의 예약자 조회 -export const getAllReserver = async (): Promise => { +export const getAllReserver = async (): Promise => { const response = await authInstance.get('/api/v1/reservations/all/workplace'); return response.data; }; diff --git a/src/components/LogoAndNotification.tsx b/src/components/LogoAndNotification.tsx index 2aa98580..88063504 100644 --- a/src/components/LogoAndNotification.tsx +++ b/src/components/LogoAndNotification.tsx @@ -2,6 +2,7 @@ import Logo from '@assets/images/roomit_logo.png'; import { RiNotification3Line } from 'react-icons/ri'; import { Link, useNavigate } from 'react-router-dom'; import { getRole } from '@utils/auth'; +// import useNotificationStore from '@store/notificationStore'; interface HeaderProps { isLogin: boolean; @@ -10,6 +11,7 @@ interface HeaderProps { const LogoAndNotification = ({ isLogin }: HeaderProps) => { const navigate = useNavigate(); const role = getRole(); + // const { activeNoti } = useNotificationStore(); const handleMoveToNotiPageClick = () => { if (role === 'ROLE_USER') { diff --git a/src/pages/HostNotiPage/components/HostNotiList.tsx b/src/pages/HostNotiPage/components/HostNotiList.tsx index daefde4b..c2a5e1f4 100644 --- a/src/pages/HostNotiPage/components/HostNotiList.tsx +++ b/src/pages/HostNotiPage/components/HostNotiList.tsx @@ -13,11 +13,16 @@ const HostNotiList = () => { <> {sortedNotification && sortedNotification.length > 0 ? (
- {sortedNotification.map((item) => { + {sortedNotification.map((item, index) => { + const uniqueKey = + item.notificationType === 'REVIEW_CREATED' + ? `review-${item.reviewId || index}` + : `reservation-${item.reservationId || index}`; + if (item.notificationType === 'REVIEW_CREATED') { return ( ); @@ -25,7 +30,7 @@ const HostNotiList = () => { return ( ); diff --git a/src/pages/ManagementReserverPage/components/ReserverList.tsx b/src/pages/ManagementReserverPage/components/ReserverList.tsx index 49c4baba..d425d97f 100644 --- a/src/pages/ManagementReserverPage/components/ReserverList.tsx +++ b/src/pages/ManagementReserverPage/components/ReserverList.tsx @@ -10,20 +10,19 @@ const ReserverList = () => { ); }); + console.log(reserverList); + return ( <> {reserverList.length > 0 ? (
{sortedReserverList.map((item) => { - if (item.reservationState !== 'ON_HOLD') { - return ( - - ); - } - return null; + return ( + + ); })}
) : ( diff --git a/src/pages/ManagementReserverPage/hooks/useGetReserver.ts b/src/pages/ManagementReserverPage/hooks/useGetReserver.ts index 9037eb46..29605856 100644 --- a/src/pages/ManagementReserverPage/hooks/useGetReserver.ts +++ b/src/pages/ManagementReserverPage/hooks/useGetReserver.ts @@ -1,13 +1,21 @@ import { getAllReserver } from '@apis/reservation'; import { useQuery } from '@tanstack/react-query'; -import { ReserverInfo } from '@typings/types'; const useGetReserver = () => { const { data } = useQuery({ queryKey: ['reserver'], - queryFn: () => getAllReserver(), + queryFn: async () => { + const reserverList = await getAllReserver(); + const filteredReserverList = reserverList.filter( + (item) => + item.reservationState !== 'ON_HOLD' && + item.reservationState !== 'PAYMENT_FAIL', + ); + + return filteredReserverList; + }, }); - return { reserverList: (data ?? []) as ReserverInfo[] }; + return { reserverList: data ?? [] }; }; export default useGetReserver; diff --git a/src/pages/ModifySpace/index.tsx b/src/pages/ModifySpace/index.tsx index 2a82c75f..7b78ef37 100644 --- a/src/pages/ModifySpace/index.tsx +++ b/src/pages/ModifySpace/index.tsx @@ -117,7 +117,7 @@ const ModifySpace = () => { ) : ( )} -
+
{selectedRoomId ? ( id === selectedRoomId)!} diff --git a/src/pages/PaymentPage/PaymentSuccessPage.tsx b/src/pages/PaymentPage/PaymentSuccessPage.tsx index f95d2287..6111ef51 100644 --- a/src/pages/PaymentPage/PaymentSuccessPage.tsx +++ b/src/pages/PaymentPage/PaymentSuccessPage.tsx @@ -8,7 +8,7 @@ const PaymentSuccessPage = () => { const { orderName, totalAmount } = responseData; - const formattedAmount = `${totalAmount.toLocaleString('ko-KR')}원`; + const formattedAmount = `${totalAmount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}원`; return ( diff --git a/src/pages/RegisterSpace/index.tsx b/src/pages/RegisterSpace/index.tsx index 9b262476..f4b14033 100644 --- a/src/pages/RegisterSpace/index.tsx +++ b/src/pages/RegisterSpace/index.tsx @@ -72,7 +72,7 @@ const RegisterSpace = () => { ) : ( )} -
+
{selectedRoomId ? ( id === selectedRoomId)!} diff --git a/src/pages/ReservationListPage/components/ReservationDetailCard.tsx b/src/pages/ReservationListPage/components/ReservationDetailCard.tsx index 73bdc15c..86d3faec 100644 --- a/src/pages/ReservationListPage/components/ReservationDetailCard.tsx +++ b/src/pages/ReservationListPage/components/ReservationDetailCard.tsx @@ -154,7 +154,7 @@ const ReservationDetailCard = ({ item }: { item: Reservation }) => { 결제 취소된 예약입니다. ))} - {buttonText === 'review' && ( + {buttonText === 'review' && state !== 'CANCELLED' && ( { const { data } = useQuery({ queryKey: ['myReservationList'], - queryFn: () => getAllReservation(), + queryFn: async () => { + const reservationList = await getAllReservation(); + const filteredReservation = reservationList.filter( + (item) => item.state !== 'ON_HOLD' && item.state !== 'PAYMENT_FAIL', + ); + + return filteredReservation; + }, }); return { reservationList: data ?? [] }; diff --git a/src/pages/UserMypage/hooks/useGetLatestReservation.ts b/src/pages/UserMypage/hooks/useGetLatestReservation.ts index 55150614..c89e5c39 100644 --- a/src/pages/UserMypage/hooks/useGetLatestReservation.ts +++ b/src/pages/UserMypage/hooks/useGetLatestReservation.ts @@ -4,7 +4,17 @@ import { useQuery } from '@tanstack/react-query'; const useGetLatestReservation = () => { const { data } = useQuery({ queryKey: ['latestReservation'], - queryFn: () => getLatestReservation(), + queryFn: async () => { + const latestReservation = await getLatestReservation(); + if ( + latestReservation.state === 'ON_HOLD' || + latestReservation.state === 'PAYMENT_FAIL' + ) { + return null; + } + + return latestReservation; + }, }); return { latestReservation: data }; }; diff --git a/src/pages/WriteReviewPage/index.tsx b/src/pages/WriteReviewPage/index.tsx index ac3da760..0156d8a1 100644 --- a/src/pages/WriteReviewPage/index.tsx +++ b/src/pages/WriteReviewPage/index.tsx @@ -23,7 +23,7 @@ const WriteReviewPage = () => { return ( -
+

void; disconnect: () => void; state: boolean; + activeNoti: boolean; } const EventSource = EventSourcePolyfill || NativeEventSource; @@ -21,6 +22,7 @@ const useNotificationStore = create((set) => ({ message: null, state: true, link: '/', + activeNoti: false, connect: () => { const token = getAuthToken() || ''; @@ -39,7 +41,6 @@ const useNotificationStore = create((set) => ({ eventSource.onmessage = (event) => { const newMessage: BusinessNotification = JSON.parse(event.data); - console.log(newMessage); if ( newMessage.content === 'connected!' || @@ -60,6 +61,8 @@ const useNotificationStore = create((set) => ({ ? '새 리뷰가 등록되었습니다.' : '새로운 예약이 등록되었습니다.'; + set(() => ({ activeNoti: true })); + set((state) => { if (state.message === newText) { return state; diff --git a/src/typings/types.ts b/src/typings/types.ts index 58d1e3c7..4f1563f2 100644 --- a/src/typings/types.ts +++ b/src/typings/types.ts @@ -53,7 +53,8 @@ export interface Business { // 사업자 알림 export interface BusinessNotification { - alrimId: number; + reviewId?: number; + reservationId?: number; content: string; createdAt: string; workplaceId: number;