c78fc43083
* feat(backend): add intake journal APIs and share note support * feat(frontend): add intake journal and shared note flows
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import { createContext, useContext } from "react";
|
|
|
|
type ShareContextValue = {
|
|
showShareDialog: boolean;
|
|
sharePeople: string[];
|
|
shareSelectedPerson: string;
|
|
setShareSelectedPerson: React.Dispatch<React.SetStateAction<string>>;
|
|
shareSelectedDays: number;
|
|
setShareSelectedDays: React.Dispatch<React.SetStateAction<number>>;
|
|
shareSelectedExpiryDays: number | null;
|
|
setShareSelectedExpiryDays: React.Dispatch<React.SetStateAction<number | null>>;
|
|
shareAllowJournalNotes: boolean;
|
|
setShareAllowJournalNotes: React.Dispatch<React.SetStateAction<boolean>>;
|
|
shareGenerating: boolean;
|
|
shareLink: string | null;
|
|
setShareLink: React.Dispatch<React.SetStateAction<string | null>>;
|
|
shareCopied: boolean;
|
|
setShareCopied: React.Dispatch<React.SetStateAction<boolean>>;
|
|
activeShareLinks: import("../hooks/useShare").ActiveShareLink[];
|
|
activeSharesLoading: boolean;
|
|
revokingShareToken: string | null;
|
|
openShareDialog: () => void;
|
|
generateShareLink: () => Promise<void>;
|
|
revokeShareLink: (token: string) => Promise<boolean>;
|
|
copyShareLink: () => void;
|
|
closeShareDialog: () => void;
|
|
resetShareDialogState: () => void;
|
|
};
|
|
|
|
const ShareContext = createContext<ShareContextValue | null>(null);
|
|
|
|
type ShareContextProviderProps = {
|
|
value: ShareContextValue;
|
|
children: React.ReactNode;
|
|
};
|
|
|
|
export function ShareContextProvider({ value, children }: ShareContextProviderProps) {
|
|
return <ShareContext.Provider value={value}>{children}</ShareContext.Provider>;
|
|
}
|
|
|
|
export function useShareContext(): ShareContextValue {
|
|
const context = useContext(ShareContext);
|
|
if (!context) {
|
|
throw new Error("useShareContext must be used within ShareContextProvider");
|
|
}
|
|
return context;
|
|
}
|
|
|
|
export type { ShareContextValue };
|