diff --git a/src/app/[lang]/(blank-layout-pages)/(guest-only)/layout.tsx b/src/app/[lang]/(blank-layout-pages)/(guest-only)/layout.tsx
index 66d3b63..614d2bb 100644
--- a/src/app/[lang]/(blank-layout-pages)/(guest-only)/layout.tsx
+++ b/src/app/[lang]/(blank-layout-pages)/(guest-only)/layout.tsx
@@ -1,16 +1,13 @@
// Type Imports
import type { ChildrenType } from '@core/types'
-import type { Locale } from '@configs/i18n'
// HOC Imports
import GuestOnlyRoute from '@/hocs/GuestOnlyRoute'
-const Layout = async (props: ChildrenType & { params: Promise<{ lang: Locale }> }) => {
- const params = await props.params
-
+const Layout = async (props: ChildrenType) => {
const { children } = props
- return {children}
+ return {children}
}
export default Layout
diff --git a/src/app/[lang]/(dashboard)/(private)/dashboards/products/page.tsx b/src/app/[lang]/(dashboard)/(private)/dashboards/products/page.tsx
index 3575aca..63cc683 100644
--- a/src/app/[lang]/(dashboard)/(private)/dashboards/products/page.tsx
+++ b/src/app/[lang]/(dashboard)/(private)/dashboards/products/page.tsx
@@ -4,8 +4,6 @@
import Grid from '@mui/material/Grid2'
// Component Imports
-import DistributedBarChartOrder from '@views/dashboards/crm/DistributedBarChartOrder'
-import EarningReportsWithTabs from '@views/dashboards/crm/EarningReportsWithTabs'
// Server Action Imports
import Loading from '../../../../../../components/layout/shared/Loading'
diff --git a/src/components/layout/vertical/VerticalMenu.tsx b/src/components/layout/vertical/VerticalMenu.tsx
index 4facf59..2241f37 100644
--- a/src/components/layout/vertical/VerticalMenu.tsx
+++ b/src/components/layout/vertical/VerticalMenu.tsx
@@ -91,7 +91,7 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => {
- }>
+ }>
{/* */}
diff --git a/src/data/dictionaries/ar.json b/src/data/dictionaries/ar.json
index ee811a2..b313afd 100644
--- a/src/data/dictionaries/ar.json
+++ b/src/data/dictionaries/ar.json
@@ -2,7 +2,7 @@
"navigation": {
"dashboards": "لوحات القيادة",
"analytics": "تحليلات",
- "eCommerce": "تجزئة الكترونية",
+ "inventory": "تجزئة الكترونية",
"stock": "المخزون",
"academy": "أكاديمية",
"logistics": "اللوجستية",
diff --git a/src/data/dictionaries/en.json b/src/data/dictionaries/en.json
index 9f638ae..4533801 100644
--- a/src/data/dictionaries/en.json
+++ b/src/data/dictionaries/en.json
@@ -2,7 +2,7 @@
"navigation": {
"dashboards": "Dashboards",
"analytics": "Analytics",
- "eCommerce": "Inventory",
+ "inventory": "Inventory",
"stock": "Stock",
"academy": "Academy",
"logistics": "Logistics",
diff --git a/src/data/dictionaries/fr.json b/src/data/dictionaries/fr.json
index b40fdb3..6ce77e7 100644
--- a/src/data/dictionaries/fr.json
+++ b/src/data/dictionaries/fr.json
@@ -2,7 +2,7 @@
"navigation": {
"dashboards": "Tableaux de bord",
"analytics": "Analytique",
- "eCommerce": "Inventaire",
+ "inventory": "Inventaire",
"stock": "Stock",
"academy": "Académie",
"logistics": "Logistique",
diff --git a/src/hocs/GuestOnlyRoute.tsx b/src/hocs/GuestOnlyRoute.tsx
index 6108fc3..ee35cbf 100644
--- a/src/hocs/GuestOnlyRoute.tsx
+++ b/src/hocs/GuestOnlyRoute.tsx
@@ -1,23 +1,34 @@
+'use client'
+
// Next Imports
// Type Imports
-import type { Locale } from '@configs/i18n'
import type { ChildrenType } from '@core/types'
+import { useRouter } from 'next/navigation'
+import { useEffect } from 'react'
+import { useAuth } from '../contexts/authContext'
+import Loading from '../components/layout/shared/Loading'
// Config Imports
// Util Imports
-const GuestOnlyRoute = async ({ children, lang }: ChildrenType & { lang: Locale }) => {
- // const session = await getServerSession()
+const GuestOnlyRoute = ({ children }: ChildrenType) => {
+ const router = useRouter()
- // if (session) {
- // redirect(getLocalizedUrl(themeConfig.homePageUrl, lang))
- // }
+ const { isAuthenticated, currentUser } = useAuth()
- console.log(lang)
+ useEffect(() => {
+ if (!isAuthenticated) return
- return <>{children}>
+ if (currentUser?.role === 'admin') {
+ router.push('/dashboards/overview')
+ } else {
+ router.push('/sa/organizations/list')
+ }
+ }, [isAuthenticated])
+
+ return <>{isAuthenticated ? : children}>
}
export default GuestOnlyRoute
diff --git a/src/services/api.ts b/src/services/api.ts
index cb931f1..25cad69 100644
--- a/src/services/api.ts
+++ b/src/services/api.ts
@@ -29,9 +29,9 @@ api.interceptors.response.use(
response => response,
error => {
const status = error.response?.status
+ const currentPath = window.location.pathname
- if (status === 401) {
- console.warn('Unauthorized. Redirecting to login...')
+ if (status === 401 && !currentPath.endsWith('/login')) {
window.location.href = '/login'
}
@@ -46,3 +46,4 @@ api.interceptors.response.use(
return Promise.reject(error)
}
)
+
diff --git a/src/views/Login.tsx b/src/views/Login.tsx
index 75bbe6e..ae7d45c 100644
--- a/src/views/Login.tsx
+++ b/src/views/Login.tsx
@@ -46,6 +46,7 @@ import { useSettings } from '@core/hooks/useSettings'
import { getLocalizedUrl } from '@/utils/i18n'
import { useAuthMutation } from '../services/mutations/auth'
import { CircularProgress } from '@mui/material'
+import { toast } from 'react-toastify'
// Styled Custom Components
const LoginIllustration = styled('img')(({ theme }) => ({
@@ -117,8 +118,8 @@ const Login = ({ mode }: { mode: SystemMode }) => {
} = useForm({
resolver: valibotResolver(schema),
defaultValues: {
- email: 'guapatlu@jambi.com',
- password: '12345678'
+ email: '',
+ password: ''
}
})
@@ -146,7 +147,7 @@ const Login = ({ mode }: { mode: SystemMode }) => {
}
},
onError: (error: any) => {
- setErrorState(error.response.data)
+ toast.error(error.response.data.message)
}
})
}
@@ -262,16 +263,6 @@ const Login = ({ mode }: { mode: SystemMode }) => {
Create an account
- or
- }
- sx={{ '& .MuiButton-startIcon': { marginInlineEnd: 3 } }}
- onClick={() => console.log('google')}
- >
- Sign in with Google
-