@7365admin1/layer-common 1.11.43 → 1.11.45

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.
@@ -14,7 +14,7 @@
14
14
  :class="['ma-1', isSelected && 'selected']"
15
15
  width="150"
16
16
  height="100"
17
- @click="clickable && emit('onClickCarousel', data.path)"
17
+ @click="clickable && emit('onClickCarousel', data)"
18
18
  class="rounded-lg border-thin"
19
19
  border=" opacity-50 thin "
20
20
  >
@@ -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>
@@ -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
+ }
@@ -57,10 +57,19 @@ export default function useServiceProvider() {
57
57
  serviceProviderOrgId = "",
58
58
  orgId = "",
59
59
  siteId = "",
60
+ status = "",
60
61
  } = {}) {
61
62
  return useNuxtApp().$api<Record<string, any>>("/api/service-providers", {
62
63
  method: "GET",
63
- query: { page, search, limit, serviceProviderOrgId, orgId, siteId },
64
+ query: {
65
+ page,
66
+ search,
67
+ limit,
68
+ serviceProviderOrgId,
69
+ orgId,
70
+ siteId,
71
+ ...(status ? { status } : {}),
72
+ },
64
73
  });
65
74
  }
66
75
 
@@ -128,32 +137,36 @@ export default function useServiceProvider() {
128
137
 
129
138
  async function createServiceProviderInvite({
130
139
  email,
140
+ name = "",
141
+ app = "",
142
+ role = "",
131
143
  orgId,
132
144
  siteId,
133
145
  siteName,
134
146
  }: {
135
147
  email: string;
148
+ name?: string;
149
+ app?: string;
150
+ role?: string;
136
151
  orgId: string;
137
152
  siteId: string;
138
153
  siteName: string;
139
154
  }) {
140
- try {
141
- const res = await useNuxtApp().$api<Record<string, any>>(
142
- "/api/auth/invite/service-provider",
143
- {
144
- method: "POST",
145
- body: {
146
- email,
147
- orgId,
148
- siteId,
149
- siteName,
150
- },
151
- }
152
- );
153
- console.log(">>> response:", res);
154
- } catch (err) {
155
- console.error("Error creating service provider invite:", err);
156
- }
155
+ return useNuxtApp().$api<Record<string, any>>(
156
+ "/api/auth/invite/service-provider/with-org",
157
+ {
158
+ method: "POST",
159
+ body: {
160
+ email,
161
+ name,
162
+ app,
163
+ role,
164
+ orgId,
165
+ siteId,
166
+ siteName,
167
+ },
168
+ }
169
+ );
157
170
  }
158
171
 
159
172
  async function invite({
@@ -211,6 +224,16 @@ export default function useServiceProvider() {
211
224
  );
212
225
  }
213
226
 
227
+ async function updateStatus(id: string, status: "active" | "inactive") {
228
+ return useNuxtApp().$api<Record<string, any>>(
229
+ `/api/service-providers/${id}/status`,
230
+ {
231
+ method: "PATCH",
232
+ body: { status },
233
+ }
234
+ );
235
+ }
236
+
214
237
  return {
215
238
  serviceProviders,
216
239
  serviceProvider,
@@ -228,5 +251,6 @@ export default function useServiceProvider() {
228
251
  invite,
229
252
  add,
230
253
  addViaInvite,
254
+ updateStatus,
231
255
  };
232
256
  }
@@ -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
  };
@@ -5,7 +5,10 @@ export default function useVerification() {
5
5
  search = "",
6
6
  page = 1,
7
7
  email = "",
8
- app = ""
8
+ app = "",
9
+ siteId = "",
10
+ orgId = "",
11
+ limit = 20,
9
12
  } = {}): Promise<{
10
13
  items: TMiniVerification[];
11
14
  pages: number;
@@ -13,7 +16,7 @@ export default function useVerification() {
13
16
  }> {
14
17
  return useNuxtApp().$api("/api/verifications", {
15
18
  method: "GET",
16
- query: { status, search, page, type, email, app },
19
+ query: { status, search, page, type, email, app, siteId, orgId, limit },
17
20
  });
18
21
  }
19
22
 
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.43",
5
+ "version": "1.11.45",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "publishConfig": {