diff --git a/backend/benefit/applications/enums.py b/backend/benefit/applications/enums.py index e342b6dd33..486bb94e28 100644 --- a/backend/benefit/applications/enums.py +++ b/backend/benefit/applications/enums.py @@ -164,4 +164,6 @@ class AhjoStatus(models.TextChoices): class ApplicationActions(models.TextChoices): - STATUS_CHANGE = "STATUS_CHANGE", _("Status change") + APPLICANT_TOGGLE_EDIT = "APPLICANT_TOGGLE_EDIT", _( + "Allow/disallow applicant's modifications" + ) diff --git a/backend/benefit/calculator/api/v1/serializers.py b/backend/benefit/calculator/api/v1/serializers.py index 0cb14f20ee..708f87262a 100644 --- a/backend/benefit/calculator/api/v1/serializers.py +++ b/backend/benefit/calculator/api/v1/serializers.py @@ -255,12 +255,11 @@ def _has_handling_started(self): and new_status in self.HANDLING_STARTED_STATUSES ) - def _are_dates_required(self, action=None): + def _are_dates_required(self): return ( self._has_handling_started() and self._is_salary_benefit_type() and not self._is_manual_mode() - and action != ApplicationActions.STATUS_CHANGE ) def _is_invalid_state_aid_max(self, state_aid_max_input: Union[None, int]) -> bool: @@ -272,7 +271,13 @@ def validate(self, data): request = self.context.get("request") if request is None: return data - if self._are_dates_required(action=ApplicationActions.STATUS_CHANGE): + + action = None + if "action" in request.data: + action = request.data["action"] + if self._are_dates_required() and action not in [ + ApplicationActions.APPLICANT_TOGGLE_EDIT + ]: if data.get("start_date") is None: raise serializers.ValidationError( {"start_date": _("Start date cannot be empty")} diff --git a/frontend/benefit/handler/src/constants.ts b/frontend/benefit/handler/src/constants.ts index 5c64a6c6d6..94879dfa78 100644 --- a/frontend/benefit/handler/src/constants.ts +++ b/frontend/benefit/handler/src/constants.ts @@ -194,5 +194,5 @@ export enum LOCAL_STORAGE_KEYS { } export enum APPLICATION_ACTIONS { - STATUS_CHANGE = 'STATUS_CHANGE', + APPLICANT_TOGGLE_EDIT = 'APPLICANT_TOGGLE_EDIT', } diff --git a/frontend/benefit/handler/src/hooks/useApplicationActions.ts b/frontend/benefit/handler/src/hooks/useApplicationActions.ts index 7bad3eab74..005aaf74a8 100644 --- a/frontend/benefit/handler/src/hooks/useApplicationActions.ts +++ b/frontend/benefit/handler/src/hooks/useApplicationActions.ts @@ -4,8 +4,8 @@ import { Application, ApplicationData } from 'benefit-shared/types/application'; import { stringToFloatValue } from 'shared/utils/string.utils'; import snakecaseKeys from 'snakecase-keys'; -import useUpdateApplicationQuery from './useUpdateApplicationQuery'; import { APPLICATION_ACTIONS } from '../constants'; +import useUpdateApplicationQuery from './useUpdateApplicationQuery'; type ExtendedComponentProps = { updateStatus: ( @@ -53,7 +53,7 @@ const useApplicationActions = ( }, { deep: true } ) as ApplicationData; - const action = { action: APPLICATION_ACTIONS.STATUS_CHANGE }; + const action = { action: APPLICATION_ACTIONS.APPLICANT_TOGGLE_EDIT }; updateApplicationQuery.mutate({ ...currentApplicationData, ...action }); window.scrollTo(0, 0); };