diff --git a/src/stores/notification/index.ts b/src/stores/notification/index.ts new file mode 100644 index 00000000..1243de88 --- /dev/null +++ b/src/stores/notification/index.ts @@ -0,0 +1,56 @@ +import { defineStore } from 'pinia'; +import { api } from 'src/boot/axios'; + +import { PaginationResult } from 'src/types'; +import { createDataRefBase } from '../utils'; + +export type Notification = {}; + +export const useNotification = defineStore('noti-store', () => { + const state = createDataRefBase(); + + async function getNotification(id: string) { + const res = await api.get(`/notification/${id}`); + if (res.status >= 400) return null; + return res.data; + } + + async function getNotificationList(params?: { + page?: number; + pageSize?: number; + query?: string; + quotationId?: string; + }) { + const res = await api.get>('/notification', { + params, + }); + if (res.status >= 400) return null; + return res.data; + } + + async function updateNotification(paymentId: string, payload: Notification) { + const res = await api.put( + `/notification/${paymentId}`, + payload, + ); + if (res.status >= 400) return null; + return res.data; + } + + async function deleteNotification(notificationId: string) { + const res = await api.delete( + `/notification/${notificationId}`, + ); + if (res.status >= 400) return null; + return res.data; + } + + return { + ...state, + + getNotification, + getNotificationList, + updateNotification, + deleteNotification, + }; +});