Walk Create Community through the Figma screens and restore a chosen logo after reload, so a guest can leave without saving until they reach the email step.
This commit is contained in:
1 parent
ca1f58a50c
commit
2348a9e94f
61 files changed
+1110
-421
No files matched your search
@@ -0,0 +1,50 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
createContext,
|
||||
useCallback,
|
||||
useContext,
|
||||
useMemo,
|
||||
useState,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
|
||||
type CreateFlowContinueAttemptContextValue = {
|
||||
attempted: boolean;
|
||||
markAttempted: () => void;
|
||||
clearAttempted: () => void;
|
||||
};
|
||||
|
||||
const CreateFlowContinueAttemptContext =
|
||||
createContext<CreateFlowContinueAttemptContextValue | null>(null);
|
||||
|
||||
export function CreateFlowContinueAttemptProvider({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const [attempted, setAttempted] = useState(false);
|
||||
const markAttempted = useCallback(() => setAttempted(true), []);
|
||||
const clearAttempted = useCallback(() => setAttempted(false), []);
|
||||
const value = useMemo(
|
||||
() => ({ attempted, markAttempted, clearAttempted }),
|
||||
[attempted, markAttempted, clearAttempted],
|
||||
);
|
||||
return (
|
||||
<CreateFlowContinueAttemptContext.Provider value={value}>
|
||||
{children}
|
||||
</CreateFlowContinueAttemptContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useCreateFlowContinueAttempt(): CreateFlowContinueAttemptContextValue {
|
||||
const value = useContext(CreateFlowContinueAttemptContext);
|
||||
if (!value) {
|
||||
return {
|
||||
attempted: false,
|
||||
markAttempted: () => {},
|
||||
clearAttempted: () => {},
|
||||
};
|
||||
}
|
||||
return value;
|
||||
}
|
||||
Reference in new issue
Block a user