import { defineStore } from 'pinia';

interface ContextMenuState {
  isOpen: boolean;
  x: number;
  y: number;
  itemId: string | null;
  itemType?: 'icon' | 'widget';
}

interface UIState {
  contextMenu: ContextMenuState;
}

export const useUIStore = defineStore('ui', {
  state: (): UIState => ({
    contextMenu: {
      isOpen: false,
      x: 0,
      y: 0,
      itemId: null,
      itemType: 'icon',
    }
  }),
  actions: {
    openContextMenu(x: number, y: number, itemId: string, itemType: 'icon' | 'widget') {
      this.contextMenu = {
        isOpen: true,
        x,
        y,
        itemId,
        itemType,
      };
    },
    closeContextMenu() {
      this.contextMenu.isOpen = false;
      this.contextMenu.itemId = null;
    },
  },
});
