-
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 6 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,7 @@ | ||
import 'server-only'; | ||
|
||
const dictionaries = { | ||
ru: () => import('../static/locales/ru.json').then((module) => module.default) | ||
}; | ||
|
||
export const getDictionary = (locale) => dictionaries[locale](); | ||
Melly5 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { NotFoundComponent } from '@/components/common'; | ||
import { ROLES_BY_ROUTE, ROUTES } from '@/utils/constants'; | ||
import { getUserSession } from '@/utils/helpers/server'; | ||
|
||
import AppLayout from './app/(main)/layout'; | ||
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 && userSession.roles.some((role) => ROLES_BY_ROUTE.PARTNER.includes(role)) && ( | ||
<div className='h-screen w-screen'> | ||
<NotFoundComponent link={ROUTES.PARTNER.ROOT} /> | ||
</div> | ||
)} | ||
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. у партнера же есть тоже 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. есть, но в него необходимо прокидывыть id организации у партнера, а у нас нет логики его хранения я так понимаю как появится логика в духе: авторизация партнера -> запрос на получение id организации по данным партнера -> отображение данных(страницы) по этому id тогда и можно будет обернуть Layout-ом |
||
{userSession && userSession.roles.some((role) => ROLES_BY_ROUTE.APP.includes(role)) && ( | ||
<AppLayout> | ||
<NotFoundComponent link={ROUTES.APP.PROFILE.ROOT} /> | ||
</AppLayout> | ||
)} | ||
{userSession && userSession.roles.some((role) => ROLES_BY_ROUTE.ORG.includes(role)) && ( | ||
<Layout> | ||
<NotFoundComponent link={ROUTES.ORG.ORGANIZATIONS.DASHBOARD} /> | ||
</Layout> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default NotFound; |
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 { ResolvingMetadata } from 'next'; | ||
|
||
export const getPathnameFromMetadataState = (state: ResolvingMetadata) => { | ||
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.