pl-fe: use more specific zustand selectors

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2025-10-22 21:42:11 +02:00
parent 80654146a2
commit ea86246647
93 changed files with 398 additions and 349 deletions

View File

@ -4,28 +4,34 @@ type State = {
ref: React.MutableRefObject<HTMLDivElement> | null;
statusId: string | null;
hovered: boolean;
openStatusHoverCard: (ref: React.MutableRefObject<HTMLDivElement>, statusId: string) => void;
updateStatusHoverCard: () => void;
closeStatusHoverCard: (force?: boolean) => void;
actions: {
openStatusHoverCard: (ref: React.MutableRefObject<HTMLDivElement>, statusId: string) => void;
updateStatusHoverCard: () => void;
closeStatusHoverCard: (force?: boolean) => void;
};
}
const useStatusHoverCardStore = create<State>((set) => ({
ref: null,
statusId: null,
hovered: false,
openStatusHoverCard: (ref, statusId) => set({
ref,
statusId,
}),
updateStatusHoverCard: () => set({
hovered: true,
}),
closeStatusHoverCard: (force = false) => set((state) => state.hovered && !force ? {} : {
ref: null,
statusId: null,
hovered: false,
}),
actions: {
openStatusHoverCard: (ref, statusId) => set({
ref,
statusId,
}),
updateStatusHoverCard: () => set({
hovered: true,
}),
closeStatusHoverCard: (force = false) => set((state) => state.hovered && !force ? {} : {
ref: null,
statusId: null,
hovered: false,
}),
},
}));
export { useStatusHoverCardStore };
const useStatusHoverCardActions = () => useStatusHoverCardStore((state) => state.actions);
export { useStatusHoverCardStore, useStatusHoverCardActions };