@7365admin1/layer-common 1.9.0 → 1.10.1

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.
Files changed (93) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/components/AcceptDialog.vue +44 -0
  3. package/components/AccessCardAddForm.vue +101 -13
  4. package/components/AccessManagement.vue +130 -47
  5. package/components/AddSupplyForm.vue +165 -0
  6. package/components/AreaChecklistHistoryLogs.vue +235 -0
  7. package/components/AreaChecklistHistoryMain.vue +176 -0
  8. package/components/AreaFormDialog.vue +266 -0
  9. package/components/AreaMain.vue +841 -0
  10. package/components/AttendanceCheckInOutDialog.vue +416 -0
  11. package/components/AttendanceDetailsDialog.vue +184 -0
  12. package/components/AttendanceMain.vue +155 -0
  13. package/components/AttendanceMapSearchDialog.vue +393 -0
  14. package/components/AttendanceSettingsDialog.vue +398 -0
  15. package/components/BuildingManagement/buildings.vue +5 -5
  16. package/components/BuildingManagement/units.vue +5 -5
  17. package/components/ChecklistItemRow.vue +54 -0
  18. package/components/CheckoutItemMain.vue +705 -0
  19. package/components/CleaningScheduleMain.vue +271 -0
  20. package/components/DocumentManagement.vue +8 -9
  21. package/components/EntryPass/QrTemplatePreview.vue +104 -0
  22. package/components/EntryPassMain.vue +252 -200
  23. package/components/HygieneUpdateMoreAction.vue +238 -0
  24. package/components/IncidentReport/Authorities.vue +226 -0
  25. package/components/IncidentReport/IncidentInformation.vue +258 -0
  26. package/components/IncidentReport/affectedEntities.vue +167 -0
  27. package/components/InvitationMain.vue +19 -17
  28. package/components/ManageChecklistMain.vue +384 -0
  29. package/components/MemberMain.vue +48 -20
  30. package/components/MyAttendanceMain.vue +224 -0
  31. package/components/OnlineFormsConfiguration.vue +9 -2
  32. package/components/PasswordConfirmation.vue +95 -0
  33. package/components/PhotoUpload.vue +410 -0
  34. package/components/RolePermissionMain.vue +17 -15
  35. package/components/ScheduleAreaMain.vue +313 -0
  36. package/components/ScheduleTaskAreaFormDialog.vue +144 -0
  37. package/components/ScheduleTaskAreaUpdateMoreAction.vue +109 -0
  38. package/components/ScheduleTaskForm.vue +471 -0
  39. package/components/ScheduleTaskMain.vue +345 -0
  40. package/components/ScheduleTastTicketMain.vue +182 -0
  41. package/components/ServiceProviderMain.vue +27 -7
  42. package/components/StockCard.vue +191 -0
  43. package/components/SupplyManagementMain.vue +557 -0
  44. package/components/TableHygiene.vue +617 -0
  45. package/components/UnitMain.vue +451 -0
  46. package/components/VisitorManagement.vue +28 -15
  47. package/composables/useAccessManagement.ts +90 -0
  48. package/composables/useAreaPermission.ts +51 -0
  49. package/composables/useAreas.ts +99 -0
  50. package/composables/useAttendance.ts +89 -0
  51. package/composables/useAttendancePermission.ts +68 -0
  52. package/composables/useBuilding.ts +2 -2
  53. package/composables/useBuildingUnit.ts +2 -2
  54. package/composables/useCard.ts +2 -0
  55. package/composables/useCheckout.ts +61 -0
  56. package/composables/useCheckoutPermission.ts +80 -0
  57. package/composables/useCleaningPermission.ts +229 -0
  58. package/composables/useCleaningSchedulePermission.ts +58 -0
  59. package/composables/useCleaningSchedules.ts +233 -0
  60. package/composables/useCountry.ts +8 -0
  61. package/composables/useDOBEntries.ts +13 -0
  62. package/composables/useDashboardData.ts +2 -2
  63. package/composables/useDocument.ts +3 -2
  64. package/composables/useFeedback.ts +1 -1
  65. package/composables/useFile.ts +4 -6
  66. package/composables/useLocation.ts +78 -0
  67. package/composables/useOnlineForm.ts +16 -9
  68. package/composables/usePeople.ts +87 -72
  69. package/composables/useQR.ts +29 -0
  70. package/composables/useRole.ts +3 -2
  71. package/composables/useScheduleTask.ts +89 -0
  72. package/composables/useScheduleTaskArea.ts +85 -0
  73. package/composables/useScheduleTaskPermission.ts +68 -0
  74. package/composables/useSiteEntryPassSettings.ts +4 -15
  75. package/composables/useStock.ts +45 -0
  76. package/composables/useSupply.ts +63 -0
  77. package/composables/useSupplyPermission.ts +92 -0
  78. package/composables/useUnitPermission.ts +51 -0
  79. package/composables/useUnits.ts +82 -0
  80. package/composables/useWebUsb.ts +389 -0
  81. package/composables/useWorkOrder.ts +1 -1
  82. package/nuxt.config.ts +3 -0
  83. package/package.json +4 -1
  84. package/types/area.d.ts +22 -0
  85. package/types/attendance.d.ts +38 -0
  86. package/types/checkout-item.d.ts +27 -0
  87. package/types/cleaner-schedule.d.ts +54 -0
  88. package/types/location.d.ts +42 -0
  89. package/types/schedule-task.d.ts +18 -0
  90. package/types/stock.d.ts +16 -0
  91. package/types/supply.d.ts +11 -0
  92. package/types/verification.d.ts +1 -1
  93. package/utils/acm-crypto.ts +30 -0
