From 99b09bffcb6d91cfd1a8b3e5021636bdee557498 Mon Sep 17 00:00:00 2001 From: Sampo Tawast Date: Wed, 6 Mar 2024 15:32:35 +0200 Subject: [PATCH] fix: reset form calculation if there's change in apprenticeship --- frontend/benefit/handler/src/hooks/useFormActions.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/benefit/handler/src/hooks/useFormActions.tsx b/frontend/benefit/handler/src/hooks/useFormActions.tsx index 3760c70fe4..e0a8ebbbc4 100644 --- a/frontend/benefit/handler/src/hooks/useFormActions.tsx +++ b/frontend/benefit/handler/src/hooks/useFormActions.tsx @@ -179,7 +179,10 @@ const useFormActions = ( values: Partial ): Calculation => { // Return the calculation values as they are - if (values.paySubsidyGranted === initialApplication?.paySubsidyGranted) { + if ( + values.paySubsidyGranted === initialApplication?.paySubsidyGranted && + values.apprenticeshipProgram === initialApplication?.apprenticeshipProgram + ) { return { ...values.calculation, monthlyPay: stringToFloatValue(values.employee.monthlyPay), @@ -196,7 +199,10 @@ const useFormActions = ( const getPayloadForPaySubsidies = ( values: Partial ): PaySubsidy[] => { - if (values.paySubsidyGranted === initialApplication?.paySubsidyGranted) { + if ( + values.paySubsidyGranted === initialApplication?.paySubsidyGranted && + values.apprenticeshipProgram === initialApplication?.apprenticeshipProgram + ) { return [...values.paySubsidies]; } return [