diff --git a/src/components/Page.tsx b/src/components/Page.tsx index 3c07f629..6eef6f88 100644 --- a/src/components/Page.tsx +++ b/src/components/Page.tsx @@ -34,6 +34,7 @@ interface PageProps { hideHeaderOnInitialScroll?: boolean; style?: React.CSSProperties; requiredPermissions?: string[]; + loading?: boolean; } const Page = (props: PageProps) => { @@ -45,8 +46,10 @@ const Page = (props: PageProps) => { const { scrollY, scrollYProgress } = useScroll(); const bgPosY = useTransform(scrollYProgress, (latest) => `${latest * 5 + 50}%`); - return props.requiredPermissions && !user.hasPermissions(props.requiredPermissions) ? ( - + return props.loading ? ( + + ) : props.requiredPermissions && !user.hasPermissions(props.requiredPermissions) ? ( + ) : ( <> diff --git a/src/pages/_error.tsx b/src/pages/_error.tsx index 7439b4bf..064b3f37 100644 --- a/src/pages/_error.tsx +++ b/src/pages/_error.tsx @@ -1,4 +1,4 @@ -import { Button, Center, Title, useMantineColorScheme, useMantineTheme } from '@mantine/core'; +import { Button, Center, Loader, Title, useMantineColorScheme, useMantineTheme } from '@mantine/core'; import Page from '../components/Page'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; @@ -38,28 +38,36 @@ function ErrorPage(props: any) { }} >
- - {code} - + {code == 1 ? ( + + <Loader color="white" size="xl" /> + + ) : ( + + {code} + + )} {errors[code].title} {errors[code].message} <br /> - <Button - variant="outline" - size="xl" - style={{ - color: 'white', - borderColor: 'white', - borderWidth: 3, - marginTop: 'calc(var(--mantine-spacing-xl)*1.5)', - }} - onClick={() => router.back()} - > - {t('button.back', { ns: 'common' })} - </Button> + {code != 1 && ( + <Button + variant="outline" + size="xl" + style={{ + color: 'white', + borderColor: 'white', + borderWidth: 3, + marginTop: 'calc(var(--mantine-spacing-xl)*1.5)', + }} + onClick={() => router.back()} + > + {t('button.back', { ns: 'common' })} + </Button> + )}
@@ -78,9 +86,9 @@ export async function getStaticProps({ locale }: any) { export default ErrorPage; const errors: any = { - fallback: { - title: 'Something went wrong', - message: 'Please try again later.', + '1': { + title: 'Loading data', + message: 'You will be redirected shortly', }, '301': { title: 'Moved Permanently', diff --git a/src/pages/faq/manage.tsx b/src/pages/faq/manage.tsx index a1f50e80..2f126d71 100644 --- a/src/pages/faq/manage.tsx +++ b/src/pages/faq/manage.tsx @@ -149,6 +149,7 @@ const Faq: NextPage = () => { }} seo={{ nofollow: true, noindex: true }} requiredPermissions={['faq.edit', 'faq.remove', 'faq.add']} + loading={!data} > {!data ? ( <> diff --git a/src/pages/me/claims/[id].tsx b/src/pages/me/claims/[id].tsx index bd159deb..58dcf42d 100644 --- a/src/pages/me/claims/[id].tsx +++ b/src/pages/me/claims/[id].tsx @@ -80,6 +80,7 @@ const ClaimPage: NextPage = ({ claimId, data }: any) => { }} smallPadding requiredPermissions={['account.edit', 'account.info']} + loading={!data} > {!data ? ( <> diff --git a/src/pages/me/index.tsx b/src/pages/me/index.tsx index 51fa31cb..3f61de20 100644 --- a/src/pages/me/index.tsx +++ b/src/pages/me/index.tsx @@ -27,8 +27,9 @@ const MePage: NextPage = () => { image: 'https://cdn.buildtheearth.net/static/thumbnails/me.png', }} requiredPermissions={['account.info']} + loading={!data} > - {data ? ( + {data && ( <>

{t('description')}

{t('account.title')}

@@ -197,8 +198,6 @@ const MePage: NextPage = () => { )} - ) : ( - <>loading )} ); diff --git a/src/pages/me/settings/[type].tsx b/src/pages/me/settings/[type].tsx index 448948a8..856174c5 100644 --- a/src/pages/me/settings/[type].tsx +++ b/src/pages/me/settings/[type].tsx @@ -58,13 +58,14 @@ const Settings: NextPage = ({ type }: any) => { }); }; - https: return data ? ( + return ( router.push({ query: { type: v } })}> @@ -146,11 +147,6 @@ const Settings: NextPage = ({ type }: any) => { - ) : ( - - You are not logged in - You need to be logged in to view this page. - ); }; diff --git a/src/pages/teams/[team]/manage/apply.tsx b/src/pages/teams/[team]/manage/apply.tsx index 80497978..650e16c7 100644 --- a/src/pages/teams/[team]/manage/apply.tsx +++ b/src/pages/teams/[team]/manage/apply.tsx @@ -147,6 +147,7 @@ const Apply: NextPage = ({ data: tempData, team }: any) => { }} seo={{ nofollow: true, noindex: true }} requiredPermissions={['team.settings.edit', 'team.socials.edit', 'team.application.edit', 'team.application.list', 'team.application.review']} + loading={!data} > setEditingQuestion(null)} title="Edit Question" centered size="lg"> diff --git a/src/pages/teams/[team]/manage/images.tsx b/src/pages/teams/[team]/manage/images.tsx index 65c32c90..d3264f9e 100644 --- a/src/pages/teams/[team]/manage/images.tsx +++ b/src/pages/teams/[team]/manage/images.tsx @@ -141,6 +141,7 @@ const Settings = () => { }} seo={{ nofollow: true, noindex: true }} requiredPermissions={['team.settings.edit', 'team.socials.edit', 'team.application.edit', 'team.application.list', 'team.application.review']} + loading={!data} > diff --git a/src/pages/teams/[team]/manage/members.tsx b/src/pages/teams/[team]/manage/members.tsx index e112b16e..c982abaa 100644 --- a/src/pages/teams/[team]/manage/members.tsx +++ b/src/pages/teams/[team]/manage/members.tsx @@ -203,6 +203,7 @@ const Settings = () => { }} seo={{ nofollow: true, noindex: true }} requiredPermissions={['team.settings.edit', 'team.socials.edit', 'team.application.edit', 'team.application.list', 'team.application.review']} + loading={!(builders && managers)} > diff --git a/src/pages/teams/[team]/manage/review/[id].tsx b/src/pages/teams/[team]/manage/review/[id].tsx index 0d345622..a141e305 100644 --- a/src/pages/teams/[team]/manage/review/[id].tsx +++ b/src/pages/teams/[team]/manage/review/[id].tsx @@ -77,6 +77,7 @@ const Apply: NextPage = ({ team, id }: any) => { image: 'https://cdn.buildtheearth.net/static/thumbnails/apply.png', }} requiredPermissions={['team.application.review']} + loading={!data} > {data && ( diff --git a/src/pages/teams/[team]/manage/review/index.tsx b/src/pages/teams/[team]/manage/review/index.tsx index fa9c8015..f1a1e81d 100644 --- a/src/pages/teams/[team]/manage/review/index.tsx +++ b/src/pages/teams/[team]/manage/review/index.tsx @@ -20,6 +20,7 @@ const Review = ({ team }: any) => { }} seo={{ nofollow: true, noindex: true }} requiredPermissions={['team.settings.edit', 'team.socials.edit', 'team.application.edit', 'team.application.list', 'team.application.review']} + loading={!data} > diff --git a/src/pages/teams/[team]/manage/settings.tsx b/src/pages/teams/[team]/manage/settings.tsx index 410ccb08..eea45571 100644 --- a/src/pages/teams/[team]/manage/settings.tsx +++ b/src/pages/teams/[team]/manage/settings.tsx @@ -87,6 +87,7 @@ const Settings = ({ data: tempData }: any) => { }} seo={{ nofollow: true, noindex: true }} requiredPermissions={['team.settings.edit', 'team.socials.edit', 'team.application.edit', 'team.application.list', 'team.application.review']} + loading={!data} > {data && (