@@ -3,21 +3,41 @@ import { Textarea, ReportButton, ReportTextLayout } from "./style";
33import { StyledText } from "../../../../components/Text/StyledText" ;
44import theme from "../../../../styles/theme" ;
55import { ReportTextProps } from '../../dto' ;
6+ import request from "../../../../apis/core" ;
7+ import { useParams } from "react-router-dom" ;
68
7- const ReportText : React . FC < ReportTextProps > = ( { onCloseBottomSheet, setIsInputVisible } ) => {
9+ const ReportText : React . FC < ReportTextProps > = ( { onCloseBottomSheet, setIsInputVisible, handleOpenModal } ) => {
810 const [ inputValue , setInputValue ] = useState ( '' ) ;
11+ const myid = localStorage . getItem ( 'id' ) ;
12+ const { userId } = useParams < { userId : string } > ( ) ;
913
14+ const userDetail = JSON . parse ( localStorage . getItem ( `userDetails_${ userId } ` ) || '{}' ) ;
1015 const handleInputChange = ( event : React . ChangeEvent < HTMLTextAreaElement > ) => {
1116 setInputValue ( event . target . value ) ;
1217 } ;
1318
1419 const handleReportSubmit = ( ) => {
1520 console . log ( "Reported with input:" , inputValue ) ;
21+ Report ( inputValue ) ;
1622 setInputValue ( "" ) ;
1723 onCloseBottomSheet ( ) ; // 바텀 시트 닫기
1824 setIsInputVisible ( false ) ; // 입력창 숨기기
1925 } ;
2026
27+ const Report = async ( inputValue : string ) => {
28+ try {
29+ await request . patch ( `/user-report` , {
30+ fromUserId : Number . parseInt ( myid as string ) ,
31+ toUserId : Number . parseInt ( userId as string ) ,
32+ reason : inputValue
33+ } ) ;
34+ handleOpenModal ( `${ userDetail . nickname } 님을 \n'${ inputValue } ' 사유로 신고했어요.` ) ;
35+ } catch ( error ) {
36+ console . error ( 'Failed to fetch user details' , error ) ;
37+ }
38+ } ;
39+
40+
2141 return (
2242 < ReportTextLayout >
2343 < Textarea
0 commit comments