import { defineStore } from "pinia";
import type { Vector3Dto } from "../../contractsCommon";
import type { Selectable } from "../../viewerTypes";

export interface ViewerOrderContextMenuTarget {
  selection: Selectable;
  label: string;
  systemId?: string | null;
  itemId?: string | null;
  targetPosition?: Vector3Dto | null;
}

export const useViewerOrderContextMenuStore = defineStore("viewerOrderContextMenu", {
  state: () => ({
    isOpen: false,
    x: 0,
    y: 0,
    target: null as ViewerOrderContextMenuTarget | null,
  }),
  actions: {
    open(x: number, y: number, target: ViewerOrderContextMenuTarget) {
      this.isOpen = true;
      this.x = x;
      this.y = y;
      this.target = target;
    },
    close() {
      this.isOpen = false;
      this.target = null;
    },
  },
});
