diff --git a/apps/concept-catalog/pages/[catalogId]/change-requests/[changeRequestId]/_change-request-form.tsx b/apps/concept-catalog/pages/[catalogId]/change-requests/[changeRequestId]/_change-request-form.tsx index 7acda5dac..e8dc60a80 100644 --- a/apps/concept-catalog/pages/[catalogId]/change-requests/[changeRequestId]/_change-request-form.tsx +++ b/apps/concept-catalog/pages/[catalogId]/change-requests/[changeRequestId]/_change-request-form.tsx @@ -1,7 +1,7 @@ -import { Checkbox } from '@digdir/design-system-react'; +import { Checkbox, Heading, Textfield } from '@digdir/design-system-react'; import { BreadcrumbType, Breadcrumbs, Button, PageBanner } from '@catalog-frontend/ui'; import { useCatalogDesign } from '../../../../context/catalog-design'; -import { localization as loc, getTranslateText as translate } from '@catalog-frontend/utils'; +import { localization as loc } from '@catalog-frontend/utils'; import styles from './change-request-page.module.css'; import { useState } from 'react'; import { Concept, ISOLanguage } from '@catalog-frontend/types'; @@ -30,13 +30,14 @@ export const ChangeRequestForm = ({ const changeRequestId = changeRequest.id; const catalogId = organization?.organizationId; const pageSubtitle = organization?.name ?? organization.id; + const [changeRequestTitle, setChangeRequestTitle] = useState(changeRequest.title ?? ''); const [selectedLanguages, setSelectedLanguages] = useState(['nb', 'nn', 'en']); const [isSubmitting, setIsSubmitting] = useState(false); const handleSubmit = (values: Concept) => { setIsSubmitting(true); - submitHandler(values); + submitHandler(values, changeRequestTitle); setIsSubmitting(false); }; @@ -48,16 +49,6 @@ export const ChangeRequestForm = ({ setSelectedLanguages(newSelectedLangs as ISOLanguage[]); }; - const getTitle = (text: string | string[]) => (text ? text : loc.concept.noName); - let changeRequestTitle = ''; - if (changeRequestId) { - changeRequestTitle = changeRequestAsConcept?.anbefaltTerm?.navn - ? getTitle(translate(changeRequestAsConcept?.anbefaltTerm?.navn)) - : changeRequestId; - } else { - changeRequestTitle = loc.suggestionForNewConcept; - } - const breadcrumbList = changeRequestId ? ([ { @@ -110,7 +101,20 @@ export const ChangeRequestForm = ({ ))} -

{changeRequestTitle}

+ + {changeRequestTitle} + + setChangeRequestTitle(e.target.value)} + /> { diff --git a/apps/concept-catalog/pages/[catalogId]/change-requests/[changeRequestId]/edit.tsx b/apps/concept-catalog/pages/[catalogId]/change-requests/[changeRequestId]/edit.tsx index 7fbe3be47..099471794 100644 --- a/apps/concept-catalog/pages/[catalogId]/change-requests/[changeRequestId]/edit.tsx +++ b/apps/concept-catalog/pages/[catalogId]/change-requests/[changeRequestId]/edit.tsx @@ -28,11 +28,11 @@ const ChangeRequestEditPage = ({ changeRequestId: changeRequest.id, }); - const submitHandler = (values: Concept) => { + const submitHandler = (values: Concept, title: string) => { const changeRequestFromConcept: ChangeRequestUpdateBody = { conceptId: changeRequest.conceptId, operations: jsonpatch.compare(originalConcept, values) as JsonPatchOperation[], - title: '', + title: title, }; changeRequestMutateHook .mutateAsync(changeRequestFromConcept) diff --git a/apps/concept-catalog/pages/[catalogId]/change-requests/new.tsx b/apps/concept-catalog/pages/[catalogId]/change-requests/new.tsx index 3443d5982..01e6b05c8 100644 --- a/apps/concept-catalog/pages/[catalogId]/change-requests/new.tsx +++ b/apps/concept-catalog/pages/[catalogId]/change-requests/new.tsx @@ -17,11 +17,11 @@ const NewConceptSuggestion = ({ }) => { const changeRequestMutateHook = useCreateChangeRequest({ catalogId: organization.organizationId }); - const submitHandler = (values: Concept) => { + const submitHandler = (values: Concept, title: string) => { const changeRequestFromConcept: ChangeRequestUpdateBody = { conceptId: changeRequest.conceptId, operations: jsonpatch.compare(originalConcept, values) as JsonPatchOperation[], - title: '', + title: title, }; changeRequestMutateHook.mutateAsync(changeRequestFromConcept).catch((error) => { alert('Failed to submit change request.'); diff --git a/libs/utils/src/lib/language/nb.ts b/libs/utils/src/lib/language/nb.ts index 856bc2219..a1a928e1a 100644 --- a/libs/utils/src/lib/language/nb.ts +++ b/libs/utils/src/lib/language/nb.ts @@ -34,6 +34,7 @@ export const nb = { unknown: 'Ukjent', showMore: 'Vis flere', showLess: 'Vis færre', + title: 'Tittel', language: { nb: 'Bokmål',