@7365admin1/layer-common 1.10.1 → 1.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,82 @@
1
+ export default function(){
2
+
3
+ const recipientList: { title: string, value: TAnnouncementRecipients }[] = [
4
+ { title: "Admin", value: "admin" },
5
+ { title: "Management Agency", value: "organization" },
6
+ { title: "Site Personnel", value: "site" },
7
+ { title: "Service Provider", value: "service-provider" },
8
+ { title: "Service Provider Member", value: "service-provider-member" },
9
+ { title: "Resident", value: "resident" }
10
+ ]
11
+
12
+ async function add(payload: Partial<TCreateAnnouncementPayload>) {
13
+ return await useNuxtApp().$api<Record<string, any>>("/api/bulletin-boards", {
14
+ method: "POST",
15
+ body: payload,
16
+ });
17
+ }
18
+
19
+ async function update(bulletinId: string, payload: Partial<TCreateAnnouncementPayload>) {
20
+ return await useNuxtApp().$api<Record<string, any>>(`/api/bulletin-boards/id/${bulletinId}`, {
21
+ method: "PUT",
22
+ body: payload,
23
+ });
24
+ }
25
+
26
+ type TGetAllParams = {
27
+ page?: number;
28
+ limit?: number;
29
+ sort?: 'asc' | 'desc';
30
+ site?: string;
31
+ status?: TAnnouncementStatus;
32
+ search?: string
33
+ }
34
+
35
+ async function getAll({
36
+ page = 1,
37
+ limit = 10,
38
+ sort = "asc",
39
+ site,
40
+ status,
41
+ search
42
+ } : TGetAllParams) {
43
+ return await useNuxtApp().$api<Record<string, any>>(
44
+ "/api/bulletin-boards",
45
+ {
46
+ method: "GET",
47
+ query: {
48
+ page,
49
+ limit,
50
+ sort,
51
+ site,
52
+ status,
53
+ search
54
+
55
+ },
56
+ }
57
+ );
58
+ }
59
+
60
+ async function getBulletinById(bulletinId: string) {
61
+ return await useNuxtApp().$api<Record<string, any>>(`/api/bulletin-boards/id/${bulletinId}`, {
62
+ method: "GET",
63
+ });
64
+ }
65
+
66
+ async function deleteBulletinById(bulletinId: string) {
67
+ return await useNuxtApp().$api<Record<string, any>>(`/api/bulletin-boards/${bulletinId}`, {
68
+ method: "PUT",
69
+ });
70
+ }
71
+
72
+
73
+ return {
74
+ recipientList,
75
+ add,
76
+ update,
77
+ getAll,
78
+ getBulletinById,
79
+ deleteBulletinById
80
+
81
+ }
82
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "1.10.1",
5
+ "version": "1.10.3",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "publishConfig": {
@@ -0,0 +1,29 @@
1
+ declare interface TAnnouncement {
2
+ _id: string;
3
+ recipients: TAnnouncementRecipients[];
4
+ title: string;
5
+ content: string;
6
+ file: AnnouncementFile[];
7
+ createdAt: string;
8
+ updatedAt: string;
9
+ site: string;
10
+ createdBy: string;
11
+ noExpiration: boolean;
12
+ startDate: string;
13
+ endDate: string;
14
+ status: TAnnouncementStatus
15
+ }
16
+
17
+ declare interface TAnnouncementFile {
18
+ _id: string;
19
+ name: string;
20
+ preview: boolean;
21
+ }
22
+
23
+ declare type TAnnouncementRecipients = "admin" | "organization" | "site" | "service-provider" | "service-provider-member" | "resident";
24
+
25
+
26
+
27
+ declare type TCreateAnnouncementPayload = Pick<TAnnouncement, "recipients" | "file" | "site" | "noExpiration" | "startDate" | "endDate" | "content" | "title">
28
+
29
+ declare type TAnnouncementStatus = "active" | "expired"