@7365admin1/layer-common 1.11.41 → 1.11.43

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.
@@ -10,7 +10,7 @@ export default function useFile() {
10
10
  const formData = new FormData();
11
11
  formData.append("file", file);
12
12
 
13
- return $fetch<Record<string, any>>("/api/files", {
13
+ return useNuxtApp().$api<Record<string, any>>("/api/files", {
14
14
  method: "POST",
15
15
  body: formData,
16
16
  });
@@ -141,6 +141,17 @@ export default function useLocalAuth() {
141
141
  });
142
142
  }
143
143
 
144
+ function verifyInvite(inviteId: string) {
145
+ if (!inviteId) throw new Error("inviteId is required");
146
+
147
+ return useNuxtApp().$api<Record<string, any>>(
148
+ `/api/auth/verify/invite/${inviteId}`,
149
+ {
150
+ method: "GET",
151
+ }
152
+ );
153
+ }
154
+
144
155
  async function updateVerificationStatus(id: string, status: string) {
145
156
  return useNuxtApp().$api<Record<string, any>>(`/api/auth/verification/status`, {
146
157
  method: "PATCH",
@@ -166,6 +177,7 @@ export default function useLocalAuth() {
166
177
  resetPassword,
167
178
  currentUser,
168
179
  verify,
180
+ verifyInvite,
169
181
  updateVerificationStatus,
170
182
  signUp,
171
183
  };
@@ -25,6 +25,13 @@ export default function useMember() {
25
25
  return useNuxtApp().$api<TMember>(`/api/members/user/${user}`);
26
26
  }
27
27
 
28
+ function getAllByUserId(user: string) {
29
+ return useNuxtApp().$api<TMember>(`/api/members/users/${user}`);
30
+ }
31
+ function getByMemberId(user: string) {
32
+ return useNuxtApp().$api<TMember>(`/api//user/${user}`);
33
+ }
34
+
28
35
  function getByUserIdType(user: string, type: string) {
29
36
  return useNuxtApp().$api<TMember>(`/api/members/user/${user}/app/${type}`);
30
37
  }
@@ -94,19 +101,36 @@ export default function useMember() {
94
101
  );
95
102
  }
96
103
 
97
- function createMemberDirect(payload: {
98
- userId: string;
99
- orgId: string;
100
- roleId: string;
101
- app: string;
102
- siteId?: string;
103
- siteName?:string;
104
- }) {
105
- return useNuxtApp().$api<TMember>('/api/members/direct', {
106
- method: 'POST',
107
- body: payload,
108
- })
109
- }
104
+ function createMemberDirect(payload: {
105
+ userId: string;
106
+ orgId: string;
107
+ roleId: string;
108
+ app: string;
109
+ siteId?: string;
110
+ siteName?: string;
111
+ }) {
112
+ return useNuxtApp().$api<TMember>('/api/members/direct', {
113
+ method: 'POST',
114
+ body: payload,
115
+ })
116
+ }
117
+ function updateMemberSite(
118
+ id: string,
119
+ siteId: string,
120
+ siteName: string,
121
+ ) {
122
+ return useNuxtApp().$api(
123
+ `/api/members/site`,
124
+ {
125
+ method: "PUT",
126
+ body: {
127
+ id,
128
+ siteId,
129
+ siteName,
130
+ },
131
+ }
132
+ )
133
+ }
110
134
 
111
135
  return {
112
136
  members,
@@ -120,8 +144,11 @@ function createMemberDirect(payload: {
120
144
  createUserByVerification,
121
145
  createMemberInvite,
122
146
  getByUserIdType,
147
+ getByMemberId,
123
148
  updateMemberStatus,
124
149
  updateMemberRole,
125
- createMemberDirect
150
+ createMemberDirect,
151
+ updateMemberSite,
152
+ getAllByUserId
126
153
  };
127
154
  }
@@ -1,3 +1,7 @@
1
+ import { computed, watch } from "vue";
2
+ import { useNuxtApp, useRoute, useState } from "#app";
3
+ import useLocalAuth from "./useLocalAuth";
4
+
1
5
  export default function useOrg() {
2
6
  function getOrgs({
3
7
  page = 1,
@@ -103,6 +107,32 @@ export default function useOrg() {
103
107
  });
104
108
  }
105
109
 
110
+ /** Super Admin client list, etc.: filter by `organizations.status` (v1 API ignores status). */
111
+ function getAllV2({
112
+ page = 1,
113
+ search = "",
114
+ limit = 20,
115
+ nature = "",
116
+ status = "active",
117
+ }: {
118
+ page?: number;
119
+ search?: string;
120
+ limit?: number;
121
+ nature?: string;
122
+ status?: "active" | "suspended" | "deleted";
123
+ } = {}) {
124
+ return useNuxtApp().$api<Record<string, any>>("/api/organizations/v2", {
125
+ method: "GET",
126
+ query: {
127
+ page,
128
+ search,
129
+ limit,
130
+ nature,
131
+ status,
132
+ },
133
+ });
134
+ }
135
+
106
136
  function add(
107
137
  value: Partial<Pick<TOrg, "name" | "email" | "nature" | "contact">>
108
138
  ) {
@@ -113,7 +143,7 @@ export default function useOrg() {
113
143
  }
114
144
 
115
145
  function addOnboardingOrg(
116
- value: Partial<Pick<TOrg, "name" | "email" | "nature" | "contact">>
146
+ value: Partial<Pick<TOrg, "name" | "type" | "email" | "nature" | "contact">>
117
147
  ) {
118
148
  return useNuxtApp()
119
149
  .$api<Record<string, any>>("/api/organizations", {
@@ -126,6 +156,22 @@ export default function useOrg() {
126
156
  ) as TOrg;
127
157
  });
128
158
  }
159
+ function updateOrg(
160
+ id: string,
161
+ value: Partial<Pick<TOrg, "name" | "type" | "email" | "nature" | "contact">>
162
+ ) {
163
+ return useNuxtApp()
164
+ .$api<Record<string, any>>(`/api/organizations/${id}`, {
165
+ method: "PUT",
166
+ body: value,
167
+ })
168
+ .then((response: Record<string, any>) => {
169
+ return (
170
+ response?.data ?? response?.organization ?? response
171
+ ) as TOrg;
172
+ });
173
+ }
174
+
129
175
 
130
176
  return {
131
177
  org,
@@ -139,7 +185,9 @@ export default function useOrg() {
139
185
  currentOrg,
140
186
  getById,
141
187
  getAll,
188
+ getAllV2,
142
189
  add,
143
190
  addOnboardingOrg,
191
+ updateOrg,
144
192
  };
145
193
  }
@@ -14,17 +14,48 @@ 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 = ''
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
+
48
+ function inviteMemberClient({
49
+ email = "",
50
+ app = "",
51
+ role = "",
52
+ name = "",
53
+ org = "",
54
+ site = "",
55
+ siteName = "",
25
56
  } = {}) {
26
- return useNuxtApp().$api<Record<string, any>>('/api/auth/invite/user', {
27
- method: 'POST',
57
+ return useNuxtApp().$api<Record<string, any>>("/api/auth/invite/member", {
58
+ method: "POST",
28
59
  body: {
29
60
  email,
30
61
  app,
@@ -32,9 +63,9 @@ export default function useUser() {
32
63
  name,
33
64
  org,
34
65
  ...(site && { siteId: site }),
35
- ...(siteName && { siteName })
36
- }
37
- })
66
+ ...(siteName && { siteName }),
67
+ },
68
+ });
38
69
  }
39
70
 
40
71
 
@@ -152,6 +183,7 @@ export default function useUser() {
152
183
  getById,
153
184
  createUserByVerification,
154
185
  getUserByEmail,
155
- inviteUserClient
186
+ inviteUserClient,
187
+ inviteMemberClient
156
188
  };
157
189
  }
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.41",
5
+ "version": "1.11.43",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "publishConfig": {
@@ -0,0 +1,7 @@
1
+ import type { $Fetch } from "ofetch";
2
+
3
+ declare module "#app" {
4
+ interface NuxtApp {
5
+ $api: $Fetch;
6
+ }
7
+ }