{"version":3,"file":"notice.bbcf7f50.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":[],"mappings":"yCAEY,KAAC,GAAiB,EAAY,UAAW,CACnD,MAAO,IACE,EACL,OAAQ,CAAE,EACV,OAAQ,CAAE,EACV,OAAQ,CAAE,EACV,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