sdy

update outcomingMsg data type

...@@ -14,7 +14,7 @@ export default withRouter(({ location }) => { ...@@ -14,7 +14,7 @@ export default withRouter(({ location }) => {
14 const { pathname } = location; 14 const { pathname } = location;
15 const roomName = pathname.slice(1, pathname.length); 15 const roomName = pathname.slice(1, pathname.length);
16 16
17 - let messageObj, outcomingMsg, roomId; 17 + let messageObj, outcomingMsg, outcomingTime, roomNum;
18 18
19 if (roomName !== undefined) { 19 if (roomName !== undefined) {
20 const { data } = useQuery(GET_ROOM_BY_NAME, { variables: { roomName } }); 20 const { data } = useQuery(GET_ROOM_BY_NAME, { variables: { roomName } });
...@@ -23,7 +23,7 @@ export default withRouter(({ location }) => { ...@@ -23,7 +23,7 @@ export default withRouter(({ location }) => {
23 getRoomByName: { id: roomId }, 23 getRoomByName: { id: roomId },
24 }, 24 },
25 } = data; 25 } = data;
26 - console.log(roomId); 26 + roomNum = Number(roomId);
27 } 27 }
28 28
29 const [createMsg] = useMutation(WHOLE_MESSAGE); 29 const [createMsg] = useMutation(WHOLE_MESSAGE);
...@@ -38,12 +38,12 @@ export default withRouter(({ location }) => { ...@@ -38,12 +38,12 @@ export default withRouter(({ location }) => {
38 messageObj = await createMsg({ 38 messageObj = await createMsg({
39 variables: { 39 variables: {
40 message: message.value, 40 message: message.value,
41 - roomId, 41 + roomId: roomNum,
42 }, 42 },
43 }); 43 });
44 - const { text } = messageObj; 44 + const { text, createdAt } = messageObj;
45 outcomingMsg = text; 45 outcomingMsg = text;
46 - console.log(messageObj); 46 + outcomingTime = createdAt;
47 } catch { 47 } catch {
48 toast.error("text must be not empty"); 48 toast.error("text must be not empty");
49 } 49 }
...@@ -55,6 +55,7 @@ export default withRouter(({ location }) => { ...@@ -55,6 +55,7 @@ export default withRouter(({ location }) => {
55 message={message} 55 message={message}
56 onSubmit={onSubmit} 56 onSubmit={onSubmit}
57 outcomingMsg={outcomingMsg} 57 outcomingMsg={outcomingMsg}
58 + outcomingTime={outcomingTime}
58 /> 59 />
59 ); 60 );
60 }); 61 });
......