CFE-1 create project from the tamplate project and config project
This commit is contained in:
24
src/pages/403.jsx
Normal file
24
src/pages/403.jsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import {useEffect, useState} from "react";
|
||||
import {useRouter} from "next/router";
|
||||
import {NextIntlProvider} from "next-intl";
|
||||
import UnAuthorizedComponent from "@/components/errors/403";
|
||||
|
||||
export default function Custom404() {
|
||||
const router = useRouter()
|
||||
const [messages, setMessages] = useState(null)
|
||||
useEffect(() => {
|
||||
const fetch = async () => {
|
||||
const tempMessages = (await import(`&/locales/${router.locale}/app.json`)).default
|
||||
setMessages(tempMessages)
|
||||
}
|
||||
fetch()
|
||||
}, []);
|
||||
|
||||
if (!messages) return
|
||||
|
||||
return (
|
||||
<NextIntlProvider messages={messages}>
|
||||
<UnAuthorizedComponent/>
|
||||
</NextIntlProvider>
|
||||
);
|
||||
}
|
||||
25
src/pages/404.jsx
Normal file
25
src/pages/404.jsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import {useEffect, useState} from "react";
|
||||
import {useRouter} from "next/router";
|
||||
import {NextIntlProvider} from "next-intl";
|
||||
import NotFoundComponent from "@/components/errors/404";
|
||||
|
||||
export default function Custom404() {
|
||||
const router = useRouter()
|
||||
const [messages, setMessages] = useState(null)
|
||||
useEffect(() => {
|
||||
|
||||
const fetch = async () => {
|
||||
const tempMessages = (await import(`&/locales/${router.locale}/app.json`)).default
|
||||
setMessages(tempMessages)
|
||||
}
|
||||
fetch()
|
||||
}, []);
|
||||
|
||||
if (!messages) return
|
||||
|
||||
return (
|
||||
<NextIntlProvider messages={messages}>
|
||||
<NotFoundComponent/>
|
||||
</NextIntlProvider>
|
||||
);
|
||||
}
|
||||
24
src/pages/500.jsx
Normal file
24
src/pages/500.jsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import {useEffect, useState} from "react";
|
||||
import {useRouter} from "next/router";
|
||||
import {NextIntlProvider} from "next-intl";
|
||||
import ServerErrorComponent from "@/components/errors/500";
|
||||
|
||||
export default function Custom500() {
|
||||
const router = useRouter()
|
||||
const [messages, setMessages] = useState(null)
|
||||
useEffect(() => {
|
||||
const fetch = async () => {
|
||||
const tempMessages = (await import(`&/locales/${router.locale}/app.json`)).default
|
||||
setMessages(tempMessages)
|
||||
}
|
||||
fetch()
|
||||
}, []);
|
||||
|
||||
if (!messages) return
|
||||
|
||||
return (
|
||||
<NextIntlProvider messages={messages}>
|
||||
<ServerErrorComponent/>
|
||||
</NextIntlProvider>
|
||||
);
|
||||
}
|
||||
33
src/pages/_app.jsx
Normal file
33
src/pages/_app.jsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import "&/fontiran.scss";
|
||||
import AppLayout from "@/layouts/AppLayout";
|
||||
import MuiLayout from "@/layouts/MuiLayout";
|
||||
import {LanguageProvider} from "@/lib/app/contexts/language";
|
||||
import {LoadingProvider} from "@/lib/app/contexts/loading";
|
||||
import {UserProvider} from "@/lib/app/contexts/user";
|
||||
import "moment/locale/fa";
|
||||
import {NextIntlProvider} from "next-intl";
|
||||
import TitlePage from "@/core/components/TitlePage";
|
||||
|
||||
const App = ({Component, pageProps}) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<UserProvider>
|
||||
<LanguageProvider>
|
||||
<NextIntlProvider messages={pageProps.messages || {}}>
|
||||
<MuiLayout isBot={pageProps.isBot}>
|
||||
{pageProps.messages ? <TitlePage text={pageProps.title}/> : ''}
|
||||
<LoadingProvider>
|
||||
<AppLayout isBot={pageProps.isBot}>
|
||||
<Component {...pageProps} />
|
||||
</AppLayout>
|
||||
</LoadingProvider>
|
||||
</MuiLayout>
|
||||
</NextIntlProvider>
|
||||
</LanguageProvider>
|
||||
</UserProvider>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
61
src/pages/_document.jsx
Normal file
61
src/pages/_document.jsx
Normal file
@@ -0,0 +1,61 @@
|
||||
import {createEmotionCacheRtl} from "@/core/utils/createEmotionCache";
|
||||
import theme from "@/core/utils/theme";
|
||||
import createEmotionServer from "@emotion/server/create-instance";
|
||||
import Document, {Head, Html, Main, NextScript} from "next/document";
|
||||
|
||||
export default function MyDocument(props) {
|
||||
const {emotionStyleTags} = props;
|
||||
|
||||
return (
|
||||
<Html>
|
||||
<Head>
|
||||
<meta name="theme-color" content={theme.palette.primary.main}/>
|
||||
<meta name="emotion-insertion-point" content=""/>
|
||||
<link rel="shortcut icon" href="/icons/favicon.png"/>
|
||||
<link rel="manifest" href="/manifest.json"/>
|
||||
{emotionStyleTags}
|
||||
</Head>
|
||||
<body>
|
||||
<Main/>
|
||||
<NextScript/>
|
||||
</body>
|
||||
</Html>
|
||||
);
|
||||
}
|
||||
|
||||
MyDocument.getInitialProps = async (ctx) => {
|
||||
const originalRenderPage = ctx.renderPage;
|
||||
let cache;
|
||||
switch (ctx.locale) {
|
||||
case "fa":
|
||||
cache = createEmotionCacheRtl();
|
||||
break;
|
||||
}
|
||||
|
||||
const {extractCriticalToChunks} = createEmotionServer(cache);
|
||||
|
||||
ctx.renderPage = () =>
|
||||
originalRenderPage({
|
||||
enhanceApp: (App) =>
|
||||
function EnhanceApp(props) {
|
||||
return <App emotionCache={cache} {...props} />;
|
||||
},
|
||||
});
|
||||
|
||||
const initialProps = await Document.getInitialProps(ctx);
|
||||
|
||||
const emotionStyles = extractCriticalToChunks(initialProps.html);
|
||||
const emotionStyleTags = emotionStyles.styles.map((style) => (
|
||||
<style
|
||||
data-emotion={`${style.key} ${style.ids.join(" ")}`}
|
||||
key={style.key}
|
||||
// eslint-disable-next-line react/no-danger
|
||||
dangerouslySetInnerHTML={{__html: style.css}}
|
||||
/>
|
||||
));
|
||||
|
||||
return {
|
||||
...initialProps,
|
||||
emotionStyleTags,
|
||||
};
|
||||
};
|
||||
22
src/pages/dashboard/change-password/index.jsx
Normal file
22
src/pages/dashboard/change-password/index.jsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import DashboardChangePasswordComponent from "@/components/dashboard/change-password";
|
||||
import WithAuthMiddleware from "@/middlewares/WithAuth";
|
||||
import {parse} from "next-useragent";
|
||||
|
||||
export default function LoanFollowUp() {
|
||||
return (
|
||||
<WithAuthMiddleware>
|
||||
<DashboardChangePasswordComponent/>
|
||||
</WithAuthMiddleware>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps({req, locale}) {
|
||||
const {isBot} = parse(req.headers["user-agent"]);
|
||||
return {
|
||||
props: {
|
||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
||||
title: "Dashboard.change_password",
|
||||
isBot,
|
||||
},
|
||||
};
|
||||
}
|
||||
22
src/pages/dashboard/edit-profile/index.jsx
Normal file
22
src/pages/dashboard/edit-profile/index.jsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import DashboardEditProfile from "@/components/dashboard/edit-profile";
|
||||
import WithAuthMiddleware from "@/middlewares/WithAuth";
|
||||
import {parse} from "next-useragent";
|
||||
|
||||
export default function LoanFollowUp() {
|
||||
return (
|
||||
<WithAuthMiddleware>
|
||||
<DashboardEditProfile/>
|
||||
</WithAuthMiddleware>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps({req, locale}) {
|
||||
const {isBot} = parse(req.headers["user-agent"]);
|
||||
return {
|
||||
props: {
|
||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
||||
title: "Dashboard.edit_profile",
|
||||
isBot,
|
||||
},
|
||||
};
|
||||
}
|
||||
22
src/pages/dashboard/index.jsx
Normal file
22
src/pages/dashboard/index.jsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import DashboardFirstComponent from "@/components/dashboard/first";
|
||||
import WithAuthMiddleware from "@/middlewares/WithAuth";
|
||||
import {parse} from "next-useragent";
|
||||
|
||||
export default function Dashboard() {
|
||||
return (
|
||||
<WithAuthMiddleware>
|
||||
<DashboardFirstComponent/>
|
||||
</WithAuthMiddleware>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps({req, locale}) {
|
||||
const {isBot} = parse(req.headers["user-agent"]);
|
||||
return {
|
||||
props: {
|
||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
||||
title: "Dashboard.dashboard_page",
|
||||
isBot,
|
||||
},
|
||||
};
|
||||
}
|
||||
21
src/pages/index.jsx
Normal file
21
src/pages/index.jsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import FirstComponent from "@/components/first";
|
||||
import {parse} from "next-useragent";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<>
|
||||
<FirstComponent/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps({req, locale}) {
|
||||
const {isBot} = parse(req.headers["user-agent"]);
|
||||
return {
|
||||
props: {
|
||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
||||
title: "first_page",
|
||||
isBot,
|
||||
},
|
||||
};
|
||||
}
|
||||
22
src/pages/login-expert.jsx
Normal file
22
src/pages/login-expert.jsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import LoginComponent from "@/components/login-expert";
|
||||
import WithoutAuthMiddleware from "@/middlewares/WithoutAuth";
|
||||
import {parse} from "next-useragent";
|
||||
|
||||
export default function Login() {
|
||||
return (
|
||||
<WithoutAuthMiddleware>
|
||||
<LoginComponent/>
|
||||
</WithoutAuthMiddleware>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps({req, locale}) {
|
||||
const {isBot} = parse(req.headers["user-agent"]);
|
||||
return {
|
||||
props: {
|
||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
||||
title: "Titles.title_login_expert_page",
|
||||
isBot,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user