@@ -0,0 +1,58 @@
1
+ export function useCleaningSchedulePermission() {
2
+ const { hasPermission } = usePermission();
3
+ const { permissions } = useCleaningPermission();
4
+
5
+ const { userAppRole } = useLocalSetup();
6
+
7
+ const canViewSchedules = computed(() => {
8
+ if (!userAppRole.value) return true;
9
+ if (userAppRole.value.permissions.includes("*")) return true;
10
+ return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "see-all-schedules");
11
+ });
12
+
13
+ const canViewScheduleDetails = computed(() => {
14
+ if (!userAppRole.value) return true;
15
+ if (userAppRole.value.permissions.includes("*")) return true;
16
+ return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "see-schedule-details");
17
+ });
18
+
19
+ const canDownloadSchedule = computed(() => {
20
+ if (!userAppRole.value) return true;
21
+ if (userAppRole.value.permissions.includes("*")) return true;
22
+ return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "download-schedule");
23
+ });
24
+
25
+ const canManageScheduleTasks = computed(() => {
26
+ if (!userAppRole.value) return true;
27
+ if (userAppRole.value.permissions.includes("*")) return true;
28
+ return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "manage-schedule-tasks");
29
+ });
30
+
31
+ const canGenerateChecklist = computed(() => {
32
+ if (!userAppRole.value) return true;
33
+ if (userAppRole.value.permissions.includes("*")) return true;
34
+ return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "generate-checklist");
35
+ });
36
+
37
+ const canViewHistory = computed(() => {
38
+ if (!userAppRole.value) return true;
39
+ if (userAppRole.value.permissions.includes("*")) return true;
40
+ return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "view-history");
41
+ });
42
+
43
+ const canAddRemarks = computed(() => {
44
+ if (!userAppRole.value) return true;
45
+ if (userAppRole.value.permissions.includes("*")) return true;
46
+ return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "add-remarks");
47
+ });
48
+
49
+ return {
50
+ canViewSchedules,
51
+ canViewScheduleDetails,
52
+ canDownloadSchedule,
53
+ canManageScheduleTasks,
54
+ canGenerateChecklist,
55
+ canViewHistory,
56
+ canAddRemarks,
57
+ };
58
+ }
@@ -0,0 +1,233 @@
1
+ export default function useCleaningSchedules() {
2
+ const _cleanerChecklists = ref({
3
+ _id: "",
4
+ date: "",
5
+ status: [],
6
+ createdAt: "",
7
+ updatedAt: "",
8
+ attachments: [],
9
+ });
10
+
11
+ async function getCleaningSchedules({
12
+ site = "",
13
+ search = "",
14
+ page = 1,
15
+ limit = 10,
16
+ startDate = "",
17
+ endDate = "",
18
+ status = "",
19
+ } = {}) {
20
+ return useNuxtApp().$api<Record<string, any>>(
21
+ `/api/hygiene-parent-checklist/site/${site}`,
22
+ {
23
+ method: "GET",
24
+ query: {
25
+ search,
26
+ page,
27
+ limit,
28
+ startDate,
29
+ endDate,
30
+ status,
31
+ },
32
+ },
33
+ );
34
+ }
35
+
36
+ async function getScheduleAreas({
37
+ scheduleAreaId = "",
38
+ page = 1,
39
+ limit = 10,
40
+ search = "",
41
+ status = "",
42
+ type = "",
43
+ } = {}) {
44
+ return useNuxtApp().$api<Record<string, any>>(
45
+ `/api/hygiene-area-checklist/schedule/${scheduleAreaId}`,
46
+ {
47
+ method: "GET",
48
+ query: {
49
+ search,
50
+ page,
51
+ limit,
52
+ status,
53
+ type,
54
+ },
55
+ },
56
+ );
57
+ }
58
+
59
+ function acceptAreaChecklist(id: string) {
60
+ return useNuxtApp().$api<Record<string, any>>(
61
+ `/api/hygiene-area-checklist/id/${id}/accept`,
62
+ {
63
+ method: "PATCH",
64
+ },
65
+ );
66
+ }
67
+
68
+ async function getUnitCleanerChecklist({
69
+ scheduleAreaId = "",
70
+ page = 1,
71
+ limit = 10,
72
+ search = "",
73
+ } = {}) {
74
+ return useNuxtApp().$api<Record<string, any>>(
75
+ `/api/hygiene-area-checklist/id/${scheduleAreaId}/units`,
76
+ {
77
+ method: "GET",
78
+ query: {
79
+ search,
80
+ page,
81
+ limit,
82
+ },
83
+ },
84
+ );
85
+ }
86
+
87
+ function updateUnitChecklist(
88
+ checklistId: string,
89
+ unitId: string,
90
+ set: number,
91
+ decision: "approve" | "reject",
92
+ remarks?: string,
93
+ attachment?: string[],
94
+ ) {
95
+ return useNuxtApp().$api<Record<string, any>>(
96
+ `/api/hygiene-area-checklist/id/${checklistId}/set/${set}/units/${unitId}/${decision}`,
97
+ {
98
+ method: "PATCH",
99
+ body: { remarks, attachment },
100
+ },
101
+ );
102
+ }
103
+
104
+ function updateAreaChecklistStatus(
105
+ id: string,
106
+ status: "complete" | "submit",
107
+ signature: string,
108
+ ) {
109
+ return useNuxtApp().$api<Record<string, any>>(
110
+ `/api/hygiene-area-checklist/id/${id}/${status}`,
111
+ {
112
+ method: "PATCH",
113
+ body: { signature },
114
+ },
115
+ );
116
+ }
117
+
118
+ function uploadAreaChecklistAttachment(id: string, attachments: string[]) {
119
+ return useNuxtApp().$api<Record<string, any>>(
120
+ `/api/hygiene-area-checklist/id/${id}/upload`,
121
+ {
122
+ method: "PATCH",
123
+ body: { attachments },
124
+ },
125
+ );
126
+ }
127
+
128
+ function generateChecklist(site: string, parentChecklistId: string) {
129
+ return useNuxtApp().$api<Record<string, any>>(
130
+ `/api/hygiene-area-checklist/site/${site}/schedule/${parentChecklistId}`,
131
+ {
132
+ method: "POST",
133
+ },
134
+ );
135
+ }
136
+
137
+ async function getAreaChecklistHistory({
138
+ parentChecklistId = "",
139
+ page = 1,
140
+ limit = 10,
141
+ search = "",
142
+ status = "",
143
+ } = {}) {
144
+ return useNuxtApp().$api<Record<string, any>>(
145
+ `/api/hygiene-area-checklist/schedule/${parentChecklistId}/history`,
146
+ {
147
+ method: "GET",
148
+ query: { page, limit, search, status },
149
+ },
150
+ );
151
+ }
152
+
153
+ async function getAreaChecklistHistoryById(id: string) {
154
+ return useNuxtApp().$api<Record<string, any>>(
155
+ `/api/hygiene-area-checklist/id/${id}/history`,
156
+ {
157
+ method: "GET",
158
+ },
159
+ );
160
+ }
161
+
162
+ async function exportAreas(site: string) {
163
+ const res = await useNuxtApp().$api<Blob | MediaSource>(
164
+ `/api/hygiene-area/site/${site}/download`,
165
+ {
166
+ method: "GET",
167
+ },
168
+ );
169
+
170
+ if (!res) throw new Error("Error downloading areas");
171
+
172
+ const date = new Date();
173
+ const formattedDate = `${String(date.getMonth() + 1).padStart(
174
+ 2,
175
+ "0",
176
+ )}-${String(date.getDate()).padStart(2, "0")}-${date.getFullYear()}`;
177
+
178
+ const downloadUrl = window.URL.createObjectURL(res);
179
+ const a = document.createElement("a");
180
+ a.href = downloadUrl;
181
+ a.download = `areas-${formattedDate}.xlsx`;
182
+ document.body.appendChild(a);
183
+ a.click();
184
+ document.body.removeChild(a);
185
+ window.URL.revokeObjectURL(downloadUrl);
186
+ }
187
+
188
+ async function downloadChecklistPdf(scheduleId: string) {
189
+ const res = await useNuxtApp().$api<Blob | MediaSource>(
190
+ `/api/hygiene-area-checklist/schedule/${scheduleId}/pdf`,
191
+ {
192
+ method: "GET",
193
+ responseType: "blob",
194
+ },
195
+ );
196
+
197
+ if (!res) throw new Error("Error downloading checklist PDF");
198
+
199
+ const date = new Date();
200
+ const formattedDate = `${String(date.getDate()).padStart(2, "0")}_${String(
201
+ date.getMonth() + 1,
202
+ ).padStart(2, "0")}_${date.getFullYear()} ${String(
203
+ date.getHours(),
204
+ ).padStart(2, "0")}_${String(date.getMinutes()).padStart(2, "0")}`;
205
+
206
+ const downloadUrl = window.URL.createObjectURL(res);
207
+ const a = document.createElement("a");
208
+ a.href = downloadUrl;
209
+ a.download = `CHECKLIST_DOWNLOADED_${formattedDate}.pdf`;
210
+ a.target = "_blank";
211
+ a.rel = "noopener noreferrer";
212
+ document.body.appendChild(a);
213
+ a.click();
214
+ document.body.removeChild(a);
215
+ setTimeout(() => window.URL.revokeObjectURL(downloadUrl), 1000);
216
+ }
217
+
218
+ return {
219
+ _cleanerChecklists,
220
+ getCleaningSchedules,
221
+ getScheduleAreas,
222
+ acceptAreaChecklist,
223
+ updateUnitChecklist,
224
+ getUnitCleanerChecklist,
225
+ updateAreaChecklistStatus,
226
+ uploadAreaChecklistAttachment,
227
+ generateChecklist,
228
+ getAreaChecklistHistory,
229
+ getAreaChecklistHistoryById,
230
+ exportAreas,
231
+ downloadChecklistPdf,
232
+ };
233
+ }
@@ -0,0 +1,8 @@
1
+ export default function useCountry() {
2
+ function getCountries({ page = 1, limit = 10, search = "" } = {}) {
3
+ return useNuxtApp().$api<Record<string, any>>(`https://www.apicountries.com/countries`, {
4
+ method: "GET",
5
+ query: { page, limit, search },
6
+ });
7
+ }
8
+ }
@@ -0,0 +1,13 @@
1
+ export default function () {
2
+ async function confirmPassword({ userId, password} : { userId: string; password: string}) {
3
+ return await useNuxtApp().$api<Record<string, any>>(`/api/auth/verify-password/id/${userId}`, {
4
+ method: "POST",
5
+ body: { password},
6
+ });
7
+ }
8
+
9
+
10
+ return {
11
+ confirmPassword
12
+ };
13
+ }
@@ -145,7 +145,7 @@ const dashboardDataMap: Record<string, ModuleData> = {
145
145
  color: '#7E57C2',
146
146
  },
