fix: path
This commit is contained in:
parent
67b747f0ff
commit
de93de2e6d
@ -6,13 +6,13 @@ const nextConfig: NextConfig = {
|
||||
return [
|
||||
{
|
||||
source: '/',
|
||||
destination: '/en/dashboards/crm',
|
||||
destination: '/en/dashboards/overview',
|
||||
permanent: true,
|
||||
locale: false
|
||||
},
|
||||
{
|
||||
source: '/:lang(en|fr|ar)',
|
||||
destination: '/:lang/dashboards/crm',
|
||||
destination: '/:lang/dashboards/overview',
|
||||
permanent: true,
|
||||
locale: false
|
||||
},
|
||||
|
||||
@ -91,8 +91,8 @@ const HorizontalMenu = ({ dictionary }: { dictionary: Awaited<ReturnType<typeof
|
||||
}}
|
||||
>
|
||||
<SubMenu label={dictionary['navigation'].dashboards} icon={<i className='tabler-smart-home' />}>
|
||||
<MenuItem href={`/${locale}/dashboards/crm`} icon={<i className='tabler-chart-pie-2' />}>
|
||||
{dictionary['navigation'].crm}
|
||||
<MenuItem href={`/${locale}/dashboards/overview`} icon={<i className='tabler-chart-pie-2' />}>
|
||||
{dictionary['navigation'].overview}
|
||||
</MenuItem>
|
||||
<MenuItem href={`/${locale}/dashboards/analytics`} icon={<i className='tabler-trending-up' />}>
|
||||
{dictionary['navigation'].analytics}
|
||||
|
||||
@ -30,6 +30,7 @@ import { useSettings } from '@core/hooks/useSettings'
|
||||
// Util Imports
|
||||
import { getLocalizedUrl } from '@/utils/i18n'
|
||||
import { useAuthMutation } from '../../../services/mutations/auth'
|
||||
import { useAuth } from '../../../contexts/authContext'
|
||||
|
||||
// Styled component for badge content
|
||||
const BadgeContentSpan = styled('span')({
|
||||
@ -42,6 +43,8 @@ const BadgeContentSpan = styled('span')({
|
||||
})
|
||||
|
||||
const UserDropdown = () => {
|
||||
const { currentUser } = useAuth()
|
||||
|
||||
// States
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
@ -85,6 +88,10 @@ const UserDropdown = () => {
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentUser) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Badge
|
||||
@ -124,9 +131,9 @@ const UserDropdown = () => {
|
||||
<Avatar alt={'john doe'} src={''} />
|
||||
<div className='flex items-start flex-col'>
|
||||
<Typography className='font-medium' color='text.primary'>
|
||||
{'john doe'}
|
||||
{currentUser?.name}
|
||||
</Typography>
|
||||
<Typography variant='caption'>{'email'}</Typography>
|
||||
<Typography variant='caption'>{currentUser?.email}</Typography>
|
||||
</div>
|
||||
</div>
|
||||
<Divider className='mlb-1' />
|
||||
|
||||
@ -30,8 +30,8 @@ const defaultSuggestions: DefaultSuggestionsType[] = [
|
||||
icon: 'tabler-trending-up'
|
||||
},
|
||||
{
|
||||
label: 'CRM',
|
||||
href: '/dashboards/crm',
|
||||
label: 'Overview',
|
||||
href: '/dashboards/overview',
|
||||
icon: 'tabler-chart-pie-2'
|
||||
},
|
||||
{
|
||||
|
||||
@ -29,8 +29,8 @@ const noResultData: NoResultData[] = [
|
||||
icon: 'tabler-user'
|
||||
},
|
||||
{
|
||||
label: 'CRM',
|
||||
href: '/dashboards/crm',
|
||||
label: 'Overview',
|
||||
href: '/dashboards/overview',
|
||||
icon: 'tabler-chart-donut-3'
|
||||
}
|
||||
]
|
||||
|
||||
@ -55,7 +55,7 @@ export type Config = {
|
||||
|
||||
const themeConfig: Config = {
|
||||
templateName: 'APSKEL',
|
||||
homePageUrl: '/dashboards/crm',
|
||||
homePageUrl: '/dashboards/overview',
|
||||
settingsCookieName: 'vuexy-mui-next-demo-1',
|
||||
mode: 'system', // 'system', 'light', 'dark'
|
||||
skin: 'default', // 'default', 'bordered'
|
||||
|
||||
@ -6,7 +6,7 @@ import Loading from '../components/layout/shared/Loading'
|
||||
type AuthContextType = {
|
||||
isAuthenticated: boolean
|
||||
token: string | null
|
||||
currentUser: string | null
|
||||
currentUser: any | null
|
||||
}
|
||||
|
||||
const AuthContext = createContext<AuthContextType>({
|
||||
@ -17,14 +17,14 @@ const AuthContext = createContext<AuthContextType>({
|
||||
|
||||
export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
const [token, setToken] = useState<string | null>(null)
|
||||
const [currentUser, setCurrentUser] = useState<string | null>(null)
|
||||
const [currentUser, setCurrentUser] = useState<any | null>(null)
|
||||
const [isInitialized, setIsInitialized] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const savedToken = localStorage.getItem('authToken')
|
||||
const savedUser = localStorage.getItem('user')
|
||||
if (savedToken) setToken(savedToken)
|
||||
if (savedUser) setCurrentUser(savedUser)
|
||||
if (savedUser) setCurrentUser(JSON.parse(savedUser))
|
||||
setIsInitialized(true)
|
||||
}, [])
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
{
|
||||
"navigation": {
|
||||
"dashboards": "لوحات القيادة",
|
||||
"crm": "إدارة علاقات العملاء",
|
||||
"analytics": "تحليلات",
|
||||
"eCommerce": "التجارة الإلكترونية",
|
||||
"stock": "المخزون",
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
{
|
||||
"navigation": {
|
||||
"dashboards": "Dashboards",
|
||||
"crm": "CRM",
|
||||
"analytics": "Analytics",
|
||||
"eCommerce": "eCommerce",
|
||||
"stock": "Stock",
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
{
|
||||
"navigation": {
|
||||
"dashboards": "Tableaux de bord",
|
||||
"crm": "GRC",
|
||||
"analytics": "Analytique",
|
||||
"eCommerce": "commerce électronique",
|
||||
"stock": "Stock",
|
||||
|
||||
@ -10,9 +10,9 @@ const horizontalMenuData = (dictionary: Awaited<ReturnType<typeof getDictionary>
|
||||
children: [
|
||||
// This is how you will normally render menu item
|
||||
{
|
||||
label: dictionary['navigation'].crm,
|
||||
label: dictionary['navigation'].overview,
|
||||
icon: 'tabler-chart-pie-2',
|
||||
href: '/dashboards/crm'
|
||||
href: '/dashboards/overview'
|
||||
},
|
||||
{
|
||||
label: dictionary['navigation'].analytics,
|
||||
|
||||
@ -14,9 +14,9 @@ const verticalMenuData = (dictionary: Awaited<ReturnType<typeof getDictionary>>)
|
||||
children: [
|
||||
// This is how you will normally render menu item
|
||||
{
|
||||
label: dictionary['navigation'].crm,
|
||||
label: dictionary['navigation'].overview,
|
||||
icon: 'tabler-circle',
|
||||
href: '/dashboards/crm'
|
||||
href: '/dashboards/overview'
|
||||
},
|
||||
{
|
||||
label: dictionary['navigation'].analytics,
|
||||
|
||||
@ -11,8 +11,8 @@ type SearchData = {
|
||||
const data: SearchData[] = [
|
||||
{
|
||||
id: '1',
|
||||
name: 'CRM Dashboard',
|
||||
url: '/dashboards/crm',
|
||||
name: 'Overview Dashboard',
|
||||
url: '/dashboards/overview',
|
||||
icon: 'tabler-chart-pie-2',
|
||||
section: 'Dashboards'
|
||||
},
|
||||
|
||||
@ -87,7 +87,7 @@ async function updateNextConfig() {
|
||||
|
||||
const redirect = `return [{
|
||||
source: '/',
|
||||
destination: '/dashboards/crm',
|
||||
destination: '/dashboards/overview',
|
||||
permanent: true
|
||||
}]`
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ import { useSettings } from '@core/hooks/useSettings'
|
||||
// Util Imports
|
||||
import { getLocalizedUrl } from '@/utils/i18n'
|
||||
import { useAuthMutation } from '../services/mutations/auth'
|
||||
import { CircularProgress } from '@mui/material'
|
||||
|
||||
// Styled Custom Components
|
||||
const LoginIllustration = styled('img')(({ theme }) => ({
|
||||
@ -134,7 +135,7 @@ const Login = ({ mode }: { mode: SystemMode }) => {
|
||||
const onSubmit: SubmitHandler<FormData> = async (data: FormData) => {
|
||||
login.mutate(data)
|
||||
|
||||
const redirectURL = searchParams.get('redirectTo') ?? '/'
|
||||
const redirectURL = searchParams.get('redirectTo') ?? '/dashboards/overview'
|
||||
|
||||
router.replace(getLocalizedUrl(redirectURL, locale as Locale))
|
||||
}
|
||||
@ -161,12 +162,6 @@ const Login = ({ mode }: { mode: SystemMode }) => {
|
||||
<Typography variant='h4'>{`Welcome to ${themeConfig.templateName}! 👋🏻`}</Typography>
|
||||
<Typography>Please sign-in to your account and start the adventure</Typography>
|
||||
</div>
|
||||
<Alert icon={false} className='bg-[var(--mui-palette-primary-lightOpacity)]'>
|
||||
<Typography variant='body2' color='primary.main'>
|
||||
Email: <span className='font-medium'>admin@vuexy.com</span> / Pass:{' '}
|
||||
<span className='font-medium'>admin</span>
|
||||
</Typography>
|
||||
</Alert>
|
||||
<form
|
||||
noValidate
|
||||
autoComplete='off'
|
||||
@ -244,7 +239,7 @@ const Login = ({ mode }: { mode: SystemMode }) => {
|
||||
</Typography>
|
||||
</div>
|
||||
<Button fullWidth variant='contained' type='submit' disabled={login.isPending}>
|
||||
{login.isPending ? 'Login...' : 'Login'}
|
||||
{login.isPending ? <CircularProgress size={16} /> : 'Login'}
|
||||
</Button>
|
||||
<div className='flex justify-center items-center flex-wrap gap-2'>
|
||||
<Typography>New on our platform?</Typography>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user