Skip to content

Commit d3b7cc5

Browse files
committed
Bugs fixed.
1 parent 69bb4f4 commit d3b7cc5

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

app/src/App.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210

211211
.Signup-now, .Login-now {
212212
color: #7E35C5;
213+
cursor: pointer;
213214
}
214215

215216
.checkbox-group {

app/src/components/Dashboard.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default function Dashboard({ userData }) {
5050
const data = response.data;
5151
setChatId(data.id);
5252
setChatVote(data.vote);
53+
fetchChatHistory(chatId);
5354

5455
} catch (error) {
5556
alert(`The Chat with ${chatId} is not belong to your chatbot!`)
@@ -92,7 +93,6 @@ export default function Dashboard({ userData }) {
9293
const id = event.target.value;
9394
if (id !== "") {
9495
fetchChatData(id);
95-
fetchChatHistory(id);
9696
} else {
9797
setchatHistory("");
9898
setChatId("");
@@ -103,7 +103,6 @@ export default function Dashboard({ userData }) {
103103
const onChatClick = useCallback((id) => {
104104
if (id !== "") {
105105
fetchChatData(id);
106-
fetchChatHistory(id);
107106
} else {
108107
setchatHistory("");
109108
setChatId("");

app/src/components/Panel.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,31 @@ export default function Panel({ email }) {
2020
});
2121
}, [email]);
2222

23+
// Added a conditional rendering to handle cases when userData is null
2324
if (loading) {
2425
return <p>Loading...</p>; // Render a loading indicator while fetching data
2526
}
2627

28+
if (!userData || (userData && userData.botId !== -1)) {
29+
return (
30+
<div className='Panel-body'>
31+
<Dashboard userData={userData} />
32+
</div>
33+
);
34+
}
35+
2736
return (
2837
<div className='Panel-body'>
29-
{userData && userData.botId !== -1 ? (
30-
<Dashboard userData={userData} />
31-
) : (
32-
<div>
33-
<center>
34-
<div className='new-user-alert'>
35-
<p>
36-
You don't have a Chatbot yet! To access your control panel, you first need to create a Chatbot.
37-
</p>
38-
</div>
39-
</center>
40-
<Create userData={userData.id} />
41-
</div>
42-
)}
38+
<div>
39+
<center>
40+
<div className='new-user-alert'>
41+
<p>
42+
You don't have a Chatbot yet! To access your control panel, you first need to create a Chatbot.
43+
</p>
44+
</div>
45+
</center>
46+
<Create userId={userData.id} />
47+
</div>
4348
</div>
4449
);
4550
}

0 commit comments

Comments
 (0)