Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #302 from frameless/feature/HP-148/producten
Browse files Browse the repository at this point in the history
FINALIZE
  • Loading branch information
lencodes authored Apr 20, 2023
2 parents 9d78a57 + 3545607 commit 936acdb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
31 changes: 24 additions & 7 deletions pages/extra/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { FormField, FormLabel } from "@utrecht/component-library-react";
import Head from "next/head";
import Image from "next/image";
Expand Down Expand Up @@ -28,7 +27,7 @@ import { PageFooterTemplate } from "../../src/components/huwelijksplanner/PageFo
import { PageHeaderTemplate } from "../../src/components/huwelijksplanner/PageHeaderTemplate";
import { ReservationCard } from "../../src/components/huwelijksplanner/ReservationCard";
import { MarriageOptionsContext } from "../../src/context/MarriageOptionsContext";
import { SdgproductService } from "../../src/generated";
import { HuwelijkService, SdgproductService } from "../../src/generated";

export const getServerSideProps = async ({ locale }: { locale: string }) => ({
props: {
Expand All @@ -39,7 +38,9 @@ export const getServerSideProps = async ({ locale }: { locale: string }) => ({
export default function MultistepForm1() {
const { t } = useTranslation(["common", "huwelijksplanner-step-5", "form"]);
const { locale, push } = useRouter();

const [isLoading, setIsLoading] = useState<boolean>(false);
const [isSavingProduct, setIsSavingProduct] = useState<boolean>(false);

const [trouwboekje, setTrouwboekje] = useState<any>();
const [selectedExtra, setSelectedExtra] = useState<any>();
Expand All @@ -49,9 +50,21 @@ export default function MultistepForm1() {
const onMarriageCertificateKindSubmit = (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();

setMarriageOptions({...marriageOptions, extras: [selectedExtra]});
setIsSavingProduct(true);

HuwelijkService.huwelijkPatchItem(marriageOptions.huwelijk.id, { producten: [selectedExtra] })
.then((res) => {
setMarriageOptions({
...marriageOptions,
huwelijk: {
...marriageOptions.huwelijk,
"ceremony-price-amount": res.kosten ? res.kosten.replace("EUR ", "") : "-",
},
});

push("/voorgenomen-huwelijk/checken");
push("/voorgenomen-huwelijk/checken");
})
.finally(() => setIsSavingProduct(false));
};

useEffect(() => {
Expand Down Expand Up @@ -113,15 +126,19 @@ export default function MultistepForm1() {

{trouwboekje.embedded.vertalingen.map((vertaling: any) => (
<FormField key={vertaling.id} type="radio">
<RadioButton2 onChange={() => setSelectedExtra(vertaling.id)} id={vertaling.id} name="marriage-certificate-kind" />
<RadioButton2
onChange={() => setSelectedExtra(vertaling.id)}
id={vertaling.id}
name="marriage-certificate-kind"
/>
<FormLabel htmlFor={vertaling.id} type="radio">
{vertaling.specifiekeTekst} ({vertaling.kosten})
</FormLabel>
</FormField>
))}
</Fieldset>
<Button type="submit" name="type" appearance="primary-action-button">
Deze wil ik hebben
<Button disabled={isSavingProduct} type="submit" name="type" appearance="primary-action-button">
{isSavingProduct ? "Loading..." : "Deze wil ik hebben"}
</Button>
</>
)}
Expand Down
3 changes: 2 additions & 1 deletion pages/persoonsgegevens/[person].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ export default function MultistepForm1() {
setIsLoading(true);

if (!huwelijkId) {
AssentService.assentPatchItem(huwelijk?.partners[0]._self.id, {
// @ts-ignore
AssentService.assentPatchItem(huwelijk?.embedded?.partners[0]._self.id, {
requester: getBsnFromJWT(),
contact: {
subjectIdentificatie: {
Expand Down
1 change: 0 additions & 1 deletion src/context/MarriageOptionsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export interface MarriageOptionsProps {
huwelijk: Huwelijk;
ambtenaar?: string;
ceremonyId?: string;
extras?: string[];
}

const myWindow = typeof window !== "undefined" ? window : undefined;
Expand Down

1 comment on commit 936acdb

@vercel
Copy link

@vercel vercel bot commented on 936acdb Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.