mirror of
https://github.com/docmost/docmost.git
synced 2026-05-15 21:24:09 +08:00
17 lines
438 B
TypeScript
17 lines
438 B
TypeScript
import { atomWithStorage } from "jotai/utils";
|
|
|
|
import { ICurrentUser } from "@/features/user/types/user.types";
|
|
import { focusAtom } from "jotai-optics";
|
|
|
|
export const currentUserAtom = atomWithStorage<ICurrentUser | null>(
|
|
"currentUser",
|
|
null,
|
|
);
|
|
|
|
export const userAtom = focusAtom(currentUserAtom, (optic) =>
|
|
optic.prop("user"),
|
|
);
|
|
export const workspaceAtom = focusAtom(currentUserAtom, (optic) =>
|
|
optic.prop("workspace"),
|
|
);
|