Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build fix #8

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 36 additions & 22 deletions pages/extra/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import { PageFooterTemplate } from "../../src/components/huwelijksplanner/PageFooterTemplate";
import { PageHeaderTemplate } from "../../src/components/huwelijksplanner/PageHeaderTemplate";
import { MarriageOptionsContext } from "../../src/context/MarriageOptionsContext";
import { HuwelijkService } from "../../src/generated";

Check warning on line 31 in pages/extra/index.tsx

View workflow job for this annotation

GitHub Actions / continuous-integration

'HuwelijkService' is defined but never used
import { useSdgProductGetCollection } from "../../src/hooks/useSdgProductGetCollection";

export const getServerSideProps = async ({ locale }: { locale: string }) => ({
Expand All @@ -48,38 +48,57 @@
const [certificate, productLoading] = useSdgProductGetCollection("trouwboekje");
const { register, handleSubmit } = useForm<FormData>();
const reservation = marriageOptions.reservation;
const [saving, setSaving] = useState(false);

Check warning on line 51 in pages/extra/index.tsx

View workflow job for this annotation

GitHub Actions / continuous-integration

'saving' is assigned a value but never used

const certificateRadioName = "marriage-certificate-kind";
const noCertificateId = useId();

const getCosts = (id: any) => {

Check warning on line 56 in pages/extra/index.tsx

View workflow job for this annotation

GitHub Actions / continuous-integration

Unexpected any. Specify a different type
switch (id) {
case "998206bc-d530-4291-89eb-02ebe21a7289":
return parseFloat(marriageOptions.reservation?.["ceremony-price-amount"] ?? "0") + 32.5;
case "22f40941-72ff-4825-87f4-1a67d6daf7f2":
return parseFloat(marriageOptions.reservation?.["ceremony-price-amount"] ?? "0") + 32.5;
case "c8c733e1-13c8-4d96-a388-de30d787f15b":
return parseFloat(marriageOptions.reservation?.["ceremony-price-amount"] ?? "0") + 30;
default:
return parseFloat(marriageOptions.reservation?.["ceremony-price-amount"] ?? "0") + 0;
}
};

const onMarriageCertificateKindSubmit = (formData: FormData) => {
if (formData["marriage-certificate-kind"] === "none") {
push("/voorgenomen-huwelijk/checken");
return;
}

const test = getCosts(formData).toString();

if (!reservation) return;

setSaving(true);

HuwelijkService.huwelijkPatchItem({
id: marriageOptions.id as string,
requestBody: {
producten: [formData["marriage-certificate-kind"]],
setMarriageOptions({
...marriageOptions,
reservation: {
...reservation,
"ceremony-price-amount": test,
},
})
.then(({ kosten }) => {
setMarriageOptions({
...marriageOptions,
reservation: {
...reservation,
"ceremony-price-amount": kosten ? kosten.replace("EUR ", "") : "-",
},
});
push("/voorgenomen-huwelijk/checken");
})
.finally(() => setSaving(false));
});

setSaving(false);
push("/voorgenomen-huwelijk/checken");

// HuwelijkService.huwelijkPatchItem({
// id: marriageOptions.id as string,
// requestBody: {
// producten: [formData["marriage-certificate-kind"]],
// },
// })
// .then(({ kosten }) => {

// })
// .finally(() => setSaving(false));
};

return (
Expand Down Expand Up @@ -152,12 +171,7 @@
)}
</section>
<ButtonGroup>
<Button
disabled={saving || productLoading}
type="submit"
name="type"
appearance="primary-action-button"
>
<Button type="submit" name="type" appearance="primary-action-button">
Bevestigen
</Button>
</ButtonGroup>
Expand Down
2 changes: 1 addition & 1 deletion pages/gateway-login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

const { register, handleSubmit } = useForm();

const onSubmit = (data: any) => {

Check warning on line 18 in pages/gateway-login/index.tsx

View workflow job for this annotation

GitHub Actions / continuous-integration

Unexpected any. Specify a different type
setError(false);
setIsLoading(true);

Expand All @@ -23,11 +23,11 @@

__request(OpenAPI, {
method: "POST",
url: "/users/login",
url: "/api/users/login",
body: data,
mediaType: "application/json",
})
.then((res: any) => {

Check warning on line 30 in pages/gateway-login/index.tsx

View workflow job for this annotation

GitHub Actions / continuous-integration

Unexpected any. Specify a different type
authenticate(res.jwtToken);

if (assentId) {
Expand Down
193 changes: 106 additions & 87 deletions pages/persoonsgegevens/[person].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@
import React, { ChangeEventHandler, useCallback, useContext, useEffect, useId, useRef, useState } from "react";
import { useForm, UseFormRegister } from "react-hook-form";
import Skeleton from "react-loading-skeleton";
import { v4 as uuidv4 } from "uuid";
import { Aside, Checkbox2, PageContentMain, ReservationCard } from "../../src/components";
import { AddressDataList } from "../../src/components/huwelijksplanner/AddressDataList";
import { PageFooterTemplate } from "../../src/components/huwelijksplanner/PageFooterTemplate";
import { PageHeaderTemplate } from "../../src/components/huwelijksplanner/PageHeaderTemplate";
import { PersonalDataList } from "../../src/components/huwelijksplanner/PersonalDataList";
import { MarriageOptionsContext } from "../../src/context/MarriageOptionsContext";
import { HuwelijkWithId } from "../../src/data/huwelijksplanner-state";

Check warning on line 37 in pages/persoonsgegevens/[person].tsx

View workflow job for this annotation

GitHub Actions / continuous-integration

'HuwelijkWithId' is defined but never used
import { resolveEmbedded } from "../../src/embedded";

Check warning on line 38 in pages/persoonsgegevens/[person].tsx

View workflow job for this annotation

GitHub Actions / continuous-integration

'resolveEmbedded' is defined but never used
import { AssentService, HuwelijkService } from "../../src/generated";

Check warning on line 39 in pages/persoonsgegevens/[person].tsx

View workflow job for this annotation

GitHub Actions / continuous-integration

'AssentService' is defined but never used
import { useIngeschrevenpersoonGetByBsn } from "../../src/hooks/useIngeschrevenpersoonGetByBsn";
import { getBsnFromJWT } from "../../src/openapi/authentication";
import { v4 as uuidv4 } from "uuid";

export const getServerSideProps = async ({ locale }: { locale: string }) => ({
props: {
Expand Down Expand Up @@ -99,16 +99,6 @@
};

useEffect(() => {
// console.log(loadingType)
// console.log(loadingCeremonie)
// console.log(loadingMoment)
// console.log(loadingAmbtenaar)
// console.log(loadingLocatie)
// console.log(loadingKosten)
// console.log(loadingPartner)
// console.log(!huwelijkId)
// console.log(loading)

if (
loadingType === true &&
loadingCeremonie === true &&
Expand All @@ -119,7 +109,7 @@
loadingPartner === true &&
!huwelijkId
) {
HuwelijkService.huwelijkGet(huwelijkIdCreate ?? " ").then((response: any) => {
HuwelijkService.huwelijkGet({ id: huwelijkIdCreate ?? " " }).then((response: any) => {
if (!reservation) return;

const partner = response.results.find(
Expand Down Expand Up @@ -148,7 +138,7 @@
setLoading(false);
});
} else {
!huwelijkId && setLoading(true);
if (!huwelijkId) setLoading(true);
}
}, [loadingType, loadingCeremonie, loadingMoment, loadingAmbtenaar, loadingLocatie, loadingKosten, loadingPartner]);

Expand Down Expand Up @@ -179,70 +169,91 @@
startdatum: format(new Date(), "yyyy-MM-dd"),
};

HuwelijkService.huwelijkCreate(postHuwelijk)
HuwelijkService.huwelijkCreate({ requestBody: postHuwelijk })
.then((response) => {
setHuwelijkIdCreate(response.id);

// ID
HuwelijkService.huwelijkPostEigenschap(
response.id ?? "",
"a2f2bce4-3877-4ad9-833e-5241c3a71cab",
productId ?? ""
).finally(() => {
HuwelijkService.huwelijkPostEigenschap({
requestBody: {
zaak: `https://api.huwelijksplanner.online/api/zrc/v1/zaken/${response.id ?? ""}`,
eigenschap:
"https://api.huwelijksplanner.online/api/ztc/v1/eigenschappen/a2f2bce4-3877-4ad9-833e-5241c3a71cab",
waarde: productId ?? "",
},
}).finally(() => {
setLoadingType(true);
});

// Ceremonie
HuwelijkService.huwelijkPostEigenschap(
response.id ?? "",
"d63af89f-0ee7-4b26-b07d-0faf02d34b51",
reservation["ceremony-id"] ?? ""
).finally(() => {
HuwelijkService.huwelijkPostEigenschap({
requestBody: {
zaak: `https://api.huwelijksplanner.online/api/zrc/v1/zaken/${response.id ?? ""}`,
eigenschap:
"https://api.huwelijksplanner.online/api/ztc/v1/eigenschappen/d63af89f-0ee7-4b26-b07d-0faf02d34b51",
waarde: reservation["ceremony-id"] ?? "",
},
}).finally(() => {
setLoadingCeremonie(true);
});

// Moment
HuwelijkService.huwelijkPostEigenschap(
response.id ?? "",
"f81cb98c-233c-4b8d-9de3-4ecc93032012",
reservation["ceremony-start"] ?? ""
).finally(() => {
HuwelijkService.huwelijkPostEigenschap({
requestBody: {
zaak: `https://api.huwelijksplanner.online/api/zrc/v1/zaken/${response.id ?? ""}`,
eigenschap:
"https://api.huwelijksplanner.online/api/ztc/v1/eigenschappen/f81cb98c-233c-4b8d-9de3-4ecc93032012",
waarde: reservation["ceremony-start"] ?? "",
},
}).finally(() => {
setLoadingMoment(true);
});

// Ambtenaar
HuwelijkService.huwelijkPostEigenschap(
response.id ?? "",
"1f8e3903-ca20-4b34-a46a-aef0cc16eb19",
ambtenaar ?? ""
).finally(() => {
HuwelijkService.huwelijkPostEigenschap({
requestBody: {
zaak: `https://api.huwelijksplanner.online/api/zrc/v1/zaken/${response.id ?? ""}`,
eigenschap:
"https://api.huwelijksplanner.online/api/ztc/v1/eigenschappen/1f8e3903-ca20-4b34-a46a-aef0cc16eb19",
waarde: ambtenaar ?? "",
},
}).finally(() => {
setLoadingAmbtenaar(true);
});

// Location
HuwelijkService.huwelijkPostEigenschap(
response.id ?? "",
"745d85cc-8972-43b9-916e-c268bf87d750",
reservation["ceremony-location"] ?? ""
).finally(() => {
HuwelijkService.huwelijkPostEigenschap({
requestBody: {
zaak: `https://api.huwelijksplanner.online/api/zrc/v1/zaken/${response.id ?? ""}`,
eigenschap:
"https://api.huwelijksplanner.online/api/ztc/v1/eigenschappen/745d85cc-8972-43b9-916e-c268bf87d750",
waarde: reservation["ceremony-location"] ?? "",
},
}).finally(() => {
setLoadingLocatie(true);
});

// Kosten
HuwelijkService.huwelijkPostEigenschap(
huwelijkIdCreate ?? "",
"416de8b8-d5d1-4f44-9a1e-1846d552292c",
getCosts(reservation) ?? ""
).finally(() => {
HuwelijkService.huwelijkPostEigenschap({
requestBody: {
zaak: `https://api.huwelijksplanner.online/api/zrc/v1/zaken/${huwelijkIdCreate ?? ""}`,
eigenschap:
"https://api.huwelijksplanner.online/api/ztc/v1/eigenschappen/416de8b8-d5d1-4f44-9a1e-1846d552292c",
waarde: getCosts(reservation) ?? "",
},
}).finally(() => {
setLoadingKosten(true);
});

// Partner
HuwelijkService.huwelijkPostEigenschap(
response.id ?? "",
"4dee2797-1faf-4dc0-95f8-ddc4956302f3",
JSON.stringify(persoonData) ?? ""
).finally(() => {
HuwelijkService.huwelijkPostEigenschap({
requestBody: {
zaak: `https://api.huwelijksplanner.online/api/zrc/v1/zaken/${response.id ?? ""}`,
eigenschap:
"https://api.huwelijksplanner.online/api/ztc/v1/eigenschappen/4dee2797-1faf-4dc0-95f8-ddc4956302f3",
waarde: JSON.stringify(persoonData) ?? "",
},
}).finally(() => {
setLoadingPartner(true);
});
})
Expand All @@ -268,7 +279,7 @@
const onContactDetailsSubmit = (data: FormData) => {
setLoading(true);
if (huwelijkId) {
HuwelijkService.huwelijkGet(huwelijkId.toString()).then((response: any) => {
HuwelijkService.huwelijkGet({ id: huwelijkId.toString() }).then((response: any) => {
if (!reservation) return;

const partnerString = response.results.find(
Expand All @@ -280,32 +291,36 @@
const partner = JSON.parse(partnerString.waarde);

// Partner
HuwelijkService.huwelijkPostEigenschap(
response.id ?? "",
"4dee2797-1faf-4dc0-95f8-ddc4956302f3",
JSON.stringify([
{ partner },
{
...persoonData,
requester: getBsnFromJWT(),

contact: {
subjectIdentificatie: {
inpBsn: getBsnFromJWT(),
HuwelijkService.huwelijkPostEigenschap({
requestBody: {
zaak: `https://api.huwelijksplanner.online/api/zrc/v1/zaken/${response.id ?? ""}`,
eigenschap:
"https://api.huwelijksplanner.online/api/ztc/v1/eigenschappen/4dee2797-1faf-4dc0-95f8-ddc4956302f3",
waarde:
JSON.stringify([
{ partner },
{
...persoonData,
requester: getBsnFromJWT(),

contact: {
subjectIdentificatie: {
inpBsn: getBsnFromJWT(),
},
...mapToContactObject(data.email, data.phoneNumber),
},
results: getResultsChecklist(),
name: "",
},
...mapToContactObject(data.email, data.phoneNumber),
},
results: getResultsChecklist(),
name: "",
},
]) ?? ""
).then(() => {
]) ?? "",
},
}).then(() => {
push(`/persoonsgegevens/succes?huwelijkId=${huwelijkId}`);
setLoading(false);
});
});
} else {
HuwelijkService.huwelijkGet(huwelijkIdCreate ?? " ").then((response: any) => {
HuwelijkService.huwelijkGet({ id: huwelijkIdCreate ?? " " }).then((response: any) => {
if (!reservation) return;

const partnerString = response.results.find(
Expand All @@ -317,23 +332,27 @@
const partner = JSON.parse(partnerString.waarde);

// Partner
HuwelijkService.huwelijkPostEigenschap(
response.id ?? "",
"4dee2797-1faf-4dc0-95f8-ddc4956302f3",
JSON.stringify({
...partner,
requester: getBsnFromJWT(),

contact: {
subjectIdentificatie: {
inpBsn: getBsnFromJWT(),
},
...mapToContactObject(data.email, data.phoneNumber),
},
results: getResultsChecklist(),
name: "",
}) ?? ""
).then(() => {
HuwelijkService.huwelijkPostEigenschap({
requestBody: {
zaak: `https://api.huwelijksplanner.online/api/zrc/v1/zaken/${response.id ?? ""}`,
eigenschap:
"https://api.huwelijksplanner.online/api/ztc/v1/eigenschappen/4dee2797-1faf-4dc0-95f8-ddc4956302f3",
waarde:
JSON.stringify({
...partner,
requester: getBsnFromJWT(),

contact: {
subjectIdentificatie: {
inpBsn: getBsnFromJWT(),
},
...mapToContactObject(data.email, data.phoneNumber),
},
results: getResultsChecklist(),
name: "",
}) ?? "",
},
}).then(() => {
const newPartner: any = JSON.stringify({
...partner,
requester: getBsnFromJWT(),
Expand Down
Loading
Loading