11import { addBlockList } from '@/apis/blockList' ;
22import MoreOptionsSelect from '@/components/MoreOptionsSelect' ;
33import HedaerLayout from '@/layouts/header/HedaerLayout' ;
4+ import { useModalStore } from '@/store/modalStore' ;
5+ import { useSheetStore } from '@/store/sheetStore' ;
46import backIcon from '@assets/icons/back-icon.svg' ;
57import { useNavigate , useParams } from 'react-router' ;
68
@@ -13,21 +15,48 @@ interface HeaderWithBackProps {
1315function HeaderWithBack ( { showMoreOptions = false , text } : HeaderWithBackProps ) {
1416 const navigate = useNavigate ( ) ;
1517 const param = useParams ( ) ;
18+
19+ const { openModal, closeModal } = useModalStore ( ) ;
20+ const { currentRecord } = useSheetStore ( ) ;
1621 // 임시함수
1722 const handleBlockUser = async ( ) => {
18- console . log ( param . userId ) ;
19- if ( param . userId ) {
20- const data = await addBlockList ( param . userId ) ;
21- console . log ( data ) ;
23+ if ( ! param . userId || ! currentRecord ) {
24+ console . log ( '차단 실패' ) ;
25+ return ;
2226 }
27+
28+ openModal ( {
29+ title : `${ currentRecord ?. nickName } 님을 차단할까요?` ,
30+ message : '차단된 사용자는 더이상 피드에 나타나지 않습니다' ,
31+ onConfirm : async ( ) => {
32+ if ( param . userId ) {
33+ try {
34+ const data = await addBlockList ( param . userId ) ;
35+ closeModal ( ) ;
36+ console . log ( data ) ;
37+ } catch ( error ) {
38+ console . log ( error ) ;
39+ }
40+ }
41+ } ,
42+ onCancel : ( ) => {
43+ closeModal ( ) ;
44+ } ,
45+ } ) ;
2346 } ;
2447
2548 return (
2649 < HedaerLayout >
2750 < div className = "flex items-center justify-between w-full" >
2851 { /* 뒤로가기 / 회원가입 */ }
2952 < div className = "gap-[10px] flex items-center" >
30- < button onClick = { ( ) => navigate ( - 1 ) } className = "px-2 py-3 cursor-pointer" >
53+ < button
54+ onClick = { ( e ) => {
55+ e . stopPropagation ( ) ;
56+ navigate ( - 1 ) ;
57+ } }
58+ className = "px-2 py-3 cursor-pointer"
59+ >
3160 < img src = { backIcon } alt = "뒤로가기 아이콘" />
3261 </ button >
3362 { text && < span className = "h4-b text-primary-normal" > { text } </ span > }
0 commit comments