import { create } from "zustand" interface LoginDialogState { open: boolean pendingActions: Array<() => void> openLoginDialog: (action?: () => void) => void closeLoginDialog: () => void consumePendingAction: () => void } export const useLoginDialogStore = create((set, get) => ({ open: false, pendingActions: [], openLoginDialog: (action) => set((state) => ({ open: true, pendingActions: action ? [...state.pendingActions, action] : state.pendingActions, })), closeLoginDialog: () => set({ open: false, pendingActions: [] }), consumePendingAction: () => { const actions = get().pendingActions set({ pendingActions: [] }) actions.forEach((action) => { action() }) }, }))