import { defineStore } from 'pinia';

export const useSnackbarStore = defineStore('snackbarModule', {
  state: () => ({
    isSnackbarVisible: false,
    snackbarOptions: {},
    message: 'message',
    icon: 'tabler:checkbox',
  }),
  actions: {
    // 👉 index
    async showSnackbar(message, options, icon) {
      this.snackbarOptions = options
      this.icon = icon || (options.color === 'error' ? 'tabler:xbox-x' : options.color === 'success' ? 'tabler:checkbox' : 'tabler:info-circle')
      this.message = message
      this.isSnackbarVisible = true
    },
  },
})
