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
22 changes: 14 additions & 8 deletions app/(landing)/[city]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { CITIES } from '@/utils/constants';
import { NotFoundComponent } from '@/components/common';
import { CITIES, ROUTES } from '@/utils/constants';

import { Footer } from '../(components)/Footer/Footer';
import { Header } from '../(components)/Header/Header';
Expand All @@ -10,12 +11,17 @@ interface LandingCityLayoutProps {
};
}

const LandingCityLayout = ({ children, params }: LandingCityLayoutProps) => (
<>
<Header cityId={params.city} />
{children}
<Footer cityId={params.city} />
</>
);
const LandingCityLayout = ({ children, params }: LandingCityLayoutProps) => {
if (!Object.keys(CITIES).includes(params.city.toUpperCase()))
return <NotFoundComponent link={ROUTES.LANDING.ROOT} />;

return (
<>
<Header cityId={params.city} />
{children}
<Footer cityId={params.city} />
</>
);
};

export default LandingCityLayout;
6 changes: 6 additions & 0 deletions app/app/(main)/activities/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import type { Metadata } from 'next';

import { I18nText } from '@/components/common';
import { Typography } from '@/components/ui';
Expand All @@ -12,6 +13,11 @@ interface ActivitiesPageProps {
searchParams: SearchParams;
}

export const metadata: Metadata = {
title: 'Большой Квест | Каталог активностей',
description: 'Большой Квест | Каталог активностей'
};

const ActivitiesPage = async ({ searchParams }: ActivitiesPageProps) => {
const [getCategoryResponse, getActivityResponse] = await Promise.all([
getCategory({ config: { cache: 'no-store' } }),
Expand Down
4 changes: 0 additions & 4 deletions app/app/not-found.tsx

This file was deleted.

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
26 changes: 26 additions & 0 deletions app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NotFoundComponent } from '@/components/common';
import { ROUTES } from '@/utils/constants';
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 NotFound = () => {
const userSession = getUserSession();

return (
<>
{!userSession && (
<div className='h-screen w-screen'>
<NotFoundComponent link={ROUTES.LANDING.ROOT} />
</div>
)}
{userSession && (
<Layout>
<NotFoundComponent link={ROUTES.ORG.ORGANIZATIONS.DASHBOARD} />
</Layout>
)}
</>
);
};

export default NotFound;
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ import { ActivityIcon, MapPinIcon, UserIcon, UsersRoundIcon } from 'lucide-react

import { ROUTES } from '@/utils/constants';

export const ORGANIZATION_PROFILE_TAB_TEXTS = {
PROFILE: 'Профиль',
ACTIVITIES: 'Активности',
ADDRESSES: 'Адреса',
EMPLOYEES: 'Сотрудники',
SCHEDULE: 'Расписание'
};

export const ORGANIZATION_PROFILE_TAB_VALUES = {
PROFILE: 'profile',
ADDRESSES: 'addresses',
Expand Down
21 changes: 21 additions & 0 deletions app/org/(panel)/organizations/[organizationId]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
import type { Metadata, ResolvedMetadata } from 'next';

import { getOrganizationById } from '@/utils/api/requests';
import { ROUTES } from '@/utils/constants';
import { getPathnameFromMetadataState } from '@/utils/helpers';

import { OrgBreadcrumbs } from '../../(components)/OrgBreadcrumbs/OrgBreadcrumbs';

import { OrganizationHeader } from './(components)/OrganizationHeader/OrganizationHeader';
import { ORGANIZATION_PROFILE_TAB_TEXTS } from './(constants)/navigation';

interface OrganizationPageLayoutProps {
params: { organizationId: string };
children: React.ReactNode;
}

export async function generateMetadata(
{ params }: OrganizationPageLayoutProps,
parent: ResolvedMetadata
): Promise<Metadata> {
const organization = await getOrganizationById({
params: { id: params.organizationId }
});

const pathname = getPathnameFromMetadataState(parent);
const pathnameParts = pathname.split('/');
const lastPart = pathnameParts[pathnameParts.length - 1];

return {
title: `ЛК Организатора | ${organization.name} | ${ORGANIZATION_PROFILE_TAB_TEXTS[lastPart.toUpperCase()]}`
};
}
Copy link
Member

Choose a reason for hiding this comment

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

можешь тут написать пример ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ЛК Организатора | ООО Рисовашки | Профиль


const OrganizationPageLayout = async ({ params, children }: OrganizationPageLayoutProps) => {
const organization = await getOrganizationById({
params: { id: params.organizationId }
Expand Down
6 changes: 6 additions & 0 deletions app/org/(panel)/organizations/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';

import { getOrganization } from '@/utils/api';
Expand All @@ -7,6 +8,11 @@ import { OrgBreadcrumbs } from '../../(components)/OrgBreadcrumbs/OrgBreadcrumbs
import { OrganizationsDashboard } from './(components)/OrganizationsDashboard/OrganizationsDashboard';
import { OrganizationsTable } from './(components)/OrganizationsTable/OrganizationsTable';

export const metadata: Metadata = {
title: 'ЛК Организатора | Организации',
description: 'ЛК Организатора | Организации'
};

export interface OrganizationsPageProps {
searchParams: SearchParams;
}
Expand Down
6 changes: 6 additions & 0 deletions app/org/auth/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Metadata } from 'next';
import Image from 'next/image';

import authImage from '@/assets/images/auth.webp';
Expand All @@ -7,6 +8,11 @@ import { ROUTES } from '@/utils/constants';

import { LoginForm } from './(components)/LoginForm/LoginForm';

export const metadata: Metadata = {
title: 'ЛК Организатора | Авторизация',
description: 'ЛК Организатора | Авторизация'
};

const OrgAuthPage = () => (
<div className='flex min-h-screen flex-col items-center justify-between p-2'>
<div className='flex flex-1 items-center justify-around gap-28 xlx:gap-12 xlx:p-5'>
Expand Down
25 changes: 25 additions & 0 deletions src/components/common/NotFoundComponent/NotFoundComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Link from 'next/link';

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

interface NotFoundComponentProps {
link: string;
}

export const NotFoundComponent = ({ link }: NotFoundComponentProps) => (
<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
}}
className={cn(buttonVariants({ size: 'lg', variant: 'primary' }), 'w-full max-w-96')}
>
<I18nText path='button.backToRoot' />
</Link>
</div>
);
1 change: 1 addition & 0 deletions src/components/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './I18nText/I18nText';
export * from './Logo/Logo';
export * from './NotFoundComponent/NotFoundComponent';
export * from './NotificationsDropdownMenu/NotificationsDropdownMenu';
export * from './QRCode/QRCode';
export * from './texts';
Expand Down
10 changes: 10 additions & 0 deletions src/utils/helpers/getPathnameFromMetadataState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { ResolvedMetadata } from 'next';

export const getPathnameFromMetadataState = (state: ResolvedMetadata) => {
const res = Object.getOwnPropertySymbols(state || {})
.map((p) => state[p])
// eslint-disable-next-line no-prototype-builtins
.find((state) => state?.hasOwnProperty?.('urlPathname'));

return res?.urlPathname.replace(/\?.+/, '');
};
1 change: 1 addition & 0 deletions src/utils/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './getMessagesByLocale';
export * from './getNavigationLinksByUserRoles';
export * from './getPathnameFromMetadataState';
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