@7365admin1/layer-common 1.11.44 → 1.11.46

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,179 @@
1
+ <template>
2
+ <v-card
3
+ width="100%"
4
+ variant="outlined"
5
+ border="thin"
6
+ rounded="lg"
7
+ :loading="loading"
8
+ class="table-v3"
9
+ >
10
+ <v-toolbar density="compact" color="grey-lighten-5">
11
+ <template #prepend>
12
+ <v-btn
13
+ icon
14
+ variant="text"
15
+ density="comfortable"
16
+ class="table-v3__refresh-btn"
17
+ @click="emit('refresh')"
18
+ >
19
+ <v-icon size="28" color="black">mdi-history</v-icon>
20
+ </v-btn>
21
+ </template>
22
+
23
+ <template #append>
24
+ <v-row no-gutters justify="end" align="center">
25
+ <span class="mr-2 text-caption text-fontgray">
26
+ {{ pageRange }}
27
+ </span>
28
+ <v-btn
29
+ icon="mdi-chevron-left"
30
+ variant="text"
31
+ density="comfortable"
32
+ :disabled="!canGoPrev"
33
+ @click="goPrev"
34
+ />
35
+ <v-btn
36
+ icon="mdi-chevron-right"
37
+ variant="text"
38
+ density="comfortable"
39
+ :disabled="!canGoNext"
40
+ @click="goNext"
41
+ />
42
+ </v-row>
43
+ </template>
44
+ </v-toolbar>
45
+
46
+ <v-data-table
47
+ :headers="headers"
48
+ :items="items"
49
+ :item-value="itemValue"
50
+ :items-per-page="itemsPerPage"
51
+ fixed-header
52
+ hide-default-footer
53
+ :style="`max-height: calc(100vh - (${offset}px))`"
54
+ @click:row="(_: any, data: any) => emit('row-click', data.item)"
55
+ >
56
+ <template v-for="(_, slotName) in $slots" #[slotName]="slotProps">
57
+ <slot :name="slotName" v-bind="slotProps" />
58
+ </template>
59
+ </v-data-table>
60
+
61
+ <v-toolbar density="compact" color="grey-lighten-5" class="table-v3__footer">
62
+ <template #append>
63
+ <v-row no-gutters justify="end" align="center">
64
+ <span class="mr-2 text-caption text-fontgray">
65
+ {{ pageRange }}
66
+ </span>
67
+ <v-btn
68
+ icon="mdi-chevron-left"
69
+ variant="text"
70
+ density="comfortable"
71
+ :disabled="!canGoPrev"
72
+ @click="goPrev"
73
+ />
74
+ <v-btn
75
+ icon="mdi-chevron-right"
76
+ variant="text"
77
+ density="comfortable"
78
+ :disabled="!canGoNext"
79
+ @click="goNext"
80
+ />
81
+ </v-row>
82
+ </template>
83
+ </v-toolbar>
84
+ </v-card>
85
+ </template>
86
+
87
+ <script setup lang="ts">
88
+ const props = defineProps({
89
+ headers: {
90
+ type: Array as PropType<Array<Record<string, any>>>,
91
+ required: true,
92
+ },
93
+ items: {
94
+ type: Array as PropType<Array<Record<string, any>>>,
95
+ default: () => [],
96
+ },
97
+ loading: {
98
+ type: Boolean,
99
+ default: false,
100
+ },
101
+ itemValue: {
102
+ type: String,
103
+ default: "_id",
104
+ },
105
+ itemsPerPage: {
106
+ type: Number,
107
+ default: 20,
108
+ },
109
+ page: {
110
+ type: Number,
111
+ default: 1,
112
+ },
113
+ pages: {
114
+ type: Number,
115
+ default: 0,
116
+ },
117
+ pageRange: {
118
+ type: String,
119
+ default: "-- - -- of --",
120
+ },
121
+ offset: {
122
+ type: Number,
123
+ default: 220,
124
+ },
125
+ });
126
+
127
+ const emit = defineEmits(["refresh", "update:page", "row-click"]);
128
+
129
+ const internalPage = ref(props.page);
130
+ const canGoPrev = computed(() => internalPage.value > 1);
131
+ const canGoNext = computed(
132
+ () => props.pages > 0 && internalPage.value < props.pages
133
+ );
134
+
135
+ function goPrev() {
136
+ if (!canGoPrev.value) {
137
+ return;
138
+ }
139
+ internalPage.value -= 1;
140
+ emit("update:page", internalPage.value);
141
+ }
142
+
143
+ function goNext() {
144
+ if (!canGoNext.value) {
145
+ return;
146
+ }
147
+ internalPage.value += 1;
148
+ emit("update:page", internalPage.value);
149
+ }
150
+
151
+ watch(
152
+ () => props.page,
153
+ (val) => {
154
+ internalPage.value = val;
155
+ }
156
+ );
157
+ </script>
158
+
159
+ <style scoped>
160
+ .table-v3 :deep(thead th) {
161
+ background-color: #f5f5f5;
162
+ color: #6b7280;
163
+ font-weight: 600 !important;
164
+ font-size: 12px;
165
+ }
166
+
167
+ .table-v3 :deep(tbody td) {
168
+ height: 54px;
169
+ }
170
+
171
+ .table-v3__footer {
172
+ border-top: 1px solid rgba(0, 0, 0, 0.08);
173
+ }
174
+
175
+ .table-v3__refresh-btn {
176
+ width: 38px;
177
+ height: 38px;
178
+ }
179
+ </style>
@@ -299,7 +299,15 @@ export default function useAccessManagement() {
299
299
  );
