import { defineStore } from 'pinia'
import { ref, reactive } from 'vue'

export const useDialogStore = defineStore('dialogStore', () => {
  const dialogs = reactive<Record<string, any>>({})

  const CreateDialog = (data: Record<string, any>) => {
    const rnd: number = Number(Math.floor(Math.random() * 10000000000))

    const localId = data.id || rnd

    dialogs[localId] = {} as Record<string, any>
    dialogs[localId].id = localId
    dialogs[localId].data = data
  }
  const CloseDialog = (id: number | string) => {
    delete dialogs[id]
  }
  return {
    dialogs,
    CreateDialog,
    CloseDialog
  }
})
