Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
Triz_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
sdy
2020-05-24 20:17:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
74c48e6ab12e581d97700f3a37bf75e4dfafe071
74c48e6a
1 parent
41809068
update onSubmit function
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
front/src/Routes/Chat/ChatContainer.js
front/src/Routes/Chat/ChatContainer.js
View file @
74c48e6
...
...
@@ -4,21 +4,37 @@ import ChatPresenter from "./ChatPresenter";
import
{
withRouter
}
from
"react-router-dom"
;
import
{
NEW_MESSAGE
,
SUBSCRIPTION_MSG
}
from
"./ChatQueries"
;
import
useInput
from
"../../Hooks/useInput"
;
import
{
toast
}
from
"react-toastify"
;
export
default
withRouter
(({
location
})
=>
{
const
[
createMsg
]
=
useMutation
(
NEW_MESSAGE
);
const
{
data
}
=
useSubscription
(
SUBSCRIPTION_MSG
);
const
message
=
useInput
(
""
);
let
messageObj
,
outcomingMsg
;
const
onSubmit
=
async
(
e
)
=>
{
e
.
preventDefault
();
if
(
message
.
value
!==
undefined
||
message
.
value
!==
""
)
{
try
{
messageObj
=
await
createMsg
({
variables
:
{
message
:
message
.
value
,
},
});
const
{
text
}
=
messageObj
;
outcomingMsg
=
text
;
}
catch
{
toast
.
error
(
"text must be not empty"
);
}
}
};
console
.
log
(
data
);
console
.
log
(
createMsg
);
return
(
<
ChatPresenter
location
=
{
location
}
message
=
{
message
}
onSubmit
=
{
onSubmit
}
/
>
<
ChatPresenter
location
=
{
location
}
message
=
{
message
}
onSubmit
=
{
onSubmit
}
outcomingMsg
=
{
outcomingMsg
}
/
>
);
});
...
...
Please
register
or
login
to post a comment