feat: add notifcation store
This commit is contained in:
parent
77bc4973a9
commit
817cdc0567
1 changed files with 56 additions and 0 deletions
56
src/stores/notification/index.ts
Normal file
56
src/stores/notification/index.ts
Normal file
|
|
@ -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<Notification>();
|
||||
|
||||
async function getNotification(id: string) {
|
||||
const res = await api.get<Notification>(`/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<PaginationResult<Notification>>('/notification', {
|
||||
params,
|
||||
});
|
||||
if (res.status >= 400) return null;
|
||||
return res.data;
|
||||
}
|
||||
|
||||
async function updateNotification(paymentId: string, payload: Notification) {
|
||||
const res = await api.put<Notification & { id: string }>(
|
||||
`/notification/${paymentId}`,
|
||||
payload,
|
||||
);
|
||||
if (res.status >= 400) return null;
|
||||
return res.data;
|
||||
}
|
||||
|
||||
async function deleteNotification(notificationId: string) {
|
||||
const res = await api.delete<Notification & { id: string }>(
|
||||
`/notification/${notificationId}`,
|
||||
);
|
||||
if (res.status >= 400) return null;
|
||||
return res.data;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
|
||||
getNotification,
|
||||
getNotificationList,
|
||||
updateNotification,
|
||||
deleteNotification,
|
||||
};
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue