-
Notifications
You must be signed in to change notification settings - Fork 1
technical/layout into [email protected] 🐢 minor global changes (not found page, page metadata, titles) #76
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
base: [email protected]
Are you sure you want to change the base?
Changes from 4 commits
f623571
d3000cb
f3aed82
1b6d2f1
d3c33c0
07a8cee
feafca6
1de1d90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
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'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 && ( | ||
Melly5 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<Layout> | ||
<NotFoundComponent link={ROUTES.ORG.ORGANIZATIONS.DASHBOARD} /> | ||
</Layout> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default NotFound; |
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( | ||
Melly5 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ 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()]}` | ||
}; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. можешь тут написать пример ? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 } | ||
|
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> | ||
); |
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(/\?.+/, ''); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './getMessagesByLocale'; | ||
export * from './getNavigationLinksByUserRoles'; | ||
export * from './getPathnameFromMetadataState'; |
Uh oh!
There was an error while loading. Please reload this page.