Skip to content

Commit

Permalink
feat: introduce route path
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminic committed Dec 11, 2024
1 parent 69cac06 commit 27f8be0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/routes/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function createSectionLazyRouteFunction(
return async () => {
try {
return await import(
`../../pages/${section.namePlural}/${componentFileName}`
`../../pages/${section.routeName || section.namePlural}/${componentFileName}`
)
} catch (e) {
// means the component is not implemented yet
Expand Down
3 changes: 2 additions & 1 deletion src/lib/constants/sections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export const SCHEMA_SECTIONS = {
// @ts-expect-error temporary route for testing
dataSetWIP: {
name: SchemaName.dataSet,
namePlural: 'dataSetsWip',
routeName: 'dataSetsWip',
namePlural: 'dataSets',
title: i18n.t('Data set'),
titlePlural: i18n.t('Data sets'),
parentSectionKey: 'dataSet',
Expand Down
3 changes: 2 additions & 1 deletion src/lib/routeUtils/routePaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export const getSectionPath = (section: Section | string) => {
if (typeof section === 'string') {
return section
}
return section.namePlural
return section.routeName || section.namePlural

}

export const getSectionNewPath = (section: Section | string) => {
Expand Down
1 change: 1 addition & 0 deletions src/types/section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type NonSchemaSection = SectionBase & {

export type OverviewSection = SectionBase & {
componentName: string
routeName?: string
}

export type ModelSection = SchemaSection | NonSchemaSection
Expand Down

0 comments on commit 27f8be0

Please sign in to comment.