300
300
  }
301
301
 
302
+ function getResidents(params: { orgId: string; siteId: string; unitId: string }) {
303
+ return useNuxtApp().$api<{ data: Record<string, any>[] }>(
304
+ `/api/access-management/residents`,
305
+ { method: "GET", query: params }
306
+ );
307
+ }
308
+
302
309
  return {
310
+ getResidents,
303
311
  getDoorAccessLevels,
304
312
  getLiftAccessLevels,
305
313
  getAccessGroups,
@@ -171,7 +171,14 @@ export default function useOrg() {
171
171
  ) as TOrg;
172
172
  });
173
173
  }
174
-
174
+ function getOrgsByEmail(email = "") {
175
+ return useNuxtApp().$api<TOrg[]>(
176
+ `/api/organizations/orgs/${email}`,
177
+ {
178
+ method: "GET",
179
+ }
180
+ );
181
+ }
175
182
 
176
183
  return {
177
184
  org,
@@ -189,5 +196,6 @@ export default function useOrg() {
189
196
  add,
190
197
  addOnboardingOrg,
191
198
  updateOrg,
199
+ getOrgsByEmail
192
200
  };
193
201
  }
@@ -0,0 +1,11 @@
1
+ export default function useOrganizationSwitcher() {
2
+ const selectedOrg = useState<any | null>('selected-org', () => null)
3
+ const selectedApp = useState<string>('selected-app', () => '')
4
+
5
+ function setOrganization({ org, app }: { org: any; app: string }) {
6
+ selectedOrg.value = org
7
+ selectedApp.value = app || org?.nature || ''
8
+ }
9
+
10
+ return { selectedOrg, selectedApp, setOrganization }
11
+ }
@@ -14,7 +14,18 @@ export default function () {
14
14
  } = {}) {
15
15
  return await useNuxtApp().$api<Record<string, any>>("/api/people", {
16
16
  method: "GET",
17
- query: { page, limit, sort, search, org, site, dateTo, dateFrom, type, status },
17
+ query: {
18
+ page,
19
+ limit,
20
+ sort,
21
+ search,
22
+ org,
23
+ site,
24
+ dateTo,
25
+ dateFrom,
26
+ type,
27
+ status,
28
+ },
18
29
  });
19
30
  }
20
31
 
@@ -26,12 +37,10 @@ export default function () {
26
37
  });
27
38
  }
28
39
 
29
- async function findPersonByNRICMultipleResult(
30
- nric: string, site: string
31
- ){
40
+ async function findPersonByNRICMultipleResult(nric: string, site: string) {
32
41
  return await $fetch<Record<any, any>>(`/api/people/all-nric`, {
33
42
  method: "GET",
34
- query: { nric, site }
43
+ query: { nric, site },
35
44
  });
36
45
  }
37
46
 
@@ -98,6 +107,15 @@ export default function () {
98
107
  }
99
108
  );
