import { defineStore } from 'pinia'
import { post } from 'src/services/api'

export const useMailTestStore = defineStore('mailTest', {
  state: () => ({
    loading: false,
    lastResult: null
  }),

  actions: {
    async sendTestMail (to) {
      this.loading = true
      try {
        const data = await post('/test-mail', {
          to
        })

        this.lastResult = data
        return true
      } catch (err) {
        this.lastResult = err
        throw err
      } finally {
        this.loading = false
      }
    }
  }
})

