Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
chat-trans
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenway
chat-trans
Commits
4b8c3bbe
Commit
4b8c3bbe
authored
Aug 14, 2023
by
chenway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add loading
parent
e39747be
Pipeline
#159012
passed with stages
in 1 minute 37 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
ChatTrans.js
src/Components/ChatTrans.js
+8
-4
No files found.
src/Components/ChatTrans.js
View file @
4b8c3bbe
import
{
useState
}
from
"react"
;
import
React
,
{
useEffect
,
useState
}
from
"react"
;
import
{
Button
,
Col
,
Container
,
Form
,
FormLabel
,
Row
,
ListGroup
,
Row
}
from
"react-bootstrap"
;
import
io
from
"socket.io-client"
;
import
"../App.css"
;
import
React
,
{
useEffect
}
from
"react"
;
const
url
=
'https://staging.strk-ai-support.ngrok.app/'
// const url = "http://localhost:8000";
...
...
@@ -33,6 +31,8 @@ function ChatTrans() {
const
[
supportMessages
,
setSupportMessages
]
=
useState
([]);
const
[
room
,
setRoom
]
=
useState
(
""
);
const
[
loading
,
setLoading
]
=
useState
(
true
);
const
generateToken
=
()
=>
{
return
Math
.
random
().
toString
(
36
).
substr
(
2
,
9
);
};
...
...
@@ -85,7 +85,9 @@ function ChatTrans() {
setUserMessages
(
messages
);
}
else
{
setSupportMessages
(
messages
);
setLoading
(
false
);
}
});
const
sendMessage
=
(
...
...
@@ -202,6 +204,7 @@ function ChatTrans() {
<
Row
>
<
Col
>
{
loading
?
<
FormLabel
>
Loading
...
<
/FormLabel> : null
}
<
ListGroup
variant
=
"flush"
>
{
userMessages
.
map
((
message
,
index
)
=>
(
<
ListGroup
.
Item
key
=
{
index
}
>
{
message
}
<
/ListGroup.Item
>
...
...
@@ -209,6 +212,7 @@ function ChatTrans() {
<
/ListGroup
>
<
/Col
>
<
Col
>
{
loading
?
<
FormLabel
>
Loading
...
<
/FormLabel> : null
}
<
ListGroup
variant
=
"flush"
>
{
supportMessages
.
map
((
message
,
index
)
=>
(
<
ListGroup
.
Item
key
=
{
index
}
>
{
message
}
<
/ListGroup.Item
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment