Resume the draft from Create rule instead of deleting it.

This commit is contained in:
adilallo committed 2026-11-22 17:51:21 -07:00
1 parent d31045b0e5
commit a846169960
9 files changed
+119 -71

No files matched your search

@@ -68,6 +68,14 @@ export function useCreateFlowNavigation(
const validStep = parseCreateFlowScreenFromPathname(pathname ?? null);
useLayoutEffect(() => {
if (!validStep || validStep === "completed" || validStep === "edit-rule") {
return;
}
if (state.currentStep === validStep) return;
updateState({ currentStep: validStep });
}, [validStep, state.currentStep, updateState]);
useLayoutEffect(() => {
if (!pathname?.includes("/create/review-template/")) return;
if (
+26
View File
@@ -0,0 +1,26 @@
import { createFlowStateHasKeys } from "../../../../lib/create/draftHydrationUtils";
import type { CreateFlowStep } from "../types";
import { readAnonymousCreateFlowState } from "./anonymousDraftStorage";
import { CREATE_ROUTES, createFlowStepPath } from "./createFlowPaths";
import { readCoreValueDetailsFromLocalStorage } from "./coreValueDetailsLocalStorage";
import { isValidStep } from "./flowSteps";
const NON_RESUME_STEPS = new Set<CreateFlowStep>(["completed", "edit-rule"]);
export function hasBrowserCreateFlowDraft(): boolean {
if (createFlowStateHasKeys(readAnonymousCreateFlowState())) return true;
return Object.keys(readCoreValueDetailsFromLocalStorage()).length > 0;
}
/**
* Path for header / Home / Profile **Create rule**. Never clears the browser
* draft or `DELETE`s `/api/drafts/me` — resume where the draft was left.
*/
export function createRuleEntryPath(): string {
const local = readAnonymousCreateFlowState();
const step = local.currentStep;
if (isValidStep(step) && !NON_RESUME_STEPS.has(step)) {
return createFlowStepPath(step);
}
return CREATE_ROUTES.createFirstStep;
}