{"version":3,"file":"notice-no5WgiOt.js","sources":["../../../app/javascript/stores/notice.js"],"sourcesContent":["import { defineStore } from 'pinia';\n\nexport const useNoticeStore = defineStore('notices', {\n state: () => {\n return {\n errors: {},\n notice: {},\n active: [],\n notices: [],\n pagination: {},\n };\n },\n\n actions: {\n async index (params) {\n if (params && params.includes('filter')) {\n return await this.axios.get(`/notices?${params}`).then((res) => {\n this.notices = res.data.data;\n });\n } else {\n return await this.axios.get('/notices').then((res) => {\n this.notices = res.data.data;\n });\n }\n // return await this.axios.get('/notices').then((res) => {\n // this.notices = res.data.data;\n // });\n },\n async show (id) {\n this.errors = {};\n this.notice = {};\n return this.axios.get(`/notices/${id}`).then((res) => {\n this.notice = res.data.data.attributes;\n return res.data.data.attributes;\n });\n },\n async new () {\n this.errors = {};\n this.notice = {};\n return this.axios.get(`/notices/new`).then((res) => {\n this.notice = res.data.data.attributes;\n });\n },\n async create () {\n this.errors = {};\n return this.axios\n .post(`/notices`, this.notice)\n .then((res) => {\n this.notice = res.data.data.attributes;\n return true;\n })\n .catch((error) => {\n this.errors = error.res.data.errors;\n return false;\n });\n },\n async edit (id) {\n this.errors = {};\n this.notice = {};\n return this.axios.get(`/notices/${id}/edit`).then((res) => {\n this.notice = res.data.data.attributes;\n });\n },\n async update (id) {\n this.errors = {};\n console.log(this.notice);\n return this.axios\n .put(`/notices/${id}`, this.notice)\n .then((response) => {\n return true;\n })\n .catch((error) => {\n this.errors = error.response.data.errors;\n return false;\n });\n },\n async destroy (id) {\n this.errors = {};\n return this.axios\n .delete(`/notices/${id}`)\n .then((res) => {\n const i = this.notices.findIndex((notice) => notice.id === res.data.data.id);\n if (i > -1) this.notices.splice(i, 1);\n return true;\n })\n .catch((error) => {\n this.errors = error.response.data.errors;\n return false;\n });\n },\n },\n});\n"],"names":["useNoticeStore","defineStore","params","res","id","error","response","i","notice"],"mappings":"wCAEY,MAACA,EAAiBC,EAAY,UAAW,CACnD,MAAO,KACE,CACL,OAAQ,CAAE,EACV,O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