Merge remote-tracking branch 'origin/main' into efril
This commit is contained in:
commit
a13597725b
@ -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 <GuestOnlyRoute lang={params.lang}>{children}</GuestOnlyRoute>
|
||||
return <GuestOnlyRoute>{children}</GuestOnlyRoute>
|
||||
}
|
||||
|
||||
export default Layout
|
||||
|
||||
@ -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'
|
||||
|
||||
@ -91,7 +91,7 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => {
|
||||
<MenuItem href={`/${locale}/dashboards/daily-report`}>{dictionary['navigation'].dailyReport}</MenuItem>
|
||||
</SubMenu>
|
||||
<MenuSection label={dictionary['navigation'].appsPages}>
|
||||
<SubMenu label={dictionary['navigation'].eCommerce} icon={<i className='tabler-salad' />}>
|
||||
<SubMenu label={dictionary['navigation'].inventory} icon={<i className='tabler-salad' />}>
|
||||
{/* <MenuItem href={`/${locale}/apps/ecommerce/dashboard`}>{dictionary['navigation'].dashboard}</MenuItem> */}
|
||||
<SubMenu label={dictionary['navigation'].products}>
|
||||
<MenuItem href={`/${locale}/apps/ecommerce/products/list`}>{dictionary['navigation'].list}</MenuItem>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"navigation": {
|
||||
"dashboards": "لوحات القيادة",
|
||||
"analytics": "تحليلات",
|
||||
"eCommerce": "تجزئة الكترونية",
|
||||
"inventory": "تجزئة الكترونية",
|
||||
"stock": "المخزون",
|
||||
"academy": "أكاديمية",
|
||||
"logistics": "اللوجستية",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"navigation": {
|
||||
"dashboards": "Dashboards",
|
||||
"analytics": "Analytics",
|
||||
"eCommerce": "Inventory",
|
||||
"inventory": "Inventory",
|
||||
"stock": "Stock",
|
||||
"academy": "Academy",
|
||||
"logistics": "Logistics",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"navigation": {
|
||||
"dashboards": "Tableaux de bord",
|
||||
"analytics": "Analytique",
|
||||
"eCommerce": "Inventaire",
|
||||
"inventory": "Inventaire",
|
||||
"stock": "Stock",
|
||||
"academy": "Académie",
|
||||
"logistics": "Logistique",
|
||||
|
||||
@ -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 ? <Loading /> : children}</>
|
||||
}
|
||||
|
||||
export default GuestOnlyRoute
|
||||
|
||||
@ -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)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -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<FormData>({
|
||||
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
|
||||
</Typography>
|
||||
</div>
|
||||
<Divider className='gap-2'>or</Divider>
|
||||
<Button
|
||||
color='secondary'
|
||||
className='self-center text-textPrimary'
|
||||
startIcon={<img src='/images/logos/google.png' alt='Google' width={22} />}
|
||||
sx={{ '& .MuiButton-startIcon': { marginInlineEnd: 3 } }}
|
||||
onClick={() => console.log('google')}
|
||||
>
|
||||
Sign in with Google
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user