100
109
  }
110
+ async function reviewResidentPerson(
111
+ _id: string,
112
+ payload: Partial<TPeoplePayload>
113
+ ) {
114
+ return await useNuxtApp().$api<Record<string, any>>(`/api/people/${_id}`, {
115
+ method: "PATCH",
116
+ body: payload,
117
+ });
118
+ }
101
119
 
102
120
  return {
103
121
  create,
@@ -110,5 +128,6 @@ export default function () {
110
128
  getPeopleByUnit,
111
129
  searchCompanyList,
112
130
  findUsersByPlateNumber,
131
+ reviewResidentPerson,
113
132
  };
114
133
  }
@@ -14,36 +14,36 @@ export default function useUser() {
14
14
  });
15
15
  }
16
16
 
17
- function inviteUserClient({
18
- email = '',
19
- app = [],
20
- role = '',
21
- name = '',
22
- org = '',
23
- site = '',
24
- siteName = ''
25
- }: {
26
- email?: string
27
- app?: string[]
28
- role?: string
29
- name?: string
30
- org?: string
31
- site?: string
32
- siteName?: string
33
- } = {}) {
34
- return useNuxtApp().$api<Record<string, any>>('/api/auth/invite/user', {
35
- method: 'POST',
36
- body: {
37
- email,
38
- app,
39
- role,
40
- name,
41
- org,
42
- ...(site && { siteId: site }),
43
- ...(siteName && { siteName })
44
- }
45
- })
46
- }
17
+ function inviteUserClient({
18
+ email = '',
19
+ app = [],
20
+ role = '',
21
+ name = '',
22
+ org = '',
23
+ site = '',
24
+ siteName = ''
25
+ }: {
26
+ email?: string
27
+ app?: string[]
28
+ role?: string
29
+ name?: string
30
+ org?: string
31
+ site?: string
32
+ siteName?: string
33
+ } = {}) {
34
+ return useNuxtApp().$api<Record<string, any>>('/api/auth/invite/user', {
35
+ method: 'POST',
36
+ body: {
37
+ email,
38
+ app,
39
+ role,
40
+ name,
41
+ org,
42
+ ...(site && { siteId: site }),
43
+ ...(siteName && { siteName })
44
+ }
45
+ })
46
+ }
47
47
 
48
48
  function inviteMemberClient({
49
49
  email = "",
@@ -168,6 +168,11 @@ function inviteUserClient({
168
168
  method: "GET"
169
169
  });
170
170
  }
171
+ function getUserByEmailV2(email = "") {
172
+ return useNuxtApp().$api<Record<string, any>>(`/api/users/user/${email}`, {
173
+ method: "GET"
174
+ });
175
+ }
171
176
 
172
177
  return {
173
178
  inviteUser,
@@ -183,6 +188,7 @@ function inviteUserClient({
183
188
  getById,
184
189
  createUserByVerification,
185
190
  getUserByEmail,
191
+ getUserByEmailV2,
186
192
  inviteUserClient,
187
193
  inviteMemberClient
188
194
  };
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.11.44",
5
+ "version": "1.11.46",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "publishConfig": {
package/types/people.d.ts CHANGED
@@ -25,6 +25,6 @@ declare type TPeople = {
25
25
  declare type TPlateNumber = { plateNumber: string, recNo: string, _id?: string, status: "active" | "deleted" | "pending", type: TVehicleType };
26
26
 
27
27
 
28
- declare type TPeoplePayload = Pick<TGuest, "name" | "block" | "level" | "unit" | "unitName" | "contact" | "plateNumber" | "nric" | "contact" | "remarks" | "org" | "site" | "start" | "end" | "type" | "isOwner">
28
+ declare type TPeoplePayload = Pick<TGuest, "name" | "block" | "level" | "unit" | "unitName" | "contact" | "plateNumber" | "nric" | "contact" | "remarks" | "org" | "site" | "start" | "end" | "type" | "isOwner"> & { status?: string }
29
29
 
30
30
  declare type TPeopleType = "guest" | "resident" | "tenant"