import { create } from 'zustand'
import type { ShortlistItemInput } from '../domain/shortlist'

interface ShortlistStore {
  selectedShortlistId: string | null
  dialogOpen: boolean
  pendingItem: ShortlistItemInput | null
  setSelectedShortlist: (id: string | null) => void
  openAddDialog: (item: ShortlistItemInput) => void
  closeAddDialog: () => void
}

export const useShortlistStore = create<ShortlistStore>((set) => ({
  selectedShortlistId: null,
  dialogOpen: false,
  pendingItem: null,
  setSelectedShortlist: (id) => set({ selectedShortlistId: id }),
  openAddDialog: (item) => set({ dialogOpen: true, pendingItem: item }),
  closeAddDialog: () => set({ dialogOpen: false, pendingItem: null }),
}))
