Skip to content

Commit d9d79bd

Browse files
authored
Merge pull request #210 from DevKor-github/fix/#208/pick-detail
์ฑ„ํŒ…์œผ๋กœ ๋ฒ„ํŠผ, ์–ผ๋Ÿฟ ๋„์šฐ๊ธฐ
2 parents e59cd56 + ca7f5bc commit d9d79bd

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)