Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

technical/layout into [email protected] 🐢 minor global changes (not found page, page metadata, titles) #76

Open
wants to merge 8 commits into
base: [email protected]
Choose a base branch
from
4 changes: 2 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const fontSans = FontSans({
});

export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app'
title: 'Большой Квест',
description: 'Большой Квест'
};

const TOASTER_DURATION = 5000;
Expand Down
55 changes: 55 additions & 0 deletions app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { headers } from 'next/headers';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не нужно делать 1 not found на все, not found можно реализоваывать на каждый сегмент org можно сделать отдельно, для обчного приложения тоже отдельно

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вчера выяснили точно, что такая история не прокатит, возможен только глобальный not-found, поэтому думала как предложила отслеживать через isOrg и isPartner, но выявила проблему что при рендере referer всегда пустой, поэтому отказалась от них

единственный варик который вижу - отслеживать в мидлваре, но стоит ли оно сейчас того, жду предложений

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • добавила метадату, для app/activities в ветке 282 положу сразу

import Link from 'next/link';

import { I18nText } from '@/components/common';
import { buttonVariants, Typography } from '@/components/ui';
import { cn } from '@/lib/utils';
import { getUserSession } from '@/utils/helpers/server';

import Layout from './org/(panel)/layout';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OrgLayout


const NotFoundComponent = ({ link }: { link: string }) => (
<div className='flex h-full w-full flex-col items-center justify-center gap-2 p-6'>
<Typography variant='h3'>
<I18nText path='page.notFound.title' />
</Typography>
<Link
href={{
pathname: link,
query: { step: 'login' }
}}
className={cn(buttonVariants({ size: 'lg', variant: 'primary' }), 'w-full max-w-96')}
>
<I18nText path='button.backToRoot' />
</Link>
</div>
);

const NotFound = () => {
const userSession = getUserSession();
const headersList = headers();

const pathname = headersList.get('referer');
const isOrg = pathname?.includes('/org/');
const isPartner = pathname?.includes('/partner/');

// TODO будем ли отслеживать org / partner пути для редиректа
console.log(userSession, pathname, isOrg, isPartner);

return (
<>
{!userSession && (
<div className='h-screen w-screen'>
<NotFoundComponent link='/' />
</div>
)}
{userSession && (
<Layout>
<NotFoundComponent link='/org/organizations/dashboard' />
</Layout>
)}
</>
);
};

export default NotFound;
3 changes: 3 additions & 0 deletions static/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"site.error": "Что-то пошло не так",
"site.loading": "Пожалуйста подождите...",

"page.notFound.title": "404 Страница не найдена",

"partners.addresses.title": "Адреса",
"partners.activities.title": "Активности",
"partners.employees.title": "Сотрудники",
Expand Down Expand Up @@ -81,6 +83,7 @@
"button.haveNotUserId": "У меня нет User ID",
"button.logout": "Выйти",
"button.addQR": "Добавить новый QR",
"button.backToRoot": "Вернуться на главную",

"organization.stage.request": "Заявка",
"organization.stage.negotiation": "Сотрудничество",
Expand Down