
import axios from '../plugins/axios'
import { defineStore } from 'pinia'

export const useTicketsStore = defineStore('tickets', {
    state: () => ({
        items: [],
        fetching: true,
        total: 0
    }),
    actions: {
        async index(page, rows) {
            this.fetching = true
            const params = { page, rows }
            const { status, data } = await axios.get('/ticket')
            this.fetching = false
            return data
        },
        async ticket(id) {
            this.fetching = true
            const { status, data } = await axios.get(`/ticket/${id}`)
            this.fetching = false
            return data
         
            
        },
        async close(id){
            this.fetching = true
            const { status, data } = await axios.patch(`/ticket/close/${id}`, id)
            this.fetching = false
            return data
        },    
        async reply(form){
            this.fetching = true
            const { status, data } = await axios.post('/ticket/message', form)
            this.fetching = false
            return data
        },     
      
    }
})