@iservice365/layer-common 1.5.5 → 1.5.7

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,425 @@
1
+ export interface DashboardCard {
2
+ title: string;
3
+ value: number;
4
+ percentage: number;
5
+ isPositive: boolean;
6
+ icon: string;
7
+ color: string;
8
+ }
9
+
10
+ export interface ModuleData {
11
+ name: string;
12
+ cards: DashboardCard[];
13
+ modules: string[];
14
+ }
15
+
16
+ export interface FeedbackData {
17
+ _id: string;
18
+ name: string;
19
+ }
20
+
21
+ export interface FeedbackChartData {
22
+ "This Week": any[];
23
+ "This Month": any[];
24
+ "This Year": any[];
25
+ }
26
+
27
+ export interface PeriodMultiplier {
28
+ "This Week": number;
29
+ "This Month": number;
30
+ "This Year": number;
31
+ }
32
+
33
+ const dashboardDataMap: Record<string, ModuleData> = {
34
+ security: {
35
+ name: 'Security',
36
+ cards: [
37
+ {
38
+ title: 'Feedback',
39
+ value: 45,
40
+ percentage: 12.5,
41
+ isPositive: true,
42
+ icon: 'mdi-comment-multiple',
43
+ color: '#1E88E5',
44
+ },
45
+ {
46
+ title: 'Work Orders',
47
+ value: 28,
48
+ percentage: 8.3,
49
+ isPositive: true,
50
+ icon: 'mdi-clipboard-list',
51
+ color: '#D32F2F',
52
+ },
53
+ {
54
+ title: 'Vehicle Management',
55
+ value: 12,
56
+ percentage: 5.2,
57
+ isPositive: true,
58
+ icon: 'mdi-truck',
59
+ color: '#FFA726',
60
+ },
61
+ {
62
+ title: 'Building Management',
63
+ value: 35,
64
+ percentage: 15.4,
65
+ isPositive: true,
66
+ icon: 'mdi-building',
67
+ color: '#43A047',
68
+ },
69
+ {
70
+ title: 'Visitor Management',
71
+ value: 22,
72
+ percentage: 6.8,
73
+ isPositive: true,
74
+ icon: 'mdi-account-multiple',
75
+ color: '#7E57C2',
76
+ },
77
+ {
78
+ title: 'Incident Reports',
79
+ value: 9,
80
+ percentage: -3.5,
81
+ isPositive: false,
82
+ icon: 'mdi-alert-circle',
83
+ color: '#EF5350',
84
+ },
85
+ {
86
+ title: 'Guest Management',
87
+ value: 18,
88
+ percentage: 4.2,
89
+ isPositive: true,
90
+ icon: 'mdi-account-badge',
91
+ color: '#AB47BC',
92
+ },
93
+ ],
94
+ modules: [
95
+ 'Feedback',
96
+ 'Work Orders',
97
+ 'Vehicle Management',
98
+ 'Building Management',
99
+ 'Visitor Management',
100
+ 'Incident Reports',
101
+ 'Guest Management',
102
+ ],
103
+ },
104
+ hygiene: {
105
+ name: 'Hygiene',
106
+ cards: [
107
+ {
108
+ title: 'Feedback',
109
+ value: 52,
110
+ percentage: 14.2,
111
+ isPositive: true,
112
+ icon: 'mdi-comment-multiple',
113
+ color: '#1E88E5',
114
+ },
115
+ {
116
+ title: 'Work Orders',
117
+ value: 38,
118
+ percentage: 11.3,
119
+ isPositive: true,
120
+ icon: 'mdi-clipboard-list',
121
+ color: '#D32F2F',
122
+ },
123
+ {
124
+ title: 'Schedule Task Ticket',
125
+ value: 25,
126
+ percentage: 7.8,
127
+ isPositive: true,
128
+ icon: 'mdi-calendar-check',
129
+ color: '#FFA726',
130
+ },
131
+ {
132
+ title: 'Attendance',
133
+ value: 64,
134
+ percentage: 18.9,
135
+ isPositive: true,
136
+ icon: 'mdi-clock-check',
137
+ color: '#43A047',
138
+ },
139
+ {
140
+ title: 'Supply Management',
141
+ value: 42,
142
+ percentage: 12.5,
143
+ isPositive: true,
144
+ icon: 'mdi-warehouse',
145
+ color: '#7E57C2',
146
+ },
147
+ {
148
+ title: 'Request Items',
149
+ value: 19,
150
+ percentage: 5.1,
151
+ isPositive: true,
152
+ icon: 'mdi-cart-plus',
153
+ color: '#29B6F6',
154
+ },
155
+ {
156
+ title: 'Cleaning Schedule',
157
+ value: 31,
158
+ percentage: 9.4,
159
+ isPositive: true,
160
+ icon: 'mdi-broom',
161
+ color: '#66BB6A',
162
+ },
163
+ ],
164
+ modules: [
165
+ 'Feedback',
166
+ 'Work Orders',
167
+ 'Schedule Task Ticket',
168
+ 'Attendance',
169
+ 'Supply Management',
170
+ 'Request Items',
171
+ 'Cleaning Schedule - Checklist, Area, Unit',
172
+ ],
173
+ },
174
+ landscaping: {
175
+ name: 'Landscaping',
176
+ cards: [
177
+ {
178
+ title: 'Feedback',
179
+ value: 33,
180
+ percentage: 10.5,
181
+ isPositive: true,
182
+ icon: 'mdi-comment-multiple',
183
+ color: '#1E88E5',
184
+ },
185
+ {
186
+ title: 'Work Orders',
187
+ value: 47,
188
+ percentage: 13.2,
189
+ isPositive: true,
190
+ icon: 'mdi-clipboard-list',
191
+ color: '#D32F2F',
192
+ },
193
+ ],
194
+ modules: [
195
+ 'Feedback',
196
+ 'Work Orders',
197
+ ],
198
+ },
199
+ mechanical_electrical: {
200
+ name: 'Mechanical & Electrical',
201
+ cards: [
202
+ {
203
+ title: 'Feedback',
204
+ value: 38,
205
+ percentage: 11.8,
206
+ isPositive: true,
207
+ icon: 'mdi-comment-multiple',
208
+ color: '#1E88E5',
209
+ },
210
+ {
211
+ title: 'Work Orders',
212
+ value: 52,
213
+ percentage: 15.7,
214
+ isPositive: true,
215
+ icon: 'mdi-clipboard-list',
216
+ color: '#D32F2F',
217
+ },
218
+ ],
219
+ modules: [
220
+ 'Feedback',
221
+ 'Work Orders',
222
+ ],
223
+ },
224
+ pool: {
225
+ name: 'Pool',
226
+ cards: [
227
+ {
228
+ title: 'Feedback',
229
+ value: 29,
230
+ percentage: 9.3,
231
+ isPositive: true,
232
+ icon: 'mdi-comment-multiple',
233
+ color: '#1E88E5',
234
+ },
235
+ {
236
+ title: 'Work Orders',
237
+ value: 41,
238
+ percentage: 12.1,
239
+ isPositive: true,
240
+ icon: 'mdi-clipboard-list',
241
+ color: '#D32F2F',
242
+ },
243
+ ],
244
+ modules: [
245
+ 'Feedback',
246
+ 'Work Orders',
247
+ ],
248
+ },
249
+ pest: {
250
+ name: 'Pest',
251
+ cards: [
252
+ {
253
+ title: 'Feedback',
254
+ value: 26,
255
+ percentage: 8.6,
256
+ isPositive: true,
257
+ icon: 'mdi-comment-multiple',
258
+ color: '#1E88E5',
259
+ },
260
+ {
261
+ title: 'Work Orders',
262
+ value: 35,
263
+ percentage: 10.2,
264
+ isPositive: true,
265
+ icon: 'mdi-clipboard-list',
266
+ color: '#D32F2F',
267
+ },
268
+ ],
269
+ modules: [
270
+ 'Feedback',
271
+ 'Work Orders',
272
+ ],
273
+ },
274
+ };
275
+
276
+ // Feedback items data for dropdowns
277
+ const feedbackItemsMap: Record<string, FeedbackData[]> = {
278
+ security: [
279
+ { _id: "sec-1", name: "Perimeter Security" },
280
+ { _id: "sec-2", name: "Access Control" },
281
+ { _id: "sec-3", name: "CCTV Monitoring" },
282
+ { _id: "sec-4", name: "Guard Services" },
283
+ ],
284
+ hygiene: [
285
+ { _id: "hyg-1", name: "Cleaning Services" },
286
+ { _id: "hyg-2", name: "Disinfection" },
287
+ { _id: "hyg-3", name: "Waste Management" },
288
+ { _id: "hyg-4", name: "Sanitation" },
289
+ ],
290
+ landscaping: [
291
+ { _id: "land-1", name: "Lawn Care" },
292
+ { _id: "land-2", name: "Garden Maintenance" },
293
+ { _id: "land-3", name: "Landscaping Design" },
294
+ { _id: "land-4", name: "Tree Service" },
295
+ ],
296
+ mechanical_electrical: [
297
+ { _id: "me-1", name: "Electrical Services" },
298
+ { _id: "me-2", name: "HVAC Maintenance" },
299
+ { _id: "me-3", name: "Equipment Repair" },
300
+ { _id: "me-4", name: "System Inspection" },
301
+ ],
302
+ pool: [
303
+ { _id: "pool-1", name: "Water Treatment" },
304
+ { _id: "pool-2", name: "Equipment Maintenance" },
305
+ { _id: "pool-3", name: "Cleaning Services" },
306
+ { _id: "pool-4", name: "Safety Inspection" },
307
+ ],
308
+ pest: [
309
+ { _id: "pest-1", name: "Pest Control" },
310
+ { _id: "pest-2", name: "Fumigation" },
311
+ { _id: "pest-3", name: "Prevention Services" },
312
+ { _id: "pest-4", name: "Inspection" },
313
+ ],
314
+ };
315
+
316
+ // Feedback chart data based on selected service
317
+ const feedbackChartDataMap: Record<string, FeedbackChartData> = {
318
+ "sec-1": {
319
+ "This Week": [
320
+ { x: 100, y: 260, width: 60, height: 30, value: 5, label: "1", color: "#2196F3" },
321
+ { x: 200, y: 194, width: 60, height: 96, value: 16, label: "2", color: "#2196F3" },
322
+ { x: 300, y: 230, width: 60, height: 60, value: 10, label: "3", color: "#2196F3" },
323
+ { x: 400, y: 248, width: 60, height: 42, value: 7, label: "4", color: "#2196F3" },
324
+ { x: 500, y: 272, width: 60, height: 18, value: 3, label: "5", color: "#2196F3" },
325
+ { x: 600, y: 260, width: 60, height: 30, value: 5, label: "6", color: "#2196F3" },
326
+ { x: 700, y: 212, width: 60, height: 78, value: 13, label: "7", color: "#2196F3" },
327
+ { x: 800, y: 200, width: 60, height: 90, value: 15, label: "8", color: "#2196F3" },
328
+ { x: 900, y: 80, width: 60, height: 210, value: 70, label: "9", color: "#2196F3" },
329
+ ],
330
+ "This Month": [
331
+ { x: 100, y: 254, width: 60, height: 36, value: 6, label: "1", color: "#2196F3" },
332
+ { x: 200, y: 140, width: 60, height: 150, value: 25, label: "2", color: "#2196F3" },
333
+ { x: 300, y: 194, width: 60, height: 96, value: 16, label: "3", color: "#2196F3" },
334
+ { x: 400, y: 212, width: 60, height: 78, value: 13, label: "4", color: "#2196F3" },
335
+ { x: 500, y: 230, width: 60, height: 60, value: 10, label: "5", color: "#2196F3" },
336
+ { x: 600, y: 248, width: 60, height: 42, value: 7, label: "6", color: "#2196F3" },
337
+ { x: 700, y: 158, width: 60, height: 132, value: 22, label: "7", color: "#2196F3" },
338
+ { x: 800, y: 176, width: 60, height: 114, value: 19, label: "8", color: "#2196F3" },
339
+ { x: 900, y: 50, width: 60, height: 240, value: 80, label: "9", color: "#2196F3" },
340
+ ],
341
+ "This Year": [
342
+ { x: 100, y: 236, width: 60, height: 54, value: 9, label: "1", color: "#2196F3" },
343
+ { x: 200, y: 104, width: 60, height: 186, value: 31, label: "2", color: "#2196F3" },
344
+ { x: 300, y: 176, width: 60, height: 114, value: 19, label: "3", color: "#2196F3" },
345
+ { x: 400, y: 194, width: 60, height: 96, value: 16, label: "4", color: "#2196F3" },
346
+ { x: 500, y: 212, width: 60, height: 78, value: 13, label: "5", color: "#2196F3" },
347
+ { x: 600, y: 230, width: 60, height: 60, value: 10, label: "6", color: "#2196F3" },
348
+ { x: 700, y: 122, width: 60, height: 168, value: 28, label: "7", color: "#2196F3" },
349
+ { x: 800, y: 158, width: 60, height: 132, value: 22, label: "8", color: "#2196F3" },
350
+ { x: 900, y: 20, width: 60, height: 270, value: 90, label: "9", color: "#2196F3" },
351
+ ],
352
+ },
353
+ "sec-2": {
354
+ "This Week": [
355
+ { x: 100, y: 272, width: 60, height: 18, value: 3, label: "1", color: "#4CAF50" },
356
+ { x: 200, y: 176, width: 60, height: 114, value: 19, label: "2", color: "#4CAF50" },
357
+ { x: 300, y: 230, width: 60, height: 60, value: 10, label: "3", color: "#4CAF50" },
358
+ { x: 400, y: 248, width: 60, height: 42, value: 7, label: "4", color: "#4CAF50" },
359
+ { x: 500, y: 260, width: 60, height: 30, value: 5, label: "5", color: "#4CAF50" },
360
+ { x: 600, y: 272, width: 60, height: 18, value: 3, label: "6", color: "#4CAF50" },
361
+ { x: 700, y: 194, width: 60, height: 96, value: 16, label: "7", color: "#4CAF50" },
362
+ { x: 800, y: 188, width: 60, height: 102, value: 17, label: "8", color: "#4CAF50" },
363
+ { x: 900, y: 32, width: 60, height: 258, value: 86, label: "9", color: "#4CAF50" },
364
+ ],
365
+ "This Month": [
366
+ { x: 100, y: 254, width: 60, height: 36, value: 6, label: "1", color: "#4CAF50" },
367
+ { x: 200, y: 140, width: 60, height: 150, value: 25, label: "2", color: "#4CAF50" },
368
+ { x: 300, y: 194, width: 60, height: 96, value: 16, label: "3", color: "#4CAF50" },
369
+ { x: 400, y: 212, width: 60, height: 78, value: 13, label: "4", color: "#4CAF50" },
370
+ { x: 500, y: 230, width: 60, height: 60, value: 10, label: "5", color: "#4CAF50" },
371
+ { x: 600, y: 248, width: 60, height: 42, value: 7, label: "6", color: "#4CAF50" },
372
+ { x: 700, y: 158, width: 60, height: 132, value: 22, label: "7", color: "#4CAF50" },
373
+ { x: 800, y: 176, width: 60, height: 114, value: 19, label: "8", color: "#4CAF50" },
374
+ { x: 900, y: 50, width: 60, height: 240, value: 80, label: "9", color: "#4CAF50" },
375
+ ],
376
+ "This Year": [
377
+ { x: 100, y: 236, width: 60, height: 54, value: 9, label: "1", color: "#4CAF50" },
378
+ { x: 200, y: 104, width: 60, height: 186, value: 31, label: "2", color: "#4CAF50" },
379
+ { x: 300, y: 176, width: 60, height: 114, value: 19, label: "3", color: "#4CAF50" },
380
+ { x: 400, y: 194, width: 60, height: 96, value: 16, label: "4", color: "#4CAF50" },
381
+ { x: 500, y: 212, width: 60, height: 78, value: 13, label: "5", color: "#4CAF50" },
382
+ { x: 600, y: 230, width: 60, height: 60, value: 10, label: "6", color: "#4CAF50" },
383
+ { x: 700, y: 122, width: 60, height: 168, value: 28, label: "7", color: "#4CAF50" },
384
+ { x: 800, y: 158, width: 60, height: 132, value: 22, label: "8", color: "#4CAF50" },
385
+ { x: 900, y: 20, width: 60, height: 270, value: 90, label: "9", color: "#4CAF50" },
386
+ ],
387
+ },
388
+ };
389
+
390
+ // Period multipliers for card data
391
+ const periodMultipliers: PeriodMultiplier = {
392
+ "This Week": 1.0,
393
+ "This Month": 4.3, // approx. weeks in a month
394
+ "This Year": 52.0, // weeks in a year
395
+ };
396
+
397
+ export const useDashboardData = (appName: string) => {
398
+ const normalizedName = appName.toLowerCase();
399
+
400
+ // Try exact match first
401
+ let moduleKey = normalizedName;
402
+
403
+ // If exact match not found, try partial matching
404
+ if (!dashboardDataMap[moduleKey]) {
405
+ if (normalizedName.includes('landscaping')) moduleKey = 'landscaping';
406
+ else if (normalizedName.includes('mechanical') || normalizedName.includes('electrical')) moduleKey = 'mechanical_electrical';
407
+ else if (normalizedName.includes('pool')) moduleKey = 'pool';
408
+ else if (normalizedName.includes('pest')) moduleKey = 'pest';
409
+ else if (normalizedName.includes('hygiene')) moduleKey = 'hygiene';
410
+ else if (normalizedName.includes('security')) moduleKey = 'security';
411
+ else moduleKey = 'security'; // default fallback
412
+ }
413
+
414
+ const moduleData = dashboardDataMap[moduleKey] || dashboardDataMap.security;
415
+ const feedbackItems = feedbackItemsMap[moduleKey] || feedbackItemsMap.security;
416
+
417
+ return {
418
+ moduleData,
419
+ cards: moduleData.cards,
420
+ modules: moduleData.modules,
421
+ feedbackItems,
422
+ feedbackChartDataMap,
423
+ periodMultipliers,
424
+ };
425
+ };
@@ -0,0 +1,27 @@
1
+ export default function useDocument() {
2
+ function getAll({
3
+ page = 1,
4
+ search = "",
5
+ limit = 10,
6
+ status = "active",
7
+ site = "",
8
+ } = {}) {
9
+ return useNuxtApp().$api<Record<string, any>>(
10
+ `/api/documents`,
11
+ {
12
+ method: "GET",
13
+ query: {
14
+ page,
15
+ search,
16
+ limit,
17
+ status,
18
+ site,
19
+ },
20
+ }
21
+ );
22
+ }
23
+
24
+ return {
25
+ getAll,
26
+ };
27
+ }
@@ -36,7 +36,18 @@ export default function () {
36
36
  }
