From 6e6de6f16b80ae1d2f67776b00cb9ded691977fb Mon Sep 17 00:00:00 2001 From: ramziabuqassim Date: Thu, 4 Apr 2024 14:06:32 +0200 Subject: [PATCH] =?UTF-8?q?innsending=20av=20personhendelser=20tar=20en=20?= =?UTF-8?q?fraOgMed=20m=C3=A5ned?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/driftApi.ts | 12 ++++++++++-- .../Personhendelser.module.less | 2 +- .../personhendelser/Personhendelser.tsx | 19 +++++++++++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/api/driftApi.ts b/src/api/driftApi.ts index 8b67643b7..58255da67 100644 --- a/src/api/driftApi.ts +++ b/src/api/driftApi.ts @@ -126,8 +126,12 @@ export async function sendUtbetalingsIder(args: { }); } -export async function sendPersonhendelser(args: { hendelser: File }): Promise> { +export async function sendPersonhendelser(args: { + fraOgMed: string; + hendelser: File; +}): Promise> { const formData = new FormData(); + formData.append('fraOgMed', args.fraOgMed); formData.append('file', args.hendelser); return apiClient({ @@ -137,8 +141,12 @@ export async function sendPersonhendelser(args: { hendelser: File }): Promise> { +export async function dryRunPersonhendelser(args: { + fraOgMed: string; + hendelser: File; +}): Promise> { const formData = new FormData(); + formData.append('fraOgMed', args.fraOgMed); formData.append('file', args.hendelser); return apiClient({ diff --git a/src/pages/drift/components/personhendelser/Personhendelser.module.less b/src/pages/drift/components/personhendelser/Personhendelser.module.less index 02dc432fd..d2e5f46da 100644 --- a/src/pages/drift/components/personhendelser/Personhendelser.module.less +++ b/src/pages/drift/components/personhendelser/Personhendelser.module.less @@ -13,5 +13,5 @@ .panelInnholdContainer { display: flex; flex-direction: column; - gap: @spacing-s; + gap: @spacing; } diff --git a/src/pages/drift/components/personhendelser/Personhendelser.tsx b/src/pages/drift/components/personhendelser/Personhendelser.tsx index 3b0eecadc..6cbf520d2 100644 --- a/src/pages/drift/components/personhendelser/Personhendelser.tsx +++ b/src/pages/drift/components/personhendelser/Personhendelser.tsx @@ -4,8 +4,10 @@ import { useState } from 'react'; import * as driftApi from '~src/api/driftApi'; import ApiErrorAlert from '~src/components/apiErrorAlert/ApiErrorAlert'; +import { MonthPicker } from '~src/components/inputs/datePicker/DatePicker'; import { useApiCall } from '~src/lib/hooks'; import { Nullable } from '~src/lib/types'; +import { toIsoDateOnlyString } from '~src/utils/date/dateUtils'; import styles from './Personhendelser.module.less'; @@ -31,6 +33,7 @@ const Personhendelser = () => { const PersonhendelserModal = (props: { visModal: boolean; onClose: () => void }) => { const [sendPersonhendelserStatus, sendPersonHendelser] = useApiCall(driftApi.sendPersonhendelser); const [dryRunStatus, dryRun] = useApiCall(driftApi.dryRunPersonhendelser); + const [fraOgMed, setFraOgMed] = useState>(null); const [personhendelserCSV, setPersonhendelserCSV] = useState>(null); const [personhendelserCSVDry, setPersonhendelserCSVDry] = useState>(null); @@ -39,14 +42,22 @@ const PersonhendelserModal = (props: { visModal: boolean; onClose: () => void }) console.log('No file selected'); return; } - sendPersonHendelser({ hendelser: personhendelserCSV }); + if (!fraOgMed) { + console.log('No date selected'); + return; + } + sendPersonHendelser({ fraOgMed: toIsoDateOnlyString(fraOgMed), hendelser: personhendelserCSV }); }; const handleDryRun = () => { if (!personhendelserCSVDry) { console.log('No file selected'); return; } - dryRun({ hendelser: personhendelserCSVDry }); + if (!fraOgMed) { + console.log('No date selected'); + return; + } + dryRun({ fraOgMed: toIsoDateOnlyString(fraOgMed), hendelser: personhendelserCSVDry }); }; return ( @@ -60,10 +71,12 @@ const PersonhendelserModal = (props: { visModal: boolean; onClose: () => void }) +
+ (e.target.files ? setPersonhendelserCSVDry(e.target.files[0]) : null)} @@ -78,8 +91,10 @@ const PersonhendelserModal = (props: { visModal: boolean; onClose: () => void })
+
+ (e.target.files ? setPersonhendelserCSV(e.target.files[0]) : null)}