From a1efb655176cc77e230ad37dd784657a19e2bcc5 Mon Sep 17 00:00:00 2001 From: Charlotte Isambert Date: Mon, 29 Jan 2024 11:23:38 +0100 Subject: [PATCH] remove enable remove route api --- packages/lib/src/routers/FlowRouter.ts | 55 -------------------------- 1 file changed, 55 deletions(-) diff --git a/packages/lib/src/routers/FlowRouter.ts b/packages/lib/src/routers/FlowRouter.ts index 5dbd8cb..e1be22f 100644 --- a/packages/lib/src/routers/FlowRouter.ts +++ b/packages/lib/src/routers/FlowRouter.ts @@ -15,8 +15,6 @@ export type FlowActionHelpers = { goToNextStep(): void; goToPreviousStep(): void; quitFlow(): void; - enableRoute(routeName: Extract): void; - disableRoute(routeName: Extract): void; setStoreState(formState: FormState): void; } & StackActionHelpers; @@ -34,16 +32,6 @@ export type FlowActionType = type: "QUIT_FLOW"; source?: string; } - | { - type: "ENABLE_ROUTE"; - source?: string; - payload: { routeName: Extract }; - } - | { - type: "DISABLE_ROUTE"; - source?: string; - payload: { routeName: Extract }; - } | { type: "SET_STORE_STATE"; source?: string; @@ -141,43 +129,6 @@ export const buildFlowRouter = return state; - case "ENABLE_ROUTE": - const notOrdonnedAvailableRoutes = [ - ...state.availableRoutes, - action.payload.routeName, - ]; - - const newAvailableRoutes = state.routeNames.filter( - (routeName: string) => - notOrdonnedAvailableRoutes.find( - (newAvailableRoute) => routeName === newAvailableRoute - ) - ); - - return { - ...state, - availableRoutes: newAvailableRoutes, - }; - - case "DISABLE_ROUTE": - // TODO: maybe use getStateForRouteNamesChange - const currentRouteName = state.routes[state.routes.length - 1]; - - const filteredRoutes = state.routes.filter( - (route) => route.name !== action.payload.routeName - ); - - return { - ...state, - availableRoutes: state.availableRoutes.filter( - (routeName: string) => routeName !== action.payload.routeName - ), - routes: filteredRoutes, - index: filteredRoutes.findIndex( - (routeName) => routeName === currentRouteName - ), - }; - case "SET_STORE_STATE": const newFormState = { ...state.formState, @@ -235,12 +186,6 @@ export const buildFlowRouter = quitFlow: () => { return { type: "QUIT_FLOW" }; }, - enableRoute: (routeName) => { - return { type: "ENABLE_ROUTE", payload: { routeName } }; - }, - disableRoute: (routeName) => { - return { type: "DISABLE_ROUTE", payload: { routeName } }; - }, setStoreState: (formState) => { return { type: "SET_STORE_STATE", payload: { formState } }; },