@@ -4,6 +4,8 @@ import { usePatchConfirmPick } from '@/features/pick/apis/usePatchConfirmPick';
44import type { PickStatus } from '@/libs/types/pick' ;
55import { useNavigate } from 'react-router' ;
66import { useToast } from '@/common/hooks/useToast' ;
7+ import { useState } from 'react' ;
8+ import CustomAlert from '@/common/components/CustomAlert' ;
79
810const 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} ;
0 commit comments