-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7dd519b
commit 2fb79ad
Showing
6 changed files
with
125 additions
and
31 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
apps/concept-catalog/app/catalogs/[catalogId]/concepts/new/new-page.client.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use client'; | ||
|
||
import { Breadcrumbs, PageBanner } from '@catalog-frontend/ui'; | ||
import { localization, getTranslateText } from '@catalog-frontend/utils'; | ||
import ConceptForm from '../../../../../components/concept-form'; | ||
|
||
export const NewPage = ({ | ||
breadcrumbList, | ||
catalogId, | ||
organization, | ||
concept, | ||
conceptStatuses, | ||
codeListsResult, | ||
fieldsResult, | ||
usersResult, | ||
catalogPortalBaseUri | ||
}) => { | ||
|
||
|
||
return ( | ||
<> | ||
<Breadcrumbs | ||
breadcrumbList={breadcrumbList} | ||
catalogPortalUrl={`${catalogPortalBaseUri}/catalogs`} | ||
/> | ||
<PageBanner | ||
title={localization.catalogType.concept} | ||
subtitle={getTranslateText(organization.prefLabel).toString()} | ||
/> | ||
<ConceptForm | ||
catalogId={catalogId} | ||
concept={concept} | ||
conceptStatuses={conceptStatuses} | ||
codeListsResult={codeListsResult} | ||
fieldsResult={fieldsResult} | ||
usersResult={usersResult} | ||
/> | ||
</> | ||
); | ||
}; |
64 changes: 57 additions & 7 deletions
64
apps/concept-catalog/app/catalogs/[catalogId]/concepts/new/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,61 @@ | ||
import { RedirectType, redirect } from 'next/navigation'; | ||
import { getAllCodeLists, getConceptStatuses, getFields, getOrganization, getUsers } from '@catalog-frontend/data-access'; | ||
import { BreadcrumbType } from '@catalog-frontend/ui'; | ||
import { localization, prepareStatusList } from '@catalog-frontend/utils'; | ||
import { CodeListsResult, FieldsResult, Organization, UsersResult } from '@catalog-frontend/types'; | ||
import { withWriteProtectedPage } from '../../../../../utils/auth'; | ||
|
||
export const NewPage = withWriteProtectedPage( | ||
({ catalogId }) => `/catalogs/${catalogId}/concepts/new`, | ||
async ({ catalogId }) => { | ||
//redirect(`${process.env.CONCEPT_CATALOG_GUI_BASE_URI}/${catalogId}/new`, RedirectType.push); | ||
import { NewPage } from './new-page.client'; | ||
|
||
export default withWriteProtectedPage( | ||
({ catalogId }) => `/catalogs//${catalogId}/concepts/new`, | ||
async ({ catalogId, session }) => { | ||
const concept = { | ||
ansvarligVirksomhet: { | ||
id: catalogId | ||
} | ||
}; | ||
|
||
const conceptStatuses = await getConceptStatuses() | ||
.then((response) => response.json()) | ||
.then((body) => body?.conceptStatuses ?? []) | ||
.then((statuses) => prepareStatusList(statuses)); | ||
|
||
const organization: Organization = await getOrganization(catalogId).then((response) => response.json()); | ||
const codeListsResult: CodeListsResult = await getAllCodeLists(catalogId, `${session?.accessToken}`).then( | ||
(response) => response.json(), | ||
); | ||
const fieldsResult: FieldsResult = await getFields(catalogId, `${session?.accessToken}`).then((response) => | ||
response.json(), | ||
); | ||
const usersResult: UsersResult = await getUsers(catalogId, `${session?.accessToken}`).then((response) => | ||
response.json(), | ||
); | ||
|
||
const breadcrumbList = catalogId | ||
? ([ | ||
{ | ||
href: `/catalogs/${catalogId}`, | ||
text: localization.catalogType.concept, | ||
}, | ||
{ | ||
href: `/catalogs/${catalogId}/concepts/new`, | ||
text: localization.newConcept, | ||
}, | ||
] as BreadcrumbType[]) | ||
: []; | ||
|
||
return ( | ||
<NewPage | ||
catalogId={catalogId} | ||
breadcrumbList={breadcrumbList} | ||
organization={organization} | ||
concept={concept} | ||
conceptStatuses={conceptStatuses} | ||
codeListsResult={codeListsResult} | ||
fieldsResult={fieldsResult} | ||
usersResult={usersResult} | ||
catalogPortalBaseUri={process.env.CATALOG_PORTAL_BASE_URI} | ||
/> | ||
); | ||
}, | ||
); | ||
|
||
export default NewPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters