MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / CurrentFlowApp

Function CurrentFlowApp

packages/onboarding-demo/src/app.tsx:37–137  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35};
36
37function CurrentFlowApp() {
38 // Each screen is addressable as `#<step-id>`, so a specific screen can be
39 // linked to directly rather than clicked toward. `[` and `]` step through.
40 const [stepId, setStepId] = useState<StepId>(stepFromHash);
41 const [overrides, setOverrides] = useState<{
42 readonly integrations?: readonly DemoIntegration[];
43 readonly connectOpen?: boolean;
44 readonly accountModal?: AccountModal;
45 readonly view?: ScreenView;
46 }>({});
47
48 const base = useMemo(() => stepState[stepId], [stepId]);
49 const state = { ...base, ...overrides };
50
51 const goToStep = useCallback((id: StepId) => {
52 setStepId(id);
53 setOverrides({});
54 if (globalThis.location) globalThis.location.hash = id;
55 }, []);
56
57 useEffect(() => {
58 const onHashChange = () => {
59 setStepId(stepFromHash());
60 setOverrides({});
61 };
62 globalThis.addEventListener("hashchange", onHashChange);
63 return () => globalThis.removeEventListener("hashchange", onHashChange);
64 }, []);
65
66 useEffect(() => {
67 const onKey = (event: KeyboardEvent) => {
68 if (event.key !== "[" && event.key !== "]") return;
69 const index = flowSteps.findIndex((candidate) => candidate.id === stepId);
70 const next = event.key === "]" ? index + 1 : index - 1;
71 const target = flowSteps[next];
72 if (target) goToStep(target.id);
73 };
74 globalThis.addEventListener("keydown", onKey);
75 return () => globalThis.removeEventListener("keydown", onKey);
76 }, [stepId, goToStep]);
77
78 const integrations = state.integrations ?? seededIntegrations;
79
80 return (
81 <>
82 <Shell integrations={integrations}>
83 {state.view === "integrations" && (
84 <IntegrationsPage
85 integrations={integrations}
86 onConnect={() => setOverrides((prev) => ({ ...prev, connectOpen: true }))}
87 onOpenIntegration={() => setOverrides((prev) => ({ ...prev, view: "detail" }))}
88 />
89 )}
90
91 {state.view === "add" && (
92 <AddOpenApiPage
93 preset={posthogPreset}
94 onCancel={() => goToStep("integrations-empty")}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected