mirror of
https://github.com/linkwarden/linkwarden.git
synced 2026-03-03 03:47:02 +00:00
27 lines
592 B
TypeScript
27 lines
592 B
TypeScript
import { create } from "zustand";
|
|
import { LinkIncludingShortenedCollectionAndTags } from "@linkwarden/types";
|
|
import { User } from "@linkwarden/prisma/client";
|
|
|
|
type Tmp = {
|
|
link: LinkIncludingShortenedCollectionAndTags | null;
|
|
user: Pick<User, "id"> | null;
|
|
};
|
|
|
|
type TmpStore = {
|
|
tmp: Tmp;
|
|
updateTmp: (newData: Partial<Tmp>) => void;
|
|
};
|
|
|
|
const useTmpStore = create<TmpStore>((set, get) => ({
|
|
tmp: {
|
|
link: null,
|
|
user: null,
|
|
},
|
|
updateTmp: async (patch) => {
|
|
const merged = { ...get().tmp, ...patch };
|
|
set({ tmp: merged });
|
|
},
|
|
}));
|
|
|
|
export default useTmpStore;
|