Skip to content

Commit 46c7ea5

Browse files
committed
fix: scroll-to-top on route change, employee link on admin-signup, clean App.jsx
1 parent ddffa50 commit 46c7ea5

File tree

2 files changed

+61
-41
lines changed

2 files changed

+61
-41
lines changed

Frontend/src/App.jsx

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ function TitleUpdater() {
123123
return null;
124124
}
125125

126+
// Scrolls to top on every route change
127+
function ScrollToTop() {
128+
const { pathname } = useLocation();
129+
useEffect(() => {
130+
window.scrollTo({ top: 0, behavior: 'instant' });
131+
}, [pathname]);
132+
return null;
133+
}
134+
126135
function AppLayout() {
127136
const { user, profile } = useAuthStore();
128137

@@ -142,51 +151,55 @@ function AppLayout() {
142151
// ProtectedRoute handles the redirect to /login if user is not present
143152
// but we still need to handle role-based navigation here
144153
return (
145-
<Routes>
146-
<Route path="/knowledge-check" element={<DuplicateDetection />} />
147-
<Route path="/auto-resolve" element={<AutoResolveChat />} />
148-
<Route path="/resolved" element={<Resolved />} />
149-
150-
{/* --- User Portal --- */}
151-
<Route element={
152-
profile?.role === 'master_admin' ? <Navigate to="/master-admin/dashboard" replace /> :
153-
(profile?.role === 'admin' || profile?.role === 'super_admin') ? <Navigate to="/admin/dashboard" replace /> :
154-
profile?.status === 'pending_approval' ? <Navigate to="/user-lobby" replace /> :
155-
profile?.status === 'rejected' ? <Navigate to="/not-approved" replace /> :
156-
<UserLayout />
157-
}>
158-
<Route path="/dashboard" element={<Dashboard />} />
159-
<Route path="/create-ticket" element={<CreateTicket />} />
160-
<Route path="/my-tickets" element={<MyTickets />} />
161-
<Route path="/ticket/:ticket_id" element={<TicketDetail />} />
162-
<Route path="/ai-processing" element={<AIProcessing />} />
163-
<Route path="/ai-understanding" element={<AIUnderstanding />} />
164-
<Route path="/ticket-tracking" element={<TicketTracking />} />
165-
<Route path="/ticket-result" element={<TicketResult />} />
166-
<Route path="/profile" element={<Profile />} />
167-
<Route path="/help" element={<Help />} />
168-
<Route path="/notifications" element={<Notifications />} />
169-
</Route>
170-
171-
{/* --- Admin Portal (Protected) --- */}
172-
<Route element={<AdminProtectedRoute />}>
173-
<Route element={<AdminLayout />}>
174-
<Route path="/admin" element={<Navigate to="/admin/dashboard" replace />} />
175-
<Route path="/admin/dashboard" element={<AdminDashboard />} />
176-
<Route path="/admin/tickets" element={<AdminTickets />} />
177-
<Route path="/admin/ticket/:ticket_id" element={<AdminTicketDetail />} />
178-
<Route path="/admin/users" element={<AdminUsers />} />
179-
<Route path="/admin/analytics" element={<AdminAnalytics />} />
180-
<Route path="/admin/profile" element={<AdminProfile />} />
181-
<Route path="/admin/settings" element={<AdminSettings />} />
154+
<>
155+
<ScrollToTop />
156+
<Routes>
157+
<Route path="/knowledge-check" element={<DuplicateDetection />} />
158+
<Route path="/auto-resolve" element={<AutoResolveChat />} />
159+
<Route path="/resolved" element={<Resolved />} />
160+
161+
{/* --- User Portal --- */}
162+
<Route element={
163+
profile?.role === 'master_admin' ? <Navigate to="/master-admin/dashboard" replace /> :
164+
(profile?.role === 'admin' || profile?.role === 'super_admin') ? <Navigate to="/admin/dashboard" replace /> :
165+
profile?.status === 'pending_approval' ? <Navigate to="/user-lobby" replace /> :
166+
profile?.status === 'rejected' ? <Navigate to="/not-approved" replace /> :
167+
<UserLayout />
168+
}>
169+
<Route path="/dashboard" element={<Dashboard />} />
170+
<Route path="/create-ticket" element={<CreateTicket />} />
171+
<Route path="/my-tickets" element={<MyTickets />} />
172+
<Route path="/ticket/:ticket_id" element={<TicketDetail />} />
173+
<Route path="/ai-processing" element={<AIProcessing />} />
174+
<Route path="/ai-understanding" element={<AIUnderstanding />} />
175+
<Route path="/ticket-tracking" element={<TicketTracking />} />
176+
<Route path="/ticket-result" element={<TicketResult />} />
177+
<Route path="/profile" element={<Profile />} />
178+
<Route path="/help" element={<Help />} />
179+
<Route path="/notifications" element={<Notifications />} />
182180
</Route>
183-
</Route>
184181

185-
<Route path="*" element={<NotFound />} />
186-
</Routes>
182+
{/* --- Admin Portal (Protected) --- */}
183+
<Route element={<AdminProtectedRoute />}>
184+
<Route element={<AdminLayout />}>
185+
<Route path="/admin" element={<Navigate to="/admin/dashboard" replace />} />
186+
<Route path="/admin/dashboard" element={<AdminDashboard />} />
187+
<Route path="/admin/tickets" element={<AdminTickets />} />
188+
<Route path="/admin/ticket/:ticket_id" element={<AdminTicketDetail />} />
189+
<Route path="/admin/users" element={<AdminUsers />} />
190+
<Route path="/admin/analytics" element={<AdminAnalytics />} />
191+
<Route path="/admin/profile" element={<AdminProfile />} />
192+
<Route path="/admin/settings" element={<AdminSettings />} />
193+
</Route>
194+
</Route>
195+
196+
<Route path="*" element={<NotFound />} />
197+
</Routes>
198+
</>
187199
);
188200
}
189201

202+
190203
function App() {
191204
const { initialize } = useAuthStore();
192205

@@ -221,7 +234,7 @@ function App() {
221234
<Route path="/privacy" element={<PrivacyPolicy />} />
222235
<Route path="/security" element={<Security />} />
223236

224-
{/* ── Master Admin Portal (hidden, standalone) ── */}
237+
{/* Master Admin Portal */}
225238
<Route path="/master-admin-login" element={<MasterAdminLogin />} />
226239

227240
<Route element={<MasterAdminProtectedRoute />}>
@@ -244,3 +257,4 @@ function App() {
244257
}
245258

246259
export default App;
260+

Frontend/src/pages/AdminSignup.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,12 @@ function AdminSignup() {
637637
<p className="text-center text-xs text-gray-400 mt-12">
638638
Secure enterprise registration portal. Your data is protected by 256-bit encryption.
639639
</p>
640+
<p className="text-center text-xs text-gray-500 mt-4">
641+
Are you an employee?{' '}
642+
<Link to="/signup" className="text-emerald-700 font-bold hover:underline">
643+
Join your team here →
644+
</Link>
645+
</p>
640646
</div>
641647
</div>
642648
</div>

0 commit comments

Comments
 (0)