37
37
  );
38
38
  }
39
-
39
+ async function updateSitebyId(
40
+ siteId: string,
41
+ payload: { field: string; value: number }
42
+ ) {
43
+ return await useNuxtApp().$api<Record<string, any>>(
44
+ `/api/sites/id/${siteId}`,
45
+ {
46
+ method: "PATCH",
47
+ body: payload,
48
+ }
49
+ );
50
+ }
40
51
  async function addCamera(camera: TSiteCamera) {
41
52
  return await useNuxtApp().$api<Record<string, any>>(`/api/site-cameras`, {
42
53
  method: "POST",
@@ -107,5 +118,6 @@ export default function () {
107
118
  setSiteGuardPosts,
108
119
  updateSiteCamera,
109
120
  deleteSiteCameraById,
121
+ updateSitebyId,
110
122
  };
111
123
  }
@@ -64,6 +64,13 @@ export default function useWorkOrder() {
64
64
  });
65
65
  }
66
66
 
67
+ function updateWorkOrder(id: string, payload: object) {
68
+ return useNuxtApp().$api<Record<string, any>>(`/api/work-orders/${id}`, {
69
+ method: "PUT",
70
+ body: payload,
71
+ });
72
+ }
73
+
67
74
  return {
68
75
  workOrders,
69
76
  workOrder,
@@ -73,5 +80,6 @@ export default function useWorkOrder() {
73
80
  createWorkOrder,
74
81
  getWorkOrders,
75
82
  getWorkOrderById,
83
+ updateWorkOrder,
76
84
  };
77
85
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@iservice365/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "1.5.5",
5
+ "version": "1.5.7",
6
6
  "main": "./nuxt.config.ts",
7
7
  "scripts": {
8
8
  "dev": "nuxi dev .playground",
@@ -0,0 +1,5 @@
1
+ declare type TDocument = {
2
+ _id?: string;
3
+ name: string;
4
+ attachment: string[];
5
+ };