formatted

This commit is contained in:
Amirhossein Mahmoodi
2024-07-09 13:58:13 +03:30
parent 863bdaca95
commit bc73725138
82 changed files with 2206 additions and 3082 deletions

View File

@@ -1,29 +1,33 @@
'use client'
import { Button } from "@mui/material"
import axios from "axios"
"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 })
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 })
const res = axios.get("https://rms.witel.ir/webapi/user/get-permission", {
withCredentials: true,
});
console.log(res);
} catch (error) {
console.log(error);
}
}
};
return (
<>
<Button onClick={handler}>login</Button>
<Button onClick={handler2}>check</Button>
</>
)
}
);
};
export default Page
export default Page;

View File

@@ -1,19 +1,17 @@
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';
import "react-toastify/dist/ReactToastify.css";
const Template = ({ children }) => {
return (
<Stack>
<HeaderWithLogo />
<Box>
<HeaderWithSidebar>
{children}
</HeaderWithSidebar>
<HeaderWithSidebar>{children}</HeaderWithSidebar>
</Box>
</Stack>
)
}
);
};
export default Template
export default Template;

View File

@@ -1,14 +1,12 @@
import WithAuthMiddleware from "@/core/middlewares/withAuth"
import { AuthProvider } from "@/lib/contexts/auth"
import WithAuthMiddleware from "@/core/middlewares/withAuth";
import { AuthProvider } from "@/lib/contexts/auth";
const Layout = ({ children }) => {
return (
<AuthProvider>
<WithAuthMiddleware>
{children}
</WithAuthMiddleware>
<WithAuthMiddleware>{children}</WithAuthMiddleware>
</AuthProvider>
)
}
);
};
export default Layout
export default Layout;

View File

@@ -1,3 +1,3 @@
export default function Default() {
return null
}
return null;
}

View File

@@ -1,17 +1,15 @@
import { TableSettingProvider } from "@/lib/contexts/tableSetting";
export const metadata = {
title: 'سامانه جامع راهداری',
}
title: "سامانه جامع راهداری",
};
export default function RootLayout({ children }) {
return (
<html lang="fa" dir={'rtl'}>
<body style={{ height: '100vh' }}>
<TableSettingProvider>
{children}
</TableSettingProvider>
<html lang="fa" dir={"rtl"}>
<body style={{ height: "100vh" }}>
<TableSettingProvider>{children}</TableSettingProvider>
</body>
</html>
)
);
}

View File

@@ -1,51 +1,57 @@
'use client'
"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"
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()
const Page = ({ searchParams }) => {
const { username } = searchParams;
const [login, setLogin] = useState(0);
const request = useRequest();
useEffect(() => {
const login = async () => {
try {
const res = await request(`${GET_LOGIN_ROUTE}?username=witel`)
setLogin(1)
await request(`${GET_LOGIN_ROUTE}?username=${username}`);
setLogin(1);
} catch (error) {
setLogin(2)
setLogin(2);
}
}
};
login()
}, [])
login();
}, []);
const retry = async () => {
setLogin(0)
setLogin(0);
try {
const res = await request(`${GET_LOGIN_ROUTE}?username=witel`)
setLogin(1)
await request(`${GET_LOGIN_ROUTE}?username=${username}`);
setLogin(1);
} catch (error) {
setLogin(2)
setLogin(2);
}
}
};
return (
<Stack alignItems={'center'} justifyContent={'center'} sx={{ height: '100%' }} spacing={2}>
<Stack alignItems={"center"} justifyContent={"center"} sx={{ height: "100%" }} spacing={2}>
<Typography variant="h5">
{login === 0 ? 'درحال دریافت مجوز برای ارتباط با سرور...' : login === 1 ? 'ارتباط با سرور برقرار شد.' : 'ارتباط با سرور برقرار نشد. مشکلی وجود دارد.'}
{login === 0
? "درحال دریافت مجوز برای ارتباط با سرور..."
: login === 1
? "ارتباط با سرور برقرار شد."
: "ارتباط با سرور برقرار نشد. مشکلی وجود دارد."}
</Typography>
<Zoom in={login === 1}>
<Button component={Link} href="/">ورود به سامانه</Button>
<Button component={Link} href="/">
ورود به سامانه
</Button>
</Zoom>
<Zoom in={login === 2}>
<Button onClick={retry}>تلاش مجدد</Button>
</Zoom>
</Stack>
)
}
export default Page
);
};
export default Page;

View File

@@ -1,8 +1,8 @@
import { redirect } from "next/navigation"
import { redirect } from "next/navigation";
function Page() {
redirect('/dashboard', 'replace')
return null
redirect("/dashboard", "replace");
return null;
}
export default Page
export default Page;

View File

@@ -15,7 +15,7 @@ const Template = ({ children }) => {
<ToastContainer rtl containerId="request_data" />
</ThemeProvider>
</AppRouterCacheProvider>
)
}
);
};
export default Template
export default Template;