add auth and base functions and fixed bug
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
|
||||
const Layout = ({children}) => {
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default Layout
|
||||
@@ -1,6 +1,28 @@
|
||||
'use client'
|
||||
import { Button } from "@mui/material"
|
||||
import axios from "axios"
|
||||
|
||||
const Page = () => {
|
||||
const handler = () => {
|
||||
try {
|
||||
axios.get('https://rms.witel.ir/test_login?username=witel', { withCredentials: true })
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
const handler2 = () => {
|
||||
try {
|
||||
const res = axios.get('https://rms.witel.ir/webapi/user/get-permission', { withCredentials: true })
|
||||
console.log(res);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<div>dashboard</div>
|
||||
<>
|
||||
<Button onClick={handler}>login</Button>
|
||||
<Button onClick={handler2}>check</Button>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
import {Box, Stack} from "@mui/material";
|
||||
import { Box, Stack } from "@mui/material";
|
||||
import HeaderWithLogo from "@/components/layouts/dashboard/headerWithLogo";
|
||||
import HeaderWithSidebar from "@/components/layouts/dashboard/headerWithSidebar";
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
|
||||
const Template = ({children}) => {
|
||||
return (<Stack>
|
||||
<HeaderWithLogo/>
|
||||
<Box>
|
||||
<HeaderWithSidebar>
|
||||
{children}
|
||||
</HeaderWithSidebar>
|
||||
</Box>
|
||||
</Stack>)
|
||||
const Template = ({ children }) => {
|
||||
return (
|
||||
<Stack>
|
||||
<HeaderWithLogo />
|
||||
<Box>
|
||||
<HeaderWithSidebar>
|
||||
{children}
|
||||
</HeaderWithSidebar>
|
||||
</Box>
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
|
||||
export default Template
|
||||
14
src/app/(withAuth)/layout.js
Normal file
14
src/app/(withAuth)/layout.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import WithAuthMiddleware from "@/core/middlewares/withAuth"
|
||||
import { AuthProvider } from "@/lib/contexts/auth"
|
||||
|
||||
const Layout = ({ children }) => {
|
||||
return (
|
||||
<AuthProvider>
|
||||
<WithAuthMiddleware>
|
||||
{children}
|
||||
</WithAuthMiddleware>
|
||||
</AuthProvider>
|
||||
)
|
||||
}
|
||||
|
||||
export default Layout
|
||||
@@ -1,17 +1,17 @@
|
||||
import {TableSettingProvider} from "@/lib/contexts/tableSetting";
|
||||
import { TableSettingProvider } from "@/lib/contexts/tableSetting";
|
||||
|
||||
export const metadata = {
|
||||
title: 'سامانه جامع راهداری',
|
||||
}
|
||||
|
||||
export default function RootLayout({children}) {
|
||||
export default function RootLayout({ children }) {
|
||||
return (
|
||||
<html lang="fa" dir={'rtl'}>
|
||||
<body style={{height: '100vh'}}>
|
||||
<TableSettingProvider>
|
||||
{children}
|
||||
</TableSettingProvider>
|
||||
</body>
|
||||
<body style={{ height: '100vh' }}>
|
||||
<TableSettingProvider>
|
||||
{children}
|
||||
</TableSettingProvider>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
|
||||
51
src/app/lfwd/page.js
Normal file
51
src/app/lfwd/page.js
Normal file
@@ -0,0 +1,51 @@
|
||||
'use client'
|
||||
|
||||
import { GET_LOGIN_ROUTE } from "@/core/utils/routes"
|
||||
import useRequest from "@/lib/hooks/useRequest"
|
||||
import { Button, Stack, Typography, Zoom } from "@mui/material"
|
||||
import Link from "next/link"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
const Page = () => {
|
||||
const [login, setLogin] = useState(0)
|
||||
const request = useRequest()
|
||||
|
||||
useEffect(() => {
|
||||
const login = async () => {
|
||||
try {
|
||||
const res = await request(`${GET_LOGIN_ROUTE}?username=witel`)
|
||||
setLogin(1)
|
||||
} catch (error) {
|
||||
setLogin(2)
|
||||
}
|
||||
}
|
||||
|
||||
login()
|
||||
}, [])
|
||||
|
||||
const retry = async () => {
|
||||
setLogin(0)
|
||||
try {
|
||||
const res = await request(`${GET_LOGIN_ROUTE}?username=witel`)
|
||||
setLogin(1)
|
||||
} catch (error) {
|
||||
setLogin(2)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<Stack alignItems={'center'} justifyContent={'center'} sx={{ height: '100%' }} spacing={2}>
|
||||
<Typography variant="h5">
|
||||
{login === 0 ? 'درحال دریافت مجوز برای ارتباط با سرور...' : login === 1 ? 'ارتباط با سرور برقرار شد.' : 'ارتباط با سرور برقرار نشد. مشکلی وجود دارد.'}
|
||||
</Typography>
|
||||
<Zoom in={login === 1}>
|
||||
<Button component={Link} href="/">ورود به سامانه</Button>
|
||||
</Zoom>
|
||||
<Zoom in={login === 2}>
|
||||
<Button onClick={retry}>تلاش مجدد</Button>
|
||||
</Zoom>
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
export default Page
|
||||
@@ -1,18 +1,18 @@
|
||||
import cacheProviderRtl from "@/core/utils/cacheRtl";
|
||||
import {CssBaseline, ThemeProvider} from "@mui/material";
|
||||
import { CssBaseline, ThemeProvider } from "@mui/material";
|
||||
import theme from "@/core/utils/theme";
|
||||
import {AppRouterCacheProvider} from "@mui/material-nextjs/v14-appRouter";
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import { AppRouterCacheProvider } from "@mui/material-nextjs/v14-appRouter";
|
||||
import "^/global.scss";
|
||||
import {ToastContainer} from "react-toastify";
|
||||
import { ToastContainer } from "react-toastify";
|
||||
|
||||
const Template = ({children}) => {
|
||||
const Template = ({ children }) => {
|
||||
return (
|
||||
<AppRouterCacheProvider CacheProvider={cacheProviderRtl} options={{enableCssLayer: true}}>
|
||||
<AppRouterCacheProvider CacheProvider={cacheProviderRtl} options={{ enableCssLayer: true }}>
|
||||
<ThemeProvider theme={theme}>
|
||||
<CssBaseline/>
|
||||
<CssBaseline />
|
||||
{children}
|
||||
<ToastContainer rtl containerId="filtering" closeButton={false}/>
|
||||
<ToastContainer rtl containerId="filtering" closeButton={false} />
|
||||
<ToastContainer rtl containerId="request_data" />
|
||||
</ThemeProvider>
|
||||
</AppRouterCacheProvider>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user