File tree Expand file tree Collapse file tree
src/pages/Chats/MatchingRoom Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { useNavigate } from 'react-router-dom' ;
2+
13import { useSocket } from '@context/SocketProvider' ;
24
35import { ResponseButton , ResponseContainer } from './styles' ;
46
57export interface ResponseMessageProps {
68 matchingId : number ;
9+ chatRoomId : number ;
710 requestStatus : 'accepted' | 'rejected' | 'pending' ;
811}
912
10- const ResponseMessage : React . FC < ResponseMessageProps > = ( { matchingId, requestStatus } ) => {
13+ const ResponseMessage : React . FC < ResponseMessageProps > = ( { matchingId, chatRoomId , requestStatus } ) => {
1114 const socket = useSocket ( 'matching' ) ;
1215 const isPending = requestStatus === 'pending' ;
16+ const nav = useNavigate ( ) ;
1317
1418 const handlebuttonClick = ( status : 'accept' | 'reject' ) => {
19+ if ( requestStatus !== 'pending' ) return ;
1520 if ( socket ) {
1621 socket . emit ( 'patchMatching' , { id : matchingId , requestStatus : status } ) ;
22+ if ( status === 'accept' ) {
23+ nav ( `/chats/${ chatRoomId } ` ) ;
24+ }
1725 }
1826 } ;
1927
Original file line number Diff line number Diff line change @@ -98,10 +98,15 @@ const MatchingRoom: React.FC = () => {
9898 < NoMatchingMessage />
9999 ) : (
100100 allMatchings . map ( ( matching : MatchingData ) => {
101+ console . log ( matching ) ;
101102 return (
102103 < div key = { matching . id } >
103104 < MatchingMessage { ...matching } />
104- < ResponseMessage matchingId = { matching . id } requestStatus = { matching . requestStatus } />
105+ < ResponseMessage
106+ matchingId = { matching . id }
107+ chatRoomId = { matching . chatRoomId }
108+ requestStatus = { matching . requestStatus }
109+ />
105110 </ div >
106111 ) ;
107112 } )
You can’t perform that action at this time.
0 commit comments