diff --git a/frontend/src/components/common-table-components/saken-gjelder.tsx b/frontend/src/components/common-table-components/saken-gjelder.tsx index 907bdff79..8365b5b6e 100644 --- a/frontend/src/components/common-table-components/saken-gjelder.tsx +++ b/frontend/src/components/common-table-components/saken-gjelder.tsx @@ -40,5 +40,5 @@ export const SakenGjelderFnr = ({ oppgaveId }: Props) => { return ; } - return ; + return ; }; diff --git a/frontend/src/components/documents/new-documents/modal/finish-document/custom-recipients.tsx b/frontend/src/components/documents/new-documents/modal/finish-document/custom-recipients.tsx index 2d6818a83..ecae84180 100644 --- a/frontend/src/components/documents/new-documents/modal/finish-document/custom-recipients.tsx +++ b/frontend/src/components/documents/new-documents/modal/finish-document/custom-recipients.tsx @@ -93,7 +93,7 @@ const Recipients = ({ mottakerList, removeMottakere, changeMottaker, sendErrors, {part.name} - + {part.identifikator === null ? null : } {error === null ? null : ( diff --git a/frontend/src/components/documents/new-documents/modal/finish-document/unreachable-suggested-recipients.tsx b/frontend/src/components/documents/new-documents/modal/finish-document/unreachable-suggested-recipients.tsx index 3b5d573ac..4854b2c94 100644 --- a/frontend/src/components/documents/new-documents/modal/finish-document/unreachable-suggested-recipients.tsx +++ b/frontend/src/components/documents/new-documents/modal/finish-document/unreachable-suggested-recipients.tsx @@ -27,7 +27,7 @@ export const UnreachableSuggestedRecipients = ({ recipients }: RecipientsProps) {recipients.map(({ part, brevmottakertyper, overriddenAddress, handling }) => { - const { id, name, statusList } = part; + const { identifikator, id, name, statusList } = part; const isPerson = part.type === IdType.FNR; const alertText = getUnreachableText(statusList); @@ -40,16 +40,18 @@ export const UnreachableSuggestedRecipients = ({ recipients }: RecipientsProps) {isPerson ? : } - + {(name ?? identifikator === null) ? null : ( + + )} - +
{alertText === null ? null : ( diff --git a/frontend/src/components/oppgavebehandling-controls/external-links.tsx b/frontend/src/components/oppgavebehandling-controls/external-links.tsx index 7e5884ba8..7ed968528 100644 --- a/frontend/src/components/oppgavebehandling-controls/external-links.tsx +++ b/frontend/src/components/oppgavebehandling-controls/external-links.tsx @@ -15,7 +15,7 @@ interface LinkProps { } export const Modia = ({ sakenGjelder }: LinkProps) => { - const url = `${EXTERNAL_URL_MODIA}/person/${sakenGjelder.id}`; + const url = `${EXTERNAL_URL_MODIA}/person/${sakenGjelder.identifikator}`; const eventName = 'modia-link'; const appName = 'Modia'; diff --git a/frontend/src/components/oppgavebehandling-controls/user-info.tsx b/frontend/src/components/oppgavebehandling-controls/user-info.tsx index 95925ba85..947ec6841 100644 --- a/frontend/src/components/oppgavebehandling-controls/user-info.tsx +++ b/frontend/src/components/oppgavebehandling-controls/user-info.tsx @@ -11,7 +11,11 @@ export const UserInfo = ({ sakenGjelder, id }: IOppgavebehandlingBase) => ( {sakenGjelder.name ?? '-'} - + diff --git a/frontend/src/components/oppgavestyring/use-tildel.tsx b/frontend/src/components/oppgavestyring/use-tildel.tsx index ca7b4e459..fea322efc 100644 --- a/frontend/src/components/oppgavestyring/use-tildel.tsx +++ b/frontend/src/components/oppgavestyring/use-tildel.tsx @@ -119,7 +119,7 @@ const Tildelt = ({ timestamp, }: TildeltProps) => { const { user } = useContext(StaticDataContext); - const sakenGjelderText = `${sakenGjelder.name ?? 'Navn mangler'} (${sakenGjelder.id})`; + const sakenGjelderText = `${sakenGjelder.name ?? 'Navn mangler'} (${sakenGjelder.identifikator})`; const toSaksbehandlerText = formatEmployeeNameAndIdFallback(toSaksbehandler, 'ukjent saksbehandler'); const fromSaksbehandlerText = fromSaksbehandler === null ? '' : ` fra ${formatEmployeeNameAndId(fromSaksbehandler)}`; const [tildel] = useTildel(oppgaveId, oppgaveType, ytelseId); @@ -172,7 +172,7 @@ const Tildelt = ({ }; const Fradelt = ({ oppgaveId, sakenGjelder, fromSaksbehandler, oppgaveType, ytelseId }: Props) => { - const sakenGjelderText = `${sakenGjelder.name ?? 'Navn mangler'} (${sakenGjelder.id})`; + const sakenGjelderText = `${sakenGjelder.name ?? 'Navn mangler'} (${sakenGjelder.identifikator})`; const fromSaksbehandlerText = formatEmployeeNameAndIdFallback(fromSaksbehandler, ''); const [tildel] = useTildel(oppgaveId, oppgaveType, ytelseId); diff --git a/frontend/src/components/part/edit-part.tsx b/frontend/src/components/part/edit-part.tsx index f83c2f1ab..dac9cd4fb 100644 --- a/frontend/src/components/part/edit-part.tsx +++ b/frontend/src/components/part/edit-part.tsx @@ -29,7 +29,7 @@ export const EditPart = ({ onChange, autoFocus, onClose, id, ...props }: EditPar setError(inputError); if (inputError === undefined && oppgave !== undefined) { - search({ identifikator: value, sakenGjelderId: oppgave.sakenGjelder.id, ytelseId: oppgave.ytelseId }); + search({ identifikator: value, sakenGjelderId: oppgave.sakenGjelder.identifikator, ytelseId: oppgave.ytelseId }); } }; @@ -55,7 +55,7 @@ export const EditPart = ({ onChange, autoFocus, onClose, id, ...props }: EditPar setError(undefined); if (inputError === undefined && oppgave !== undefined) { - search({ identifikator: value, sakenGjelderId: oppgave.sakenGjelder.id, ytelseId: oppgave.ytelseId }); + search({ identifikator: value, sakenGjelderId: oppgave.sakenGjelder.identifikator, ytelseId: oppgave.ytelseId }); } }, [oppgave, rawValue, search]); diff --git a/frontend/src/components/part/fullmektig/fullmektig.tsx b/frontend/src/components/part/fullmektig/fullmektig.tsx index 6c2f168f8..7b79a947b 100644 --- a/frontend/src/components/part/fullmektig/fullmektig.tsx +++ b/frontend/src/components/part/fullmektig/fullmektig.tsx @@ -2,10 +2,11 @@ import { BehandlingSection } from '@app/components/behandling/behandlingsdetalje import { CopyButton } from '@app/components/copy-button/copy-button'; import { CopyIdButton } from '@app/components/copy-button/copy-id-button'; import { EditPart } from '@app/components/part/edit-part'; +import { NO_FULLMEKTIG_ID } from '@app/components/part/fullmektig/types'; import { WithoutId } from '@app/components/part/fullmektig/without-id'; import { useOppgaveId } from '@app/hooks/oppgavebehandling/use-oppgave-id'; import { useUpdateFullmektigMutation } from '@app/redux-api/oppgaver/mutations/behandling'; -import { FULLMEKTIG_WITHOUT_ID, type IFullmektig } from '@app/types/oppgave-common'; +import type { IFullmektig } from '@app/types/oppgave-common'; import { ArrowUndoIcon, PencilIcon, TrashFillIcon, XMarkIcon } from '@navikt/aksel-icons'; import { Button, HStack, ToggleGroup, VStack } from '@navikt/ds-react'; import { skipToken } from '@reduxjs/toolkit/query'; @@ -25,7 +26,7 @@ const getInitialValue = (part: IFullmektig | null): Option => { return Option.ID; } - return part.id === null ? Option.ADDRESS : Option.ID; + return part.identifikator === null ? Option.ADDRESS : Option.ID; }; interface Props { @@ -35,7 +36,9 @@ interface Props { export const Fullmektig = ({ part }: Props) => { const [isEditing, setIsEditing] = useState(false); const [value, setValue] = useState(getInitialValue(part)); - const [updateFullmektig, { isLoading }] = useUpdateFullmektigMutation({ fixedCacheKey: FULLMEKTIG_WITHOUT_ID }); + const [updateFullmektig, { isLoading }] = useUpdateFullmektigMutation({ + fixedCacheKey: part?.id ?? NO_FULLMEKTIG_ID, + }); const oppgaveId = useOppgaveId(); const onClose = () => setIsEditing(false); @@ -49,11 +52,11 @@ export const Fullmektig = ({ part }: Props) => { ) : ( 'Ikke satt' )} - {typeof part?.id === 'string' ? : null} + {typeof part?.identifikator === 'string' ? : null} - {isEditing ? : null} + {isEditing && part !== null ? : null} setIsEditing(!isEditing)} isEditing={isEditing} /> @@ -95,9 +98,9 @@ export const Fullmektig = ({ part }: Props) => { ); }; -const Delete = ({ onClose }: { onClose: () => void }) => { +const Delete = ({ onClose, id }: { onClose: () => void; id: string }) => { const [showConfirm, setShowConfirm] = useState(false); - const [updateFullmektig, { isLoading }] = useUpdateFullmektigMutation({ fixedCacheKey: FULLMEKTIG_WITHOUT_ID }); + const [updateFullmektig, { isLoading }] = useUpdateFullmektigMutation({ fixedCacheKey: id }); const oppgaveId = useOppgaveId(); if (oppgaveId === skipToken) { diff --git a/frontend/src/components/part/fullmektig/types.ts b/frontend/src/components/part/fullmektig/types.ts new file mode 100644 index 000000000..ddfb2a8de --- /dev/null +++ b/frontend/src/components/part/fullmektig/types.ts @@ -0,0 +1 @@ +export const NO_FULLMEKTIG_ID = 'NO_FULLMEKTIG_ID'; diff --git a/frontend/src/components/part/fullmektig/without-id.tsx b/frontend/src/components/part/fullmektig/without-id.tsx index 649ae9aae..f41620c25 100644 --- a/frontend/src/components/part/fullmektig/without-id.tsx +++ b/frontend/src/components/part/fullmektig/without-id.tsx @@ -1,9 +1,10 @@ import { StaticDataContext } from '@app/components/app/static-data-context'; import { Country } from '@app/components/documents/new-documents/modal/finish-document/address/country/country'; import { Postnummer } from '@app/components/documents/new-documents/modal/finish-document/address/postnummer'; +import { NO_FULLMEKTIG_ID } from '@app/components/part/fullmektig/types'; import { useOppgaveId } from '@app/hooks/oppgavebehandling/use-oppgave-id'; import { useUpdateFullmektigMutation } from '@app/redux-api/oppgaver/mutations/behandling'; -import { FULLMEKTIG_WITHOUT_ID, type IFullmektig, Utsendingskanal } from '@app/types/oppgave-common'; +import { type IFullmektig, Utsendingskanal } from '@app/types/oppgave-common'; import { Box, type BoxProps, Button, ErrorSummary, HStack, Tag, TextField, VStack } from '@navikt/ds-react'; import { skipToken } from '@reduxjs/toolkit/query'; import { useContext, useState } from 'react'; @@ -16,7 +17,7 @@ interface Props { // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ¯\_(ツ)_/¯ export const WithoutId = ({ part, onClose }: Props) => { const [setFullmektig, { isLoading, isError }] = useUpdateFullmektigMutation({ - fixedCacheKey: FULLMEKTIG_WITHOUT_ID, + fixedCacheKey: part?.id ?? NO_FULLMEKTIG_ID, }); const [name, setName] = useState(part?.name ?? ''); @@ -241,7 +242,7 @@ const RequiredTag = ({ children }: { children: string }) => ( ); const DEFAULT_PROPS = { - id: FULLMEKTIG_WITHOUT_ID, + identifikator: null, type: null, statusList: [], utsendingskanal: Utsendingskanal.SENTRAL_UTSKRIFT, diff --git a/frontend/src/components/part/lookup.tsx b/frontend/src/components/part/lookup.tsx index fc5e651a7..d2a0f0bc2 100644 --- a/frontend/src/components/part/lookup.tsx +++ b/frontend/src/components/part/lookup.tsx @@ -38,7 +38,13 @@ const Result = ({ part, isLoading, onChange, buttonText = 'Bruk', allowUnreachab return ( - {part.name} ({part.type === IdType.FNR ? formatFoedselsnummer(part.id) : formatOrgNum(part.id)}) + {part.name} + {''} + {part.identifikator !== null ? ( + <> + ({part.type === IdType.FNR ? formatFoedselsnummer(part.identifikator) : formatOrgNum(part.identifikator)}) + + ) : null} diff --git a/frontend/src/components/part/part.tsx b/frontend/src/components/part/part.tsx index 1a2765b49..c7080dc29 100644 --- a/frontend/src/components/part/part.tsx +++ b/frontend/src/components/part/part.tsx @@ -68,7 +68,7 @@ export const Part = ({ part, isDeletable, label, onChange, isLoading }: Deletabl ) : ( )} - + {part.identifikator === null ? null : } diff --git a/frontend/src/components/relevant-oppgaver/relevant-oppgaver.tsx b/frontend/src/components/relevant-oppgaver/relevant-oppgaver.tsx index 796d4b3f8..a08687bb0 100644 --- a/frontend/src/components/relevant-oppgaver/relevant-oppgaver.tsx +++ b/frontend/src/components/relevant-oppgaver/relevant-oppgaver.tsx @@ -42,7 +42,7 @@ export const RelevantOppgaver = ({ oppgaveId, size = 'small' }: Props) => { return null; } - const fnr = formatFoedselsnummer(sakenGjelder?.id); + const fnr = formatFoedselsnummer(sakenGjelder?.identifikator); const name = sakenGjelder?.name ?? ''; const heading = `${totalCount} andre pågående oppgaver for ${name} (${fnr})`; const tooltip = totalCount === 1 ? '1 annen pågående oppgave' : `${totalCount} andre pågående oppgaver`; diff --git a/frontend/src/plate/components/label-content.tsx b/frontend/src/plate/components/label-content.tsx index 8e833b550..68eb130ad 100644 --- a/frontend/src/plate/components/label-content.tsx +++ b/frontend/src/plate/components/label-content.tsx @@ -98,7 +98,7 @@ const useContent = (source: LabelContentSource): string | null => { } if (source === LabelContentSource.SAKEN_GJELDER_FNR) { - return `${formatFoedselsnummer(oppgave.sakenGjelder.id)}\n`; + return `${formatFoedselsnummer(oppgave.sakenGjelder.identifikator)}\n`; } if (source === LabelContentSource.SAKSNUMMER) { @@ -108,7 +108,7 @@ const useContent = (source: LabelContentSource): string | null => { const { klager, sakenGjelder } = oppgave; if (source === LabelContentSource.SAKEN_GJELDER_IF_DIFFERENT_FROM_KLAGER_NAME) { - if (klager.id !== sakenGjelder.id) { + if (klager.identifikator !== sakenGjelder.identifikator) { return `${sakenGjelder.name ?? '-'}\n`; } @@ -116,7 +116,7 @@ const useContent = (source: LabelContentSource): string | null => { } if (source === LabelContentSource.KLAGER_IF_EQUAL_TO_SAKEN_GJELDER_NAME) { - if (klager.id === sakenGjelder.id) { + if (klager.identifikator === sakenGjelder.identifikator) { return `${klager.name ?? '-'}\n`; } @@ -124,7 +124,7 @@ const useContent = (source: LabelContentSource): string | null => { } if (source === LabelContentSource.KLAGER_IF_DIFFERENT_FROM_SAKEN_GJELDER_NAME) { - if (klager.id !== sakenGjelder.id) { + if (klager.identifikator !== sakenGjelder.identifikator) { return `${klager.name ?? '-'}\n`; } diff --git a/frontend/src/redux-api/oppgaver/mutations/behandling.ts b/frontend/src/redux-api/oppgaver/mutations/behandling.ts index ed571be61..67e55ccb8 100644 --- a/frontend/src/redux-api/oppgaver/mutations/behandling.ts +++ b/frontend/src/redux-api/oppgaver/mutations/behandling.ts @@ -8,6 +8,7 @@ import { getFullmektigBody, getFullmektigMessage } from '@app/redux-api/oppgaver import { oppgaveDataQuerySlice } from '@app/redux-api/oppgaver/queries/oppgave-data'; import { reduxStore } from '@app/redux/configure-store'; import { isApiRejectionError } from '@app/types/errors'; +import type { IFullmektig } from '@app/types/oppgave-common'; import type { IOppgavebehandling } from '@app/types/oppgavebehandling/oppgavebehandling'; import type { IFinishOppgavebehandlingParams, @@ -121,7 +122,8 @@ const behandlingerMutationSlice = oppgaverApi.injectEndpoints({ body: getFullmektigBody(fullmektig), }), onQueryStarted: async ({ oppgaveId, fullmektig }, { queryFulfilled }) => { - const undo = update(oppgaveId, { prosessfullmektig: fullmektig }); + const fm: IFullmektig | null = fullmektig === null ? null : { ...fullmektig, id: fullmektig.id ?? 'temp' }; + const undo = update(oppgaveId, { prosessfullmektig: fm }); try { const { data } = await queryFulfilled; @@ -144,7 +146,7 @@ const behandlingerMutationSlice = oppgaverApi.injectEndpoints({ query: ({ oppgaveId, klager }) => ({ url: `/kabal-api/behandlinger/${oppgaveId}/klager`, method: 'PUT', - body: { identifikator: klager?.id ?? null }, + body: { identifikator: klager?.identifikator ?? null }, // TODO double check }), onQueryStarted: async ({ oppgaveId, klager }, { queryFulfilled }) => { const undo = update(oppgaveId, { klager }); @@ -152,10 +154,10 @@ const behandlingerMutationSlice = oppgaverApi.injectEndpoints({ try { const { data } = await queryFulfilled; update(oppgaveId, data); - toast.success(`Klager endret til ${klager.name} (${formatIdNumber(klager.id)})`); + toast.success(`Klager endret til ${klager.name} (${formatIdNumber(klager.identifikator)})`); } catch (e) { undo(); - const message = 'Kunne ikke endre fullmektig.'; + const message = 'Kunne ikke endre klager.'; if (isApiRejectionError(e)) { apiErrorToast(message, e.error); diff --git a/frontend/src/redux-api/oppgaver/mutations/documents.ts b/frontend/src/redux-api/oppgaver/mutations/documents.ts index cd02a92b4..7236fed52 100644 --- a/frontend/src/redux-api/oppgaver/mutations/documents.ts +++ b/frontend/src/redux-api/oppgaver/mutations/documents.ts @@ -548,7 +548,7 @@ const documentsMutationSlice = oppgaverApi.injectEndpoints({ setAvsender: builder.mutation({ query: ({ oppgaveId, dokumentId, avsender }) => ({ url: `/kabal-api/behandlinger/${oppgaveId}/dokumenter/${dokumentId}/avsender`, - body: { id: avsender.id }, + body: { id: avsender.identifikator }, // TODO: double check this method: 'PUT', }), onQueryStarted: async ({ dokumentId, avsender, oppgaveId }, { queryFulfilled }) => { diff --git a/frontend/src/redux-api/oppgaver/mutations/fullmektig-helpers.tsx b/frontend/src/redux-api/oppgaver/mutations/fullmektig-helpers.tsx index a82fcc594..738b020c9 100644 --- a/frontend/src/redux-api/oppgaver/mutations/fullmektig-helpers.tsx +++ b/frontend/src/redux-api/oppgaver/mutations/fullmektig-helpers.tsx @@ -1,19 +1,17 @@ import { formatIdNumber } from '@app/functions/format-id'; import type { IAddress } from '@app/types/documents/recipients'; -import { FULLMEKTIG_WITHOUT_ID, type IFullmektig } from '@app/types/oppgave-common'; +import type { ISetFullmektigParams } from '@app/types/oppgavebehandling/params'; import { styled } from 'styled-components'; -export const getFullmektigMessage = (fullmektig: IFullmektig | null) => { +export const getFullmektigMessage = (fullmektig: ISetFullmektigParams['fullmektig']) => { if (fullmektig === null) { return 'Fullmektig fjernet'; } - const { name, id, address } = fullmektig; + const { name, identifikator, address } = fullmektig; - const hasId = id !== FULLMEKTIG_WITHOUT_ID; - - if (hasId) { - return `Fullmektig satt til ${fullmektig.name} (${formatIdNumber(fullmektig.id)})`; + if (identifikator !== null) { + return `Fullmektig satt til ${fullmektig.name} (${formatIdNumber(fullmektig.identifikator)})`; } return address === null ? ( @@ -64,16 +62,14 @@ const addressToString = (address: IAddress): string => { return value; }; -export const getFullmektigBody = (fullmektig: IFullmektig | null) => { +export const getFullmektigBody = (fullmektig: ISetFullmektigParams['fullmektig']) => { if (fullmektig === null) { return { fullmektig: null, address: null, name: null }; } - const { address, name, id: identifikator } = fullmektig; - - const hasId = identifikator !== FULLMEKTIG_WITHOUT_ID; + const { address, name, identifikator } = fullmektig; - if (hasId) { + if (identifikator !== null) { return { identifikator, address: null, name: null }; } diff --git a/frontend/src/types/documents/params.ts b/frontend/src/types/documents/params.ts index d646f3560..bd8b1ec0d 100644 --- a/frontend/src/types/documents/params.ts +++ b/frontend/src/types/documents/params.ts @@ -41,6 +41,7 @@ interface InputMottaker { id: string; handling: HandlingEnum; overriddenAddress: IAddress | null; + navn: string | null; } export interface ISetMottakerListParams extends IDocumentParams { @@ -54,5 +55,6 @@ export const mottakerToInputMottaker = (mottaker: IMottaker): InputMottaker => { id: part.id, handling, overriddenAddress, + navn: part.name, }; }; diff --git a/frontend/src/types/oppgave-common.ts b/frontend/src/types/oppgave-common.ts index 6086964a0..e80bde27f 100644 --- a/frontend/src/types/oppgave-common.ts +++ b/frontend/src/types/oppgave-common.ts @@ -46,6 +46,7 @@ export interface SearchPersonResponse { } export interface IPartBase { + id: string; name: string | null; address: IAddress | null; utsendingskanal: Utsendingskanal; @@ -109,27 +110,25 @@ export type IOrganizationStatus = }; export interface IPersonPart extends IPartBase { - id: string; + identifikator: string; type: IdType.FNR; statusList: IPersonStatus[]; } export interface IOrganizationPart extends IPartBase { - id: string; + identifikator: string; type: IdType.ORGNR; statusList: IOrganizationStatus[]; } -export const FULLMEKTIG_WITHOUT_ID = 'FULLMEKTIG_WITHOUT_ID'; - export interface IPersonFullmektig extends IPartBase { - id: string | typeof FULLMEKTIG_WITHOUT_ID; + identifikator: string | null; type: IdType.FNR | null; statusList: IPersonStatus[] | null; } export interface IOrganizationFullmektig extends IPartBase { - id: string | typeof FULLMEKTIG_WITHOUT_ID; + identifikator: string | null; type: IdType.ORGNR | null; statusList: IOrganizationStatus[] | null; } diff --git a/frontend/src/types/oppgavebehandling/params.ts b/frontend/src/types/oppgavebehandling/params.ts index 898a3ceca..ba81472d1 100644 --- a/frontend/src/types/oppgavebehandling/params.ts +++ b/frontend/src/types/oppgavebehandling/params.ts @@ -52,7 +52,7 @@ export interface ISetFlowStateParams extends IOppgavebehandlingBaseParams { } export interface ISetFullmektigParams extends IOppgavebehandlingBaseParams { - fullmektig: IFullmektig | null; + fullmektig: (Omit & { id?: string }) | null; } export interface ISetKlagerParams extends IOppgavebehandlingBaseParams {