Skip to content

Commit ca7f5bc

Browse files
committed
채팅으로 버튼, 얼럿 띄우기
1 parent e59cd56 commit ca7f5bc

3 files changed

Lines changed: 62 additions & 2 deletions

File tree

src/features/pick/components/DetailBottom/index.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { usePatchConfirmPick } from '@/features/pick/apis/usePatchConfirmPick';
44
import type { PickStatus } from '@/libs/types/pick';
55
import { useNavigate } from 'react-router';
66
import { useToast } from '@/common/hooks/useToast';
7+
import { useState } from 'react';
8+
import CustomAlert from '@/common/components/CustomAlert';
79

810
const PICK_EXPIRED_MESSAGE: Record<Exclude<PickStatus, 'PENDING' | 'CONFIRMED'>, string> = {
911
CANCELLED: '취소된 PICK이에요',
@@ -24,11 +26,23 @@ const DetailBottom = ({ id, itemId, isCreator, pickState, chatRoomId }: Props) =
2426
const { mutate: cancel } = usePatchCancelPick();
2527
const { mutate: confirm } = usePatchConfirmPick();
2628
const { openToast } = useToast();
29+
const [showAlert, setShowAlert] = useState(false);
30+
31+
const cancelType = pickState === 'PENDING' ? '거절' : '취소';
32+
33+
const onNo = () => {
34+
setShowAlert(false);
35+
};
36+
37+
const handleAlert = () => {
38+
setShowAlert(true);
39+
};
2740

2841
const cancelPick = () => {
2942
cancel(id, {
3043
onSuccess: () => {
3144
navigate(`/detail/${itemId}`, { replace: true });
45+
setShowAlert(false);
3246
openToast({ message: 'PICK이 취소되었어요' });
3347
},
3448
});
@@ -50,12 +64,12 @@ const DetailBottom = ({ id, itemId, isCreator, pickState, chatRoomId }: Props) =
5064
<div className={s.Container}>
5165
{canChangeState ? (
5266
isCreator ? (
53-
<button className={s.Button({ color: 'main' })} onClick={cancelPick}>
67+
<button className={s.Button({ color: 'gray' })} onClick={handleAlert}>
5468
PICK 취소하기
5569
</button>
5670
) : (
5771
<>
58-
<button className={s.Button({ color: 'gray' })} onClick={cancelPick}>
72+
<button className={s.Button({ color: 'gray' })} onClick={handleAlert}>
5973
{pickState === 'PENDING' ? '거절하기' : 'PICK 취소하기'}
6074
</button>
6175
{pickState === 'PENDING' && (
@@ -68,6 +82,15 @@ const DetailBottom = ({ id, itemId, isCreator, pickState, chatRoomId }: Props) =
6882
) : (
6983
<div className={s.Button({ color: 'gray' })}>{PICK_EXPIRED_MESSAGE[pickState]}</div>
7084
)}
85+
{showAlert && (
86+
<CustomAlert
87+
onYes={cancelPick}
88+
subTitle="정말 취소하실 건가요?"
89+
title={`PICK을 ${cancelType}하면\n더 이상 거래를 할 수 없어요.`}
90+
yesBtn="네, 취소할래요"
91+
onNo={onNo}
92+
/>
93+
)}
7194
</div>
7295
);
7396
};

src/pages/PickDetailPage/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import getItemInterfaceFromItemDetail from '@/common/utils/getItemInterfaceFromI
1111
import NotFoundPage from '@/pages/NotFoundPage';
1212
import CustomHeader from '@/common/components/CustomHeader';
1313
import DetailBottom from '@/features/pick/components/DetailBottom';
14+
import { cx } from '@styled-system/css';
1415

1516
interface InfoItemProps {
1617
title: string;
@@ -37,6 +38,10 @@ const PickDetailPage = () => {
3738
navigate(`/edit-pick/${id}`);
3839
};
3940

41+
const onChatBtnClick = () => {
42+
navigate(`/chatroom/${data?.chatRoomId}`);
43+
};
44+
4045
if (isError) return <NotFoundPage />;
4146

4247
if (data === undefined || itemData === undefined) return null;
@@ -111,6 +116,10 @@ const PickDetailPage = () => {
111116
)}
112117
</div>
113118
</div>
119+
<button className={s.ToChat} onClick={onChatBtnClick}>
120+
<div className={cx('mgc_chat_1_fill', s.ChatIcon)} />
121+
채팅으로
122+
</button>
114123
<DetailBottom
115124
id={id}
116125
itemId={data.itemId}

src/pages/PickDetailPage/style.css.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,34 @@ export const EditButton = css({
5353
},
5454
});
5555

56+
export const ChatIcon = css({
57+
fontSize: '1.25rem',
58+
aspectRatio: '1/1',
59+
});
60+
61+
export const ToChat = css({
62+
display: 'inline-flex',
63+
padding: '0.5rem 1rem',
64+
justifyContent: 'flex-end',
65+
alignItems: 'center',
66+
alignSelf: 'flex-end',
67+
gap: '0.625rem',
68+
margin: '0 1rem 1rem 0',
69+
70+
borderRadius: '6.25rem',
71+
background: 'main-26',
72+
w: 'fit-content',
73+
74+
color: 'main',
75+
textAlign: 'center',
76+
fontFamily: 'Pretendard',
77+
fontSize: '1rem',
78+
fontStyle: 'normal',
79+
fontWeight: 600,
80+
lineHeight: 'normal',
81+
letterSpacing: '-0.04rem',
82+
});
83+
5684
export const Block = css({
5785
display: 'flex',
5886
flexDir: 'column',

0 commit comments

Comments
 (0)