Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Vedlegg bug fix (#490)
Browse files Browse the repository at this point in the history
* Vedlegg bug fix

* pkg upd
  • Loading branch information
poroshinaleksei authored Aug 30, 2023
1 parent 6f16e1f commit 672eec9
Show file tree
Hide file tree
Showing 6 changed files with 264 additions and 295 deletions.
520 changes: 240 additions & 280 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@navikt/sif-common-amplitude": "^2.7.3",
"@navikt/sif-common-core": "^12.0.6",
"@navikt/sif-common-formik": "^23.5.1",
"@navikt/sif-common-forms": "17.7.1",
"@navikt/sif-common-forms": "17.7.2",
"@navikt/sif-common-sentry": "^0.5.5",
"@navikt/sif-common-soknad": "^6.0.1",
"axios": "^0.27.2",
Expand Down Expand Up @@ -56,8 +56,8 @@
},
"devDependencies": {
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
"@babel/plugin-transform-modules-commonjs": "^7.22.5",
"@babel/preset-env": "^7.22.7",
"@babel/plugin-transform-modules-commonjs": "^7.22.11",
"@babel/preset-env": "^7.22.10",
"@babel/preset-react": "^7.22.5",
"@types/enzyme": "^3.10.13",
"@types/intl": "^1.2.0",
Expand Down Expand Up @@ -96,7 +96,7 @@
"ts-jest": "^28.0.8",
"ts-loader": "^9.4.4",
"typescript": "^4.9.5",
"webpack": "^5.88.1",
"webpack": "^5.88.2",
"webpack-dev-server": "^4.15.1"
},
"resolutions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const DokumenterLegeerklæringSummaryView: React.FC = () => {
const intl = useIntl();
const { values } = useFormikContext<SøknadFormData>();

const attachments: Attachment[] = values[SøknadFormField.dokumenterLegeerklæring];
const attachments: Attachment[] = values[SøknadFormField.dokumenterLegeerklæring].filter(
(attachment) => attachment.uploaded === true && attachment.url
);

return (
<Box margin="s">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ const SmittevernDokumenterSummaryView: React.FC = () => {
const intl = useIntl();
const { values } = useFormikContext<SøknadFormData>();

const attachments: Attachment[] = values[SøknadFormField.smittevernDokumenter];

const attachments: Attachment[] = values[SøknadFormField.smittevernDokumenter].filter(
(attachment) => attachment.uploaded === true && attachment.url
);
return (
<SummaryBlock header={intlHelper(intl, 'step.oppsummering.smittevern.bekreftelse.header')}>
{attachments.length > 0 ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ const StengtBhgSkoleDokumenterSummaryView: React.FC = () => {
const intl = useIntl();
const { values } = useFormikContext<SøknadFormData>();

const attachments: Attachment[] = values[SøknadFormField.dokumenterStengtBkgSkole];

const attachments: Attachment[] = values[SøknadFormField.dokumenterStengtBkgSkole].filter(
(attachment) => attachment.uploaded === true && attachment.url
);
return (
<SummaryBlock header={intlHelper(intl, 'step.oppsummering.stengtBhgSkole.bekreftelse.header')}>
{attachments.length > 0 ? (
Expand Down
17 changes: 11 additions & 6 deletions src/app/utils/formToApiMaps/mapVedleggToApiData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Utbetalingsårsak,
} from '../../types/ArbeidsforholdTypes';
import { getAttachmentURLBackend } from '../attachmentUtilsAuthToken';
import { attachmentUploadHasFailed } from '@navikt/sif-common-core/lib/utils/attachmentUtils';

const skalInkludereVedleggFraArbeidsforhold = (arbeidsforhold: ArbeidsforholdFormData): boolean => {
if (
Expand All @@ -31,12 +32,16 @@ function notEmpty<TValue>(value: TValue | null | undefined): value is TValue {
}

export const listOfAttachmentsToListOfUrlStrings = (attachments: Attachment[]): string[] => {
return attachments
.map((attachment: Attachment) => {
const attachmentUrl = getAttachmentURLBackend(attachment.url);
return attachmentUrl;
})
.filter(notEmpty);
const apiData: string[] = [];
attachments
.filter((attachment) => !attachmentUploadHasFailed(attachment))
.forEach((a) => {
if (a.url) {
const attachmentUrl = getAttachmentURLBackend(a.url);
apiData.push(attachmentUrl);
}
});
return apiData;
};

export const listOfAttachmentsToListOfDocumentName = (attachments: Attachment[]): string[] => {
Expand Down

0 comments on commit 672eec9

Please sign in to comment.