Turn a saved draft into the finished Rule, and greet with congratulations.
This commit is contained in:
1 parent
a2815ae05f
commit
851133e56d
11 files changed
+150
-23
No files matched your search
@@ -3,7 +3,11 @@
|
||||
import { useCallback, useState } from "react";
|
||||
import { buildPublishPayload } from "../../../../lib/create/buildPublishPayload";
|
||||
import { stateWithPendingCommunityAvatar } from "../../../../lib/create/flushPendingCommunityAvatar";
|
||||
import { publishRule, updatePublishedRule } from "../../../../lib/create/api";
|
||||
import {
|
||||
deleteServerDraft,
|
||||
publishRule,
|
||||
updatePublishedRule,
|
||||
} from "../../../../lib/create/api";
|
||||
import { writeLastPublishedRule } from "../../../../lib/create/lastPublishedRule";
|
||||
import { writePendingKeepRuleLogin } from "../../../../lib/create/pendingKeepRuleLogin";
|
||||
import messages from "../../../../messages/en/index";
|
||||
@@ -150,6 +154,7 @@ export function useCreateFlowFinalize({
|
||||
document: ruleDocument,
|
||||
});
|
||||
updateState({ editingPublishedRuleId: undefined });
|
||||
void deleteServerDraft();
|
||||
router.push(createFlowStepPath("completed"));
|
||||
return;
|
||||
}
|
||||
@@ -203,6 +208,8 @@ export function useCreateFlowFinalize({
|
||||
if (isGuest) {
|
||||
writePendingKeepRuleLogin();
|
||||
onGuestPublished?.({ skippedInvites: skippedGuestInvites });
|
||||
} else {
|
||||
void deleteServerDraft();
|
||||
}
|
||||
router.push(
|
||||
createFlowStepPath("completed", {
|
||||
|
||||
@@ -247,6 +247,15 @@ export function isValidStep(
|
||||
);
|
||||
}
|
||||
|
||||
/** Resume a saved draft on the screen it was left on. */
|
||||
export function resumeCreateFlowStep(
|
||||
state: { currentStep?: CreateFlowStep } | null | undefined,
|
||||
): CreateFlowStep {
|
||||
const step = state?.currentStep;
|
||||
if (step && isValidStep(step)) return step;
|
||||
return FIRST_STEP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses `/create/{screenId}` (and optional trailing segments) from pathname.
|
||||
* Returns null for non-wizard paths (e.g. `/create/review-template/...`).
|
||||
|
||||
Reference in new issue
Block a user