From 301454838b79fdbfe72e463df8de20f268caf21f Mon Sep 17 00:00:00 2001 From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Date: Sat, 3 Aug 2024 10:03:10 +0200 Subject: [PATCH] fix: strategy edit required param error (#7747) Fixing error "Missing required path param: featureId", on editing default project strategy. --- .../StrategyTypes/FlexibleStrategy/FlexibleStrategy.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.tsx b/frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.tsx index e4988b575e..d5c50a2d10 100644 --- a/frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.tsx +++ b/frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.tsx @@ -15,6 +15,7 @@ import { StickinessSelect } from './StickinessSelect/StickinessSelect'; import { useDefaultProjectSettings } from 'hooks/useDefaultProjectSettings'; import Loader from '../../../common/Loader/Loader'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; +import { useOptionalPathParam } from 'hooks/useOptionalPathParam'; import { useLocation } from 'react-router'; import type { IFormErrors } from 'hooks/useFormErrors'; @@ -58,7 +59,7 @@ const FlexibleStrategy = ({ errors, }: IFlexibleStrategyProps) => { const projectId = useRequiredPathParam('projectId'); - const featureId = useRequiredPathParam('featureId'); + const featureId = useOptionalPathParam('featureId'); const { defaultStickiness, loading } = useDefaultProjectSettings(projectId); const { pathname } = useLocation(); @@ -83,7 +84,11 @@ const FlexibleStrategy = ({ const groupId = useMemo(() => { if (!parameters.groupId && !loading) { - updateParameter('groupId', isDefaultStrategyEdit ? '' : featureId); + if (isDefaultStrategyEdit || !featureId) { + updateParameter('groupId', ''); + } else { + updateParameter('groupId', featureId); + } } return parseParameterString(parameters.groupId);