Skip to content

Commit 07b2f96

Browse files
committed
fix bug on logout menu bar
1 parent b30dd1a commit 07b2f96

8 files changed

Lines changed: 94 additions & 100 deletions

File tree

src/app/(pages)/api/auth/login/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import { NextRequest, NextResponse } from 'next/server';
55
export async function POST(req: NextRequest) {
66
const { email, password } = await req.json();
77

8+
89
const data : LoginResponse = {
9-
otpExpiresIn: 60,
10+
otpExpiresIn: 120,
1011
trackingId: 'abc123',
1112
otpRetryCount: 3
1213
}

src/app/(pages)/api/user/account/userprofile/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function GET(req: NextRequest) {
1212
address: 'Leeds',
1313
lastName: 'Fadaei',
1414
firstName: 'Saghar',
15-
role: UserRole.Admin,
15+
role: UserRole.User,
1616
lastLogin: new Date()
1717

1818
}

src/app/(pages)/api/user/add/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { UserRole } from '@/store/userProfile/interface';
33
import { NextRequest, NextResponse } from 'next/server';
44

55
export async function POST(req: NextRequest) {
6+
const { email } = await req.json();
67
const data : UserDtoResponse = {
7-
email: 'Connor@gmail.com',
8+
email: email,
89
isActive: false,
910
role: UserRole.User,
10-
userId: 2
11+
userId: 10
1112
}
1213

1314
return NextResponse.json({ message: 'Add user successfully', data }, { status: 200 });

src/app/(pages)/security/page.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
import Security from "@/app/components/Security";
1+
'use client'
2+
import React from 'react';
3+
import isMobileView from '@/app/utils/isMobileView';
4+
import { useShowInnerComponent } from '@/app/ShowInnerComponentContext';
5+
import MobileSecurityComponent from '@/app/components/Security/MobileChat';
6+
import WebSecurityComponent from '@/app/components/Security/WebChat';
27

38
export default function SecurityPage() {
4-
return (
5-
<Security />
6-
)
7-
}
9+
const { setShowInnerComponent } = useShowInnerComponent();
10+
11+
return (
12+
<>
13+
{isMobileView ? (
14+
<MobileSecurityComponent setShowInnerComponent={setShowInnerComponent} />
15+
) : (
16+
<WebSecurityComponent/>
17+
)}
18+
</>
19+
);
20+
}

src/app/components/SafeLLM/Menu.tsx

Lines changed: 38 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,20 @@ const Menu = ({ currentPath, setShowInnerComponent }: { currentPath: string, set
4343
dispatch(fetchChatHistoryListRequest());
4444
}, [dispatch]);
4545

46-
4746
function handleClick(path: string) {
48-
setShowInnerComponent(true);
47+
setTimeout(() => {
48+
setShowInnerComponent(true);
49+
}, 1000)
50+
4951
Router.push(path);
5052
}
5153

54+
5255
const logoutFuc = async () => {
5356
await logout();
5457
dispatch(resetLoginOtpState());
5558
dispatch(loginReset());
59+
setShowInnerComponent(true);
5660
localStorage.removeItem('isLogin');
5761
localStorage.removeItem('userProfile');
5862
Router.push('/');
@@ -83,19 +87,10 @@ const Menu = ({ currentPath, setShowInnerComponent }: { currentPath: string, set
8387
<div className={'w-full h-3 bg-secondary-02'} />
8488
<ul>
8589
<li className={'flex justify-between p-4 border-b-2 border-secondary-02 cursor-pointer'}>
86-
{currentPath === '/chat' ?
87-
<a className={'flex flex-1'} onClick={() => handleClick('/chat')}>
88-
<Icons name={'profile-faq'} />
89-
<p className={'ml-3'}>Chat</p>
90-
</a>
91-
:
92-
<Link href="/chat">
93-
<span className={'flex flex-1'}>
94-
<Icons name={'profile-faq'} />
95-
<p className={'ml-3'}>Chat</p>
96-
</span>
97-
</Link>
98-
}
90+
<a className={'flex flex-1'} onClick={() => handleClick('/chat')}>
91+
<Icons name={'profile-faq'} />
92+
<p className={'ml-3'}>chat</p>
93+
</a>
9994
<Icons name={'direction-left-gray'} />
10095
</li>
10196

@@ -113,91 +108,49 @@ const Menu = ({ currentPath, setShowInnerComponent }: { currentPath: string, set
113108
<ul className="pl-8 space-y-1 max-h-40 overflow-y-auto" onScroll={handleScroll}>
114109
{chatHistory.map((chat: any) => (
115110
<li key={chat.id}>
116-
117111
<a
118112
href={`/chat/history/${chat.id}`}
119113
className={`block px-4 py-2 hover:bg-primary-02 hover:text-primary ${currentPath.includes(chat.id) ? 'bg-primary-01 text-primary' : ''}`}
120114
>
121115
{chat.title} - {new Date(chat.date).toLocaleDateString()}
122116
</a>
123-
124117
</li>
125118
))}
126119
</ul>
127120
)}
128121

129-
{allowedRolesManagement.includes(role) && (
130-
<>
131-
<li className={'flex justify-between p-4 border-b-2 border-secondary-02 cursor-pointer'}>
132-
{currentPath === '/management' ?
133-
<a className={'flex flex-1'} onClick={() => handleClick('/management')}>
134-
<Icons name={'management'} />
135-
<p className={'ml-3'}>Management</p>
136-
</a>
137-
:
138-
<Link href="/management">
139-
<span className={'flex flex-1'}>
140-
<Icons name={'management'} />
141-
<p className={'ml-3'}>Management</p>
142-
</span>
143-
</Link>
144-
}
145-
146-
<Icons name={'direction-left-gray'} />
147-
</li>
148-
<li className={'flex justify-between p-4 border-b-2 border-secondary-02 cursor-pointer'}>
149-
150-
{currentPath === '/alerts' ?
151-
<a className={'flex flex-1'} onClick={() => handleClick('/alerts')}>
152-
<Icons name={'chart-live'} />
153-
<p className={'ml-3'}>Alerts</p>
154-
</a>
155-
:
156-
<Link href="/alerts">
157-
<span className={'flex flex-1'}>
158-
<Icons name={'chart-live'} />
159-
<p className={'ml-3'}>Alerts</p>
160-
</span>
161-
</Link>
162-
}
163-
<Icons name={'direction-left-gray'} />
164-
</li>
165-
</>
166-
)}
167-
<li className={'flex justify-between p-4 border-b-2 border-secondary-02 cursor-pointer'}>
168-
169-
170-
{currentPath === '/profile' ?
171-
<a className={'flex flex-1'} onClick={() => handleClick('/profile')}>
172-
<Icons name={'profile-account'} />
173-
<p className={'ml-3'}>Profle</p>
122+
{allowedRolesManagement.includes(role) ?
123+
<li className={'flex justify-between p-4 border-b-2 border-secondary-02 cursor-pointer'}>
124+
<a className={'flex flex-1'} onClick={() => handleClick('/management')}>
125+
<Icons name={'management'} />
126+
<p className={'ml-3'}>Management</p>
127+
</a>
128+
<Icons name={'direction-left-gray'} />
129+
</li>
130+
: ''
131+
}
132+
{allowedRolesManagement.includes(role) ?
133+
<li className={'flex justify-between p-4 border-b-2 border-secondary-02 cursor-pointer'}>
134+
<a className={'flex flex-1'} onClick={() => handleClick('/alerts')}>
135+
<Icons name={'chart-live'} />
136+
<p className={'ml-3'}>Alerts</p>
174137
</a>
175-
:
176-
<Link href="/profile">
177-
<span className={'flex flex-1'}>
178-
<Icons name={'profile-account'} />
179-
<p className={'ml-3'}>Profile</p>
180-
</span>
181-
</Link>
182-
}
138+
<Icons name={'direction-left-gray'} />
139+
</li>
140+
: ''
141+
}
142+
<li className={'flex justify-between p-4 border-b-2 border-secondary-02 cursor-pointer'}>
143+
<a className={'flex flex-1'} onClick={() => handleClick('/profile')}>
144+
<Icons name={'profile-account'} />
145+
<p className={'ml-3'}>Profle</p>
146+
</a>
183147
<Icons name={'direction-left-gray'} />
184148
</li>
185149
<li className={'flex justify-between p-4 border-b-2 border-secondary-02 cursor-pointer'}>
186-
187-
188-
{currentPath === '/security' ?
189-
<a className={'flex flex-1'} onClick={() => handleClick('/security')}>
190-
<Icons name={'profile-security'} />
191-
<p className={'ml-3'}>Security</p>
192-
</a>
193-
:
194-
<Link href="/security">
195-
<span className={'flex flex-1'}>
196-
<Icons name={'profile-security'} />
197-
<p className={'ml-3'}>Security</p>
198-
</span>
199-
</Link>
200-
}
150+
<a className={'flex flex-1'} onClick={() => handleClick('/security')}>
151+
<Icons name={'profile-security'} />
152+
<p className={'ml-3'}>Security</p>
153+
</a>
201154
<Icons name={'direction-left-gray'} />
202155
</li>
203156

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use client'
2+
import React, { useState } from "react";
3+
import Icons from "../../../../../public/Icons";
4+
import ReactMarkdown from "react-markdown";
5+
import EditPassword from "../EditPassword";
6+
7+
export default function MobileSecurityComponent({ setShowInnerComponent }:
8+
{ setShowInnerComponent: (a: boolean) => void }) {
9+
10+
const [isEditPasswordOpen, setIsEditPasswordOpen] = useState<boolean>(false);
11+
12+
return (
13+
<>
14+
<div className={"fixed pt-3 pb-3 w-full bg-white"}>
15+
<h3 className={"font-semibold text-xl text-center"}>Security</h3>
16+
17+
<div onClick={() => { setShowInnerComponent(false) }}
18+
className={'absolute top-4 left-2 cursor-pointer'}>
19+
<Icons name={'right-arrow-key'} />
20+
</div>
21+
</div>
22+
<div className={"pt-8 h-full flex flex-1 flex-col"}>
23+
<EditPassword setIsEditPasswordOpen={setIsEditPasswordOpen} isEditPasswordOpen={isEditPasswordOpen} />
24+
</div>
25+
</>
26+
);
27+
}

src/app/components/Security/index.tsx renamed to src/app/components/Security/WebChat/index.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
'use client'
2-
import Icons from "../../../../public/Icons";
2+
import Icons from "../../../../../public/Icons";
33
import {useRouter} from "next/navigation";
44
import isMobileView from "@/app/utils/isMobileView";
55
import {useState} from "react";
66
import Sidebar from "@/app/components/Sidebar";
77
import defaultSidebarStatus from "@/app/utils/defaultSidebarStatus";
88
import EditPassword from "@/app/components/Security/EditPassword";
99

10-
export default function Security() {
10+
export default function WebSecurityComponent() {
1111

1212
const [isSidebarOpen, setIsSidebarOpen] = useState<boolean>(defaultSidebarStatus);
1313
const [isEditPasswordOpen, setIsEditPasswordOpen] = useState<boolean>(false);
1414
const router = useRouter();
15-
16-
15+
1716
return (
1817
<Sidebar isSidebarOpen={isSidebarOpen} setIsSidebarOpen={setIsSidebarOpen}
1918
children={<>
@@ -37,4 +36,4 @@ export default function Security() {
3736

3837
</>}/>
3938
)
40-
}
39+
}

src/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function RootLayout({
5757
<ShowInnerComponentProvider>
5858
<Suspense fallback={<Loading />}>
5959
<ClientWrapper>{children}</ClientWrapper>
60-
</Suspense>إ
60+
</Suspense>
6161
</ShowInnerComponentProvider>
6262
</ReCaptchaProvider>
6363
</ReduxProvider>

0 commit comments

Comments
 (0)