Skip to content

Commit eabb4f1

Browse files
committed
made executive and form page protected
1 parent 6815c4f commit eabb4f1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Diff for: src/Pages/Executive/CustomerSupportChat.jsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ const CustomerSupportChat = ({socket}) => {
2020
}, [selectedConversation])
2121

2222
useEffect(()=>{
23+
const loginStatus = localStorage.getItem("executiveID");
24+
if(loginStatus == null){
25+
navigate("/login")
26+
}
2327
socket.emit('load-chats-for-executive')
2428
socket.on("convos-for-executive", (chats)=>{
2529
console.log(chats)
@@ -28,8 +32,8 @@ const CustomerSupportChat = ({socket}) => {
2832
socket.on('new-customer-for-executive', (chat)=>{
2933
console.log("chats", chat)
3034
setOriginalListOfConvos(chats=>[chat, ...chats])
31-
3235
})
36+
3337
}, [])
3438

3539
socket.on("user-disconected", (socketID)=>{

Diff for: src/Pages/FormPage/CustomerSupportForm.jsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useState } from 'react';
22
import './CustomerSupportForm.css'; // Import the stylesheet
3-
import { useLocation } from 'react-router-dom';
3+
import { useLocation, useNavigate } from 'react-router-dom';
44

55
const CustomerSupportForm = ({socket}) => {
66
const {state} = useLocation();
@@ -15,9 +15,15 @@ const CustomerSupportForm = ({socket}) => {
1515
solutionSummary: '',
1616
noQueryReason: '',
1717
});
18+
19+
const navigate = useNavigate();
1820

1921
// To handle form response
2022
useEffect(()=>{
23+
const loginStatus = localStorage.getItem("executiveID");
24+
if(loginStatus == null){
25+
navigate("/login")
26+
}
2127
socket.on('form-response', (data)=>{
2228
if(data.success){
2329
alert('Form submitted successfully!');

0 commit comments

Comments
 (0)