Skip to content

Commit

Permalink
โœจ Feat, ๐Ÿ’„ Design : ์˜ˆ์•ฝ ON_HOLD, PAYMENT_FAIL์ฒ˜๋ฆฌ, paymentsucces page ์ˆ˜์ •,โ€ฆ
Browse files Browse the repository at this point in the history
โ€ฆ ํ—ค๋” hr ์œ„์น˜ ์กฐ์ •

โœจ Feat, ๐Ÿ’„ Design : ์˜ˆ์•ฝ ON_HOLD, PAYMENT_FAIL์ฒ˜๋ฆฌ, paymentsucces page ์ˆ˜์ •, ํ—ค๋” hr ์œ„์น˜ ์กฐ์ •
  • Loading branch information
JOEIH authored Dec 9, 2024
2 parents 6333632 + 7d87abb commit 9bdb682
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/apis/reservation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const getLatestReservation = async (): Promise<Reservation> => {
};

// ์‚ฌ์—…์ž์˜ ์˜ˆ์•ฝ์ž ์กฐํšŒ
export const getAllReserver = async (): Promise<ReserverInfo> => {
export const getAllReserver = async (): Promise<ReserverInfo[]> => {
const response = await authInstance.get('/api/v1/reservations/all/workplace');
return response.data;
};
Expand Down
2 changes: 2 additions & 0 deletions src/components/LogoAndNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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') {
Expand Down
11 changes: 8 additions & 3 deletions src/pages/HostNotiPage/components/HostNotiList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,24 @@ const HostNotiList = () => {
<>
{sortedNotification && sortedNotification.length > 0 ? (
<div className='mt-4 flex w-[375px] flex-col justify-center gap-[13px] pb-24'>
{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 (
<HostReviewNotiCard
key={item.alrimId}
key={uniqueKey}
item={item}
/>
);
}

return (
<HostReservationNotiCard
key={item.alrimId}
key={uniqueKey}
item={item}
/>
);
Expand Down
17 changes: 8 additions & 9 deletions src/pages/ManagementReserverPage/components/ReserverList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@ const ReserverList = () => {
);
});

console.log(reserverList);

return (
<>
{reserverList.length > 0 ? (
<div className='mt-[6px] flex w-[375px] flex-col justify-center pb-24'>
{sortedReserverList.map((item) => {
if (item.reservationState !== 'ON_HOLD') {
return (
<ReserverCard
key={item.reservationId}
item={item}
/>
);
}
return null;
return (
<ReserverCard
key={item.reservationId}
item={item}
/>
);
})}
</div>
) : (
Expand Down
14 changes: 11 additions & 3 deletions src/pages/ManagementReserverPage/hooks/useGetReserver.ts
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion src/pages/ModifySpace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const ModifySpace = () => {
) : (
<HeaderOnlyTitle title='๊ณต๊ฐ„ ๋“ฑ๋ก ์ˆ˜์ •' />
)}
<hr className='fixed top-[93px] mx-[22.5px] h-0.5 w-custom border-0 bg-black' />
<hr className='fixed top-[70px] mx-[22.5px] h-0.5 w-custom border-0 bg-black' />
{selectedRoomId ? (
<RoomModify
room={spaceFormData.rooms.find(({ id }) => id === selectedRoomId)!}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/PaymentPage/PaymentSuccessPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<MainLayout>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RegisterSpace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const RegisterSpace = () => {
) : (
<HeaderOnlyTitle title='๊ณต๊ฐ„ ๋“ฑ๋ก' />
)}
<hr className='fixed top-[93px] mx-[22.5px] h-0.5 w-custom border-0 bg-black' />
<hr className='fixed top-[70px] mx-[22.5px] h-0.5 w-custom border-0 bg-black' />
{selectedRoomId ? (
<RoomForm
room={spaceFormData.rooms.find(({ id }) => id === selectedRoomId)!}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const ReservationDetailCard = ({ item }: { item: Reservation }) => {
๊ฒฐ์ œ ์ทจ์†Œ๋œ ์˜ˆ์•ฝ์ž…๋‹ˆ๋‹ค.
</span>
))}
{buttonText === 'review' && (
{buttonText === 'review' && state !== 'CANCELLED' && (
<ButtonInCard
name='๋ฆฌ๋ทฐ ์ž‘์„ฑ'
onClickFunction={handleReviewButton}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import { useQuery } from '@tanstack/react-query';
const useGetAllMyReservations = () => {
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 ?? [] };
Expand Down
12 changes: 11 additions & 1 deletion src/pages/UserMypage/hooks/useGetLatestReservation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/WriteReviewPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const WriteReviewPage = () => {
return (
<MainLayout>
<HeaderOnlyTitle title='๋ฆฌ๋ทฐ ์ž‘์„ฑ' />
<hr className='fixed top-[93px] mx-[22.5px] h-0.5 w-custom border-0 bg-black' />
<hr className='fixed top-[70px] mx-[22.5px] h-0.5 w-custom border-0 bg-black' />
<ReservationInfo item={reservationInfo} />
<hr className='mx-[22.5px] w-custom border-[0.5px] border-dashed' />
<WriteReview
Expand Down
5 changes: 4 additions & 1 deletion src/store/notificationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface NotificationState {
connect: () => void;
disconnect: () => void;
state: boolean;
activeNoti: boolean;
}

const EventSource = EventSourcePolyfill || NativeEventSource;
Expand All @@ -21,6 +22,7 @@ const useNotificationStore = create<NotificationState>((set) => ({
message: null,
state: true,
link: '/',
activeNoti: false,

connect: () => {
const token = getAuthToken() || '';
Expand All @@ -39,7 +41,6 @@ const useNotificationStore = create<NotificationState>((set) => ({

eventSource.onmessage = (event) => {
const newMessage: BusinessNotification = JSON.parse(event.data);
console.log(newMessage);

if (
newMessage.content === 'connected!' ||
Expand All @@ -60,6 +61,8 @@ const useNotificationStore = create<NotificationState>((set) => ({
? '์ƒˆ ๋ฆฌ๋ทฐ๊ฐ€ ๋“ฑ๋ก๋˜์—ˆ์Šต๋‹ˆ๋‹ค.'
: '์ƒˆ๋กœ์šด ์˜ˆ์•ฝ์ด ๋“ฑ๋ก๋˜์—ˆ์Šต๋‹ˆ๋‹ค.';

set(() => ({ activeNoti: true }));

set((state) => {
if (state.message === newText) {
return state;
Expand Down
3 changes: 2 additions & 1 deletion src/typings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export interface Business {

// ์‚ฌ์—…์ž ์•Œ๋ฆผ
export interface BusinessNotification {
alrimId: number;
reviewId?: number;
reservationId?: number;
content: string;
createdAt: string;
workplaceId: number;
Expand Down

0 comments on commit 9bdb682

Please sign in to comment.