add: more things

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-07-06 15:21:36 +08:00
parent 41e98bb602
commit 244aa607f7
71 changed files with 2998 additions and 1014 deletions
+2 -7
View File
@@ -1,6 +1,6 @@
import { Navigate, Outlet } from 'react-router-dom'
import { useAuth } from '../contexts/AuthContext'
import { useEffect } from 'react'
import { getRoleHomePath } from '../utils/roleRedirect.util'
export default function PublicRoute() {
const { user, loading } = useAuth() // ← just loading and user
@@ -8,12 +8,7 @@ export default function PublicRoute() {
if (loading) return null // ← only block on initial cold load
if (user) {
switch (user.acc_type) {
case 'admin': return <Navigate to="/admin" replace />
case 'user': return <Navigate to={user.needs_intro ? '/intro' : '/dashboard'} replace />
case 'staff': return <Navigate to="/staff" replace />
default: return <Navigate to="/dashboard" replace />
}
return <Navigate to={getRoleHomePath(user)} replace />
}
return <Outlet />
+2 -6
View File
@@ -1,6 +1,7 @@
// RequirePasswordChange.jsx
import { Navigate, Outlet } from 'react-router-dom'
import { useAuth } from '../contexts/AuthContext'
import { getRoleHomePath } from '../utils/roleRedirect.util'
export default function RequirePasswordChange() {
const { user, loading } = useAuth()
@@ -12,12 +13,7 @@ export default function RequirePasswordChange() {
// User is logged in but doesn't need to change password → send to dashboard
if (!user.must_change_password) {
switch (user.acc_type) {
case 'admin': return <Navigate to="/admin" replace />
case 'staff': return <Navigate to="/staff" replace />
case 'client': return <Navigate to="/client" replace />
default: return <Navigate to="/" replace />
}
return <Navigate to={getRoleHomePath(user)} replace />
}
// User is logged in AND must change password → allow through