147
147
  {
148
- title: 'Request Items',
148
+ title: 'Checkout Items',
149
149
  value: 19,
150
150
  percentage: 5.1,
151
151
  isPositive: true,
@@ -167,7 +167,7 @@ const dashboardDataMap: Record<string, ModuleData> = {
167
167
  'Schedule Task Ticket',
168
168
  'Attendance',
169
169
  'Supply Management',
170
- 'Request Items',
170
+ 'Checkout Items',
171
171
  'Cleaning Schedule - Checklist, Area, Unit',
172
172
  ],
173
173
  },
@@ -26,8 +26,9 @@ export default function useDocument() {
26
26
  }
27
27
 
28
28
  function deleteById(id: string) {
29
- return useNuxtApp().$api(`/api/documents/${id}`, {
30
- method: "DELETE",
29
+ return useNuxtApp().$api<Record<string, any>>(`/api/documents/deleted/document`, {
30
+ method: "PUT",
31
+ query: { id },
31
32
  });
32
33
  }
33
34
 
@@ -76,7 +76,7 @@ export default function useFeedback() {
76
76
 
77
77
  function deleteFeedback(id: string) {
78
78
  return useNuxtApp().$api<Record<string, any>>(`/api/feedbacks/deleted/feedback`, {
79
- method: "DELETE",
79
+ method: "PUT",
80
80
  query: { id },
81
81
  });
82
82
  }
@@ -30,12 +30,10 @@ export default function useFile() {
30
30
  }
31
31
 
32
32
  function deleteFile(attachmentId: string) {
33
- return useNuxtApp().$api<Record<string, any>>(
34
- `/api/files/${attachmentId}`,
35
- {
36
- method: "DELETE",
37
- }
38
- );
33
+ return useNuxtApp().$api<Record<string, any>>(`/api/files/deleted/file`, {
34
+ method: "PUT",
35
+ query: { id: attachmentId },
36
+ });
39
37
  }
40
38
 
41
39
  function getFileById(id: string) {
@@ -0,0 +1,78 @@
1
+ export default function useLocation() {
2
+ function getCountries() {
3
+ return useNuxtApp()
4
+ .$api<Record<string, any>>("/json/country.json", {
5
+ method: "GET",
6
+ })
7
+ .then((countries) =>
8
+ countries
9
+ .map((c: any) => c.name)
10
+ .sort((a: string, b: string) => a.localeCompare(b)),
11
+ );
12
+ }
13
+
14
+ function getAddressByPostalCode(postalCode: string, country?: string) {
15
+ const countryISOMap: Record<string, string> = {
16
+ Singapore: "sg",
17
+ Malaysia: "my",
18
+ "United States": "us",
19
+ "United Kingdom": "gb",
20
+ };
21
+
22
+ const isoCode = country
23
+ ? countryISOMap[country] || country.toLowerCase()
24
+ : undefined;
25
+
26
+ return useNuxtApp()
27
+ .$api<Record<string, any>[]>(
28
+ "https://nominatim.openstreetmap.org/search",
29
+ {
30
+ method: "GET",
31
+ query: {
32
+ postalcode: postalCode,
33
+ country: isoCode,
34
+ format: "json",
35
+ limit: 1,
36
+ addressdetails: 1,
37
+ },
38
+ headers: {
39
+ "User-Agent": "iService365-Hygiene-App",
40
+ },
41
+ },
42
+ )
43
+ .then((data) => (data?.length ? data[0] : null));
44
+ }
45
+
46
+ function searchLocationByAddress({
47
+ postalCode,
48
+ city,
49
+ address,
50
+ country,
51
+ }: TLocationSearchParams) {
52
+ const searchParts = [postalCode, city, address, country].filter(Boolean);
53
+
54
+ return useNuxtApp()
55
+ .$api<Record<string, any>[]>(
56
+ "https://nominatim.openstreetmap.org/search",
57
+ {
58
+ method: "GET",
59
+ query: {
60
+ q: searchParts.join(", "),
61
+ format: "json",
62
+ limit: 1,
63
+ addressdetails: 1,
64
+ },
65
+ headers: {
66
+ "User-Agent": "iService365-Hygiene-App",
67
+ },
68
+ },
69
+ )
70
+ .then((data) => (data?.length ? data[0] : null));
71
+ }
72
+
73
+ return {
74
+ getCountries,
75
+ getAddressByPostalCode,
76
+ searchLocationByAddress,
77
+ };
78
+ }
@@ -24,19 +24,26 @@ export default function useOnlineForm() {
24
24
  });
25
25
  }
26
26
  function getOnlineFormById(id: string) {
27
- return useNuxtApp().$api<Record<string, any>>(`/api/online-forms/id/${id}`, {
28
- method: "GET",
29
- });
27
+ return useNuxtApp().$api<Record<string, any>>(
28
+ `/api/online-forms/id/${id}`,
29
+ {
30
+ method: "GET",
31
+ }
32
+ );
30
33
  }
31
34
  function updateOnlineFormById(id: string, value: any) {
32
- return useNuxtApp().$api<Record<string, any>>(`/api/online-forms/id/${id}`, {
33
- method: "PUT",
34
- body: value,
35
- });
35
+ return useNuxtApp().$api<Record<string, any>>(
36
+ `/api/online-forms/id/${id}`,
37
+ {
38
+ method: "PUT",
39
+ body: value,
40
+ }
41
+ );
36
42
  }
37
43
  function deleteOnlineFormById(id: string) {
38
- return useNuxtApp().$api(`/api/online-forms/id/${id}`, {
39
- method: "DELETE",
44
+ return useNuxtApp().$api(`/api/online-forms/deleted/online-form`, {
45
+ method: "PUT",
46
+ query: { id },
40
47
  });
41
48
  }
42
49
  function getAllBySiteId(
@@ -1,88 +1,103 @@
1
- export default function(){
2
-
3
-
4
- async function getAll({
5
- page = 1,
6
- limit = 10,
7
- sort = "asc",
8
- search = "",
9
- org = "",
10
- site = "",
11
- dateTo = "",
12
- dateFrom = "",
13
- type="",
14
- displayNoCheckOut=false
15
- } = {}) {
16
- return await useNuxtApp().$api<Record<string, any>>("/api/people", {
17
- method: "GET",
18
- query: { page, limit, sort, search, org, site, dateTo, dateFrom, type }
19
- });
1
+ export default function () {
2
+ async function getAll({
3
+ page = 1,
4
+ limit = 10,
5
+ sort = "asc",
6
+ search = "",
7
+ org = "",
8
+ site = "",
9
+ dateTo = "",
10
+ dateFrom = "",
11
+ type = "",
12
+ displayNoCheckOut = false,
13
+ } = {}) {
14
+ return await useNuxtApp().$api<Record<string, any>>("/api/people", {
15
+ method: "GET",
16
+ query: { page, limit, sort, search, org, site, dateTo, dateFrom, type },
17
+ });
20
18
  }
21
19
 
22
- async function findPersonByNRIC(nric: string): Promise<null | Partial<TPeople>> {
23
- return await $fetch<Record<string, any>>(`/api/people/nric/${nric}`, {
24
- method: "GET",
25
- });
20
+ async function findPersonByNRIC(
21
+ nric: string
22
+ ): Promise<null | Partial<TPeople>> {
23
+ return await $fetch<Record<string, any>>(`/api/people/nric/${nric}`, {
24
+ method: "GET",
25
+ });
26
26
  }
27
27
 
28
- async function findPersonByContact(contact: string): Promise<null | Partial<TPeople>> {
29
- return await $fetch<Record<string, any>>(`/api/people/contact/${contact}`, {
30
- method: "GET",
31
- });
28
+ async function findPersonByContact(
29
+ contact: string
30
+ ): Promise<null | Partial<TPeople>> {
31
+ return await $fetch<Record<string, any>>(`/api/people/contact/${contact}`, {
32
+ method: "GET",
33
+ });
32
34
  }
33
- async function findUsersByPlateNumber(plateNumber: string): Promise<null | Partial<TPeople>> {
34
- return await $fetch<Record<string, any>>(`/api/people/plateNumber/${plateNumber}`, {
35
+ async function findUsersByPlateNumber(
36
+ plateNumber: string
37
+ ): Promise<null | Partial<TPeople>> {
38
+ return await $fetch<Record<string, any>>(
39
+ `/api/people/plateNumber/${plateNumber}`,
40
+ {
35
41
  method: "GET",
36
- query: { limit: 20 }
37
- });
42
+ query: { limit: 20 },
43
+ }
44
+ );
38
45
  }
39
46
 
40
- async function searchCompanyList(company: string): Promise<null | Partial<TPeople>> {
41
- return await $fetch<Record<string, any>>('/api/people/company', {
42
- method: "GET",
43
- query: { search: company}
44
- });
47
+ async function searchCompanyList(
48
+ company: string
49
+ ): Promise<null | Partial<TPeople>> {
50
+ return await $fetch<Record<string, any>>("/api/people/company", {
51
+ method: "GET",
52
+ query: { search: company },
53
+ });
45
54
  }
46
55
 
47
- async function create(payload: Partial<TPeoplePayload>){
48
- return await useNuxtApp().$api<Record<string, any>>("/api/people", {
49
- method: "POST",
50
- body: payload,
51
- });
52
- }
56
+ async function create(payload: Partial<TPeoplePayload>) {
57
+ return await useNuxtApp().$api<Record<string, any>>("/api/people", {
58
+ method: "POST",
59
+ body: payload,
60
+ });
61
+ }
53
62
 
54
- async function updateById(_id: string, payload: Partial<TPeoplePayload>){
55
- return await useNuxtApp().$api<Record<string, any>>(`/api/people/id/${_id}`, {
63
+ async function updateById(_id: string, payload: Partial<TPeoplePayload>) {
64
+ return await useNuxtApp().$api<Record<string, any>>(
65
+ `/api/people/id/${_id}`,
66
+ {
56
67
  method: "PUT",
57
68
  body: payload,
58
- });
59
- }
69
+ }
70
+ );
71
+ }
60
72
 
61
- async function deleteById(_id: string){
62
- return await useNuxtApp().$api<Record<string, any>>(`/api/people/id/${_id}`, {
63
- method: "PUT",
64
- });
65
- }
73
+ async function deleteById(_id: string) {
74
+ return await useNuxtApp().$api<Record<string, any>>(`/api/people/${_id}`, {
75
+ method: "PUT",
76
+ });
77
+ }
66
78
 
67
- async function getPeopleByUnit( _id: string,{
68
- status = "active",
69
- type = "resident",
70
- } = {}){
71
- return await useNuxtApp().$api<Record<string, any>>(`/api/people/unit/${_id}`, {
72
- method: "GET",
73
- query: { status, type }
74
- });
75
- }
79
+ async function getPeopleByUnit(
80
+ _id: string,
81
+ { status = "active", type = "resident" } = {}
82
+ ) {
83
+ return await useNuxtApp().$api<Record<string, any>>(
84
+ `/api/people/unit/${_id}`,
85
+ {
86
+ method: "GET",
87
+ query: { status, type },
88
+ }
89
+ );
90
+ }
76
91
 
77
- return {
78
- create,
79
- getAll,
80
- updateById,
81
- deleteById,
82
- findPersonByNRIC,
83
- findPersonByContact,
84
- getPeopleByUnit,
85
- searchCompanyList,
86
- findUsersByPlateNumber
87
- }
88
- }
92
+ return {
93
+ create,
94
+ getAll,
95
+ updateById,
96
+ deleteById,
97
+ findPersonByNRIC,
98
+ findPersonByContact,
99
+ getPeopleByUnit,
100
+ searchCompanyList,
101
+ findUsersByPlateNumber,
102
+ };
103
+ }