@iservice365/layer-common 0.1.0 → 0.2.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.
- package/.playground/app.vue +7 -2
- package/.playground/pages/feedback.vue +30 -0
- package/CHANGELOG.md +12 -0
- package/components/Chat/Bubbles.vue +53 -0
- package/components/Chat/Information.vue +187 -0
- package/components/Chat/ListCard.vue +62 -0
- package/components/Chat/Message.vue +149 -0
- package/components/Chat/Navigation.vue +150 -0
- package/components/ConfirmDialog.vue +66 -0
- package/components/Container/Standard.vue +33 -0
- package/components/Feedback/Form.vue +136 -0
- package/components/FeedbackDetail.vue +465 -0
- package/components/FeedbackMain.vue +454 -0
- package/components/FormDialog.vue +65 -0
- package/components/Input/File.vue +203 -0
- package/components/Input/ListGroupSelection.vue +96 -0
- package/components/Input/NewDate.vue +123 -0
- package/components/Input/Number.vue +124 -0
- package/components/InvitationMain.vue +284 -0
- package/components/Layout/Header.vue +14 -4
- package/components/ListView.vue +87 -0
- package/components/MemberMain.vue +459 -0
- package/components/RolePermissionFormCreate.vue +161 -0
- package/components/RolePermissionFormPreviewUpdate.vue +183 -0
- package/components/RolePermissionMain.vue +361 -0
- package/components/ServiceProviderFormCreate.vue +154 -0
- package/components/ServiceProviderMain.vue +195 -0
- package/components/SignaturePad.vue +73 -0
- package/components/SpecificAttr.vue +53 -0
- package/components/SwitchContext.vue +26 -5
- package/components/TableList.vue +150 -0
- package/components/TableListSecondary.vue +164 -0
- package/components/WorkOrder/Create.vue +197 -0
- package/components/WorkOrder/ListView.vue +96 -0
- package/components/WorkOrder/Main.vue +308 -0
- package/components/Workorder.vue +1 -0
- package/composables/useAddress.ts +107 -0
- package/composables/useCommonPermission.ts +130 -0
- package/composables/useCustomer.ts +113 -0
- package/composables/useFeedback.ts +117 -0
- package/composables/useFile.ts +40 -0
- package/composables/useInvoice.ts +18 -0
- package/composables/useLocal.ts +24 -4
- package/composables/useLocalAuth.ts +62 -20
- package/composables/useLocalSetup.ts +13 -0
- package/composables/useMember.ts +111 -0
- package/composables/useOrg.ts +76 -92
- package/composables/usePaymentMethod.ts +101 -0
- package/composables/usePrice.ts +15 -0
- package/composables/usePromoCode.ts +36 -0
- package/composables/useRole.ts +38 -7
- package/composables/useServiceProvider.ts +218 -0
- package/composables/useSite.ts +108 -0
- package/composables/useSubscription.ts +149 -0
- package/composables/useUser.ts +38 -14
- package/composables/useUtils.ts +218 -6
- package/composables/useVerification.ts +33 -0
- package/composables/useWorkOrder.ts +68 -0
- package/middleware/01.auth.ts +11 -0
- package/middleware/02.org.ts +18 -0
- package/middleware/03.customer.ts +13 -0
- package/middleware/member.ts +4 -0
- package/nuxt.config.ts +3 -1
- package/package.json +7 -3
- package/pages/index.vue +3 -0
- package/pages/payment-method-linked.vue +31 -0
- package/pages/require-customer.vue +56 -0
- package/pages/require-organization-membership.vue +47 -0
- package/pages/unauthorized.vue +29 -0
- package/plugins/API.ts +2 -25
- package/plugins/iconify.client.ts +5 -0
- package/plugins/secure-member.client.ts +54 -0
- package/plugins/vuetify.ts +2 -0
- package/public/bg-camera.jpg +0 -0
- package/public/bg-city.jpg +0 -0
- package/public/bg-condo.jpg +0 -0
- package/public/images/icons/delete-icon.png +0 -0
- package/public/sprite.svg +1 -0
- package/types/address.d.ts +13 -0
- package/types/customer.d.ts +15 -0
- package/types/feedback.d.ts +63 -0
- package/types/local.d.ts +47 -38
- package/types/member.d.ts +21 -0
- package/types/org.d.ts +13 -0
- package/types/permission.d.ts +1 -0
- package/types/price.d.ts +17 -0
- package/types/promo-code.d.ts +19 -0
- package/types/service-provider.d.ts +15 -0
- package/types/site.d.ts +13 -0
- package/types/subscription.d.ts +23 -0
- package/types/user.d.ts +19 -0
- package/types/verification.d.ts +20 -0
- package/types/work-order.d.ts +40 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
export default function useServiceProvider() {
|
|
2
|
+
const serviceProviders = useState<Array<TServiceProvider>>(
|
|
3
|
+
"serviceProviders",
|
|
4
|
+
() => []
|
|
5
|
+
);
|
|
6
|
+
const serviceProviderCategories = useState<string[]>(
|
|
7
|
+
"serviceProviderCategories",
|
|
8
|
+
() => []
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const page = useState("page", () => 1);
|
|
12
|
+
const pages = useState("pages", () => 0);
|
|
13
|
+
const pageRange = useState("pageRange", () => "-- - -- of --");
|
|
14
|
+
|
|
15
|
+
const serviceProvider = useState(
|
|
16
|
+
"serviceProvider",
|
|
17
|
+
(): TServiceProvider => ({
|
|
18
|
+
_id: "",
|
|
19
|
+
name: "",
|
|
20
|
+
orgId: "",
|
|
21
|
+
customerOrgId: "",
|
|
22
|
+
siteId: "",
|
|
23
|
+
serviceProviderOrgId: "",
|
|
24
|
+
type: "",
|
|
25
|
+
nature: "",
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
async function getServiceProviders({
|
|
30
|
+
page = 1,
|
|
31
|
+
search = "",
|
|
32
|
+
limit = 10,
|
|
33
|
+
serviceProviderId = "",
|
|
34
|
+
orgId = "",
|
|
35
|
+
siteId = "",
|
|
36
|
+
} = {}) {
|
|
37
|
+
try {
|
|
38
|
+
const response = await useNuxtApp().$api<Record<string, any>>(
|
|
39
|
+
"/api/service-providers",
|
|
40
|
+
{
|
|
41
|
+
method: "GET",
|
|
42
|
+
query: { page, search, limit, serviceProviderId, orgId, siteId },
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
serviceProviders.value = response.items;
|
|
46
|
+
pages.value = response.pages;
|
|
47
|
+
pageRange.value = response.pageRange;
|
|
48
|
+
} catch (err) {
|
|
49
|
+
console.error(err);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function getAll({
|
|
54
|
+
page = 1,
|
|
55
|
+
search = "",
|
|
56
|
+
limit = 10,
|
|
57
|
+
serviceProviderOrgId = "",
|
|
58
|
+
orgId = "",
|
|
59
|
+
siteId = "",
|
|
60
|
+
} = {}) {
|
|
61
|
+
return useNuxtApp().$api<Record<string, any>>("/api/service-providers", {
|
|
62
|
+
method: "GET",
|
|
63
|
+
query: { page, search, limit, serviceProviderOrgId, orgId, siteId },
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function getByProviderOrg({
|
|
68
|
+
page = 1,
|
|
69
|
+
search = "",
|
|
70
|
+
limit = 10,
|
|
71
|
+
provider = "",
|
|
72
|
+
org = "",
|
|
73
|
+
} = {}) {
|
|
74
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
75
|
+
`/api/service-providers/provider/${provider}/org/${org}`,
|
|
76
|
+
{
|
|
77
|
+
method: "GET",
|
|
78
|
+
query: { page, search, limit },
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function getByServiceProviderOrgIdType({ id = "", type = "" } = {}) {
|
|
84
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
85
|
+
`/api/service-providers/org/${id}/type/${type}`,
|
|
86
|
+
{
|
|
87
|
+
method: "GET",
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function getServiceProviderNames({
|
|
93
|
+
page = 1,
|
|
94
|
+
search = "",
|
|
95
|
+
limit = 10,
|
|
96
|
+
} = {}): Promise<TServiceProviderPaginatedResponse | undefined> {
|
|
97
|
+
try {
|
|
98
|
+
const response =
|
|
99
|
+
await useNuxtApp().$api<TServiceProviderPaginatedResponse>(
|
|
100
|
+
"/api/service-providers/name",
|
|
101
|
+
{
|
|
102
|
+
method: "GET",
|
|
103
|
+
query: { page, search, limit },
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
return response;
|
|
107
|
+
} catch (err) {
|
|
108
|
+
console.error(err);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function getServiceProviderCategories() {
|
|
113
|
+
try {
|
|
114
|
+
const response = await useNuxtApp().$api<{
|
|
115
|
+
items: string[];
|
|
116
|
+
page: number;
|
|
117
|
+
pages: number;
|
|
118
|
+
pageRange: string;
|
|
119
|
+
limit: number;
|
|
120
|
+
}>("/api/service-providers/category?page=1&limit=100", {
|
|
121
|
+
method: "GET",
|
|
122
|
+
});
|
|
123
|
+
serviceProviderCategories.value = response.items;
|
|
124
|
+
} catch (err) {
|
|
125
|
+
console.error("Error fetching service provider categories:", err);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function createServiceProviderInvite({
|
|
130
|
+
email,
|
|
131
|
+
siteId,
|
|
132
|
+
serviceProviderOrgId,
|
|
133
|
+
}: {
|
|
134
|
+
email: string;
|
|
135
|
+
siteId: string;
|
|
136
|
+
serviceProviderOrgId: string;
|
|
137
|
+
}) {
|
|
138
|
+
try {
|
|
139
|
+
await useNuxtApp().$api<Record<string, any>>(
|
|
140
|
+
"/api/auth/invite/service-provider",
|
|
141
|
+
{
|
|
142
|
+
method: "POST",
|
|
143
|
+
body: { email, siteId, serviceProviderOrgId },
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
} catch (err) {
|
|
147
|
+
console.error("Error creating service provider invite:", err);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function invite({
|
|
152
|
+
email = "",
|
|
153
|
+
orgId = "",
|
|
154
|
+
siteId = "",
|
|
155
|
+
siteName = "",
|
|
156
|
+
} = {}) {
|
|
157
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
158
|
+
"/api/service-providers/invite",
|
|
159
|
+
{
|
|
160
|
+
method: "POST",
|
|
161
|
+
body: { email, orgId, siteId, siteName },
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function add({
|
|
167
|
+
name = "",
|
|
168
|
+
type = "",
|
|
169
|
+
description = "",
|
|
170
|
+
email = "",
|
|
171
|
+
orgId = "",
|
|
172
|
+
siteId = "",
|
|
173
|
+
siteName = "",
|
|
174
|
+
serviceProviderOrgId = "",
|
|
175
|
+
} = {}) {
|
|
176
|
+
return useNuxtApp().$api<Record<string, any>>("/api/service-providers", {
|
|
177
|
+
method: "POST",
|
|
178
|
+
body: {
|
|
179
|
+
name,
|
|
180
|
+
type,
|
|
181
|
+
description,
|
|
182
|
+
email,
|
|
183
|
+
orgId,
|
|
184
|
+
siteId,
|
|
185
|
+
siteName,
|
|
186
|
+
serviceProviderOrgId,
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function addViaInvite(id = "") {
|
|
192
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
193
|
+
`/api/service-providers/id/${id}`,
|
|
194
|
+
{
|
|
195
|
+
method: "POST",
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
serviceProviders,
|
|
202
|
+
serviceProvider,
|
|
203
|
+
serviceProviderCategories,
|
|
204
|
+
page,
|
|
205
|
+
pages,
|
|
206
|
+
pageRange,
|
|
207
|
+
getByProviderOrg,
|
|
208
|
+
getServiceProviders,
|
|
209
|
+
getServiceProviderNames,
|
|
210
|
+
getServiceProviderCategories,
|
|
211
|
+
getAll,
|
|
212
|
+
createServiceProviderInvite,
|
|
213
|
+
getByServiceProviderOrgIdType,
|
|
214
|
+
invite,
|
|
215
|
+
add,
|
|
216
|
+
addViaInvite,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export default function useSite() {
|
|
2
|
+
const sites = ref<Array<TSite>>([]);
|
|
3
|
+
const page = ref(1);
|
|
4
|
+
const pages = ref(0);
|
|
5
|
+
const pageRange = ref("-- - -- of --");
|
|
6
|
+
const search = ref("");
|
|
7
|
+
|
|
8
|
+
const site = useState(
|
|
9
|
+
"site",
|
|
10
|
+
(): TSite => ({
|
|
11
|
+
_id: "",
|
|
12
|
+
name: "",
|
|
13
|
+
description: "",
|
|
14
|
+
orgId: "",
|
|
15
|
+
customerOrgId: "",
|
|
16
|
+
customerSiteId: "",
|
|
17
|
+
createdAt: "",
|
|
18
|
+
updatedAt: "",
|
|
19
|
+
deletedAt: "",
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const { currentUser } = useLocalAuth();
|
|
24
|
+
|
|
25
|
+
async function getSites({
|
|
26
|
+
orgId,
|
|
27
|
+
page: requestPage = 1,
|
|
28
|
+
search: searchQuery = "",
|
|
29
|
+
limit = 10,
|
|
30
|
+
sort = "createdAt",
|
|
31
|
+
order = "asc",
|
|
32
|
+
}: {
|
|
33
|
+
orgId?: string;
|
|
34
|
+
page?: number;
|
|
35
|
+
search?: string;
|
|
36
|
+
limit?: number;
|
|
37
|
+
sort?: string;
|
|
38
|
+
order?: string;
|
|
39
|
+
} = {}) {
|
|
40
|
+
try {
|
|
41
|
+
const organizationId = orgId || currentUser.value?.defaultOrg;
|
|
42
|
+
|
|
43
|
+
const response = await useNuxtApp().$api<Record<string, any>>(
|
|
44
|
+
`/api/sites/organization/${organizationId}`,
|
|
45
|
+
{
|
|
46
|
+
method: "GET",
|
|
47
|
+
query: { page: requestPage, search: searchQuery, limit, sort, order },
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
sites.value = response.items;
|
|
52
|
+
page.value = requestPage;
|
|
53
|
+
pages.value = response.pages;
|
|
54
|
+
pageRange.value = response.pageRange;
|
|
55
|
+
|
|
56
|
+
return response;
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error(err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function createSite(payload: TSiteCreate) {
|
|
63
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/sites`, {
|
|
64
|
+
method: "POST",
|
|
65
|
+
body: payload,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function deleteSite(id: string) {
|
|
70
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/sites/${id}`, {
|
|
71
|
+
method: "DELETE",
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function getSiteById(id: string) {
|
|
76
|
+
return useNuxtApp().$api<TCustomer>(`/api/sites/${id}`, {
|
|
77
|
+
method: "GET",
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function getAll({
|
|
82
|
+
org = "",
|
|
83
|
+
page = 1,
|
|
84
|
+
search = "",
|
|
85
|
+
limit = 10,
|
|
86
|
+
sort = "createdAt",
|
|
87
|
+
order = "asc",
|
|
88
|
+
} = {}) {
|
|
89
|
+
return useNuxtApp().$api<Record<string, any>>("/api/sites", {
|
|
90
|
+
method: "GET",
|
|
91
|
+
query: { page, search, limit, sort, order, org },
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
sites,
|
|
97
|
+
site,
|
|
98
|
+
page,
|
|
99
|
+
pages,
|
|
100
|
+
pageRange,
|
|
101
|
+
search,
|
|
102
|
+
getSites,
|
|
103
|
+
createSite,
|
|
104
|
+
deleteSite,
|
|
105
|
+
getSiteById,
|
|
106
|
+
getAll,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
export default function useSubscription() {
|
|
2
|
+
function add(subscriptionId: string, user: string) {
|
|
3
|
+
return useNuxtApp().$api("/api/subscriptions", {
|
|
4
|
+
method: "POST",
|
|
5
|
+
body: {
|
|
6
|
+
subscriptionId,
|
|
7
|
+
user,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getById(id: string) {
|
|
13
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
14
|
+
`/api/subscriptions/id/${id}`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getByAffiliateId(id: string) {
|
|
19
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
20
|
+
`/api/subscriptions/affiliate/${id}`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getByOrgId(id: string) {
|
|
25
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
26
|
+
`/api/subscriptions/org/${id}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getSubscriptions() {
|
|
31
|
+
return useNuxtApp().$api("/api/subscriptions");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getSubscriptionStatusById(id: string) {
|
|
35
|
+
return useNuxtApp().$api<Record<string, string>>(
|
|
36
|
+
`/api/subscriptions/status/${id}`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function cancelSubscription(id: string) {
|
|
41
|
+
return useNuxtApp().$api(`/api/subscriptions/cancel/${id}`, {
|
|
42
|
+
method: "DELETE",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const affiliateSubscription = useState(
|
|
47
|
+
"affiliateSubscription",
|
|
48
|
+
() => "inactive"
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
async function affSubscriptionStatus() {
|
|
52
|
+
const { currentUser } = useLocalAuth();
|
|
53
|
+
|
|
54
|
+
if (currentUser.value && currentUser.value._id) {
|
|
55
|
+
try {
|
|
56
|
+
const result = await getByAffiliateId(currentUser.value._id);
|
|
57
|
+
affiliateSubscription.value = result.status as string;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error("failed to get the subscription", error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const orgSubscription = useState("orgSubscription", () => "inactive");
|
|
65
|
+
|
|
66
|
+
async function orgSubscriptionStatus() {
|
|
67
|
+
const { currentOrg } = useOrg();
|
|
68
|
+
|
|
69
|
+
if (currentOrg.value) {
|
|
70
|
+
try {
|
|
71
|
+
const result = await getByOrgId(currentOrg.value);
|
|
72
|
+
orgSubscription.value = result.status as string;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error("failed to get the subscription", error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type TSub = {
|
|
80
|
+
amount: number;
|
|
81
|
+
payment_method_type: string;
|
|
82
|
+
payment_method_card_number?: string;
|
|
83
|
+
payment_method_expiry_month?: string;
|
|
84
|
+
payment_method_expiry_year?: string;
|
|
85
|
+
payment_method_cvv?: string;
|
|
86
|
+
payment_method_cardholder_name?: string;
|
|
87
|
+
currency?: string;
|
|
88
|
+
seats?: number;
|
|
89
|
+
organization?: TOrg;
|
|
90
|
+
billingAddress: TAddress;
|
|
91
|
+
promoCode?: string;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
function initOrgSubscription(value: TSub) {
|
|
95
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
96
|
+
"/api/subscriptions/organization",
|
|
97
|
+
{
|
|
98
|
+
method: "POST",
|
|
99
|
+
body: value,
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function initAffiliateSubscription(value: TSub) {
|
|
105
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
106
|
+
"/api/subscriptions/affiliate",
|
|
107
|
+
{
|
|
108
|
+
method: "POST",
|
|
109
|
+
body: value,
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function updateSeatsById({
|
|
115
|
+
subscriptionId = "",
|
|
116
|
+
seats = 0,
|
|
117
|
+
amount = 0,
|
|
118
|
+
promoCode = "",
|
|
119
|
+
} = {}) {
|
|
120
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
121
|
+
`/api/subscriptions/seats/${subscriptionId}`,
|
|
122
|
+
{
|
|
123
|
+
method: "PUT",
|
|
124
|
+
body: {
|
|
125
|
+
seats,
|
|
126
|
+
amount,
|
|
127
|
+
promoCode,
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
add,
|
|
135
|
+
getById,
|
|
136
|
+
getByOrgId,
|
|
137
|
+
getSubscriptions,
|
|
138
|
+
affSubscriptionStatus,
|
|
139
|
+
affiliateSubscription,
|
|
140
|
+
orgSubscriptionStatus,
|
|
141
|
+
orgSubscription,
|
|
142
|
+
getSubscriptionStatusById,
|
|
143
|
+
cancelSubscription,
|
|
144
|
+
initAffiliateSubscription,
|
|
145
|
+
initOrgSubscription,
|
|
146
|
+
getByAffiliateId,
|
|
147
|
+
updateSeatsById,
|
|
148
|
+
};
|
|
149
|
+
}
|
package/composables/useUser.ts
CHANGED
|
@@ -1,48 +1,58 @@
|
|
|
1
1
|
export default function useUser() {
|
|
2
2
|
function inviteUser({ email = "", app = "", role = "", name = "" } = {}) {
|
|
3
|
-
return useNuxtApp().$api<
|
|
3
|
+
return useNuxtApp().$api<Record<string, any>>("/api/auth/invite", {
|
|
4
4
|
method: "POST",
|
|
5
5
|
body: { email, app, role, name },
|
|
6
6
|
});
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
function updateName(
|
|
10
|
-
return useNuxtApp().$api<
|
|
9
|
+
function updateName(name = "") {
|
|
10
|
+
return useNuxtApp().$api<Record<string, any>>("/api/users/name", {
|
|
11
11
|
method: "PUT",
|
|
12
|
-
body: {
|
|
12
|
+
body: { name },
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function updateBirthday({ month = "", day = 0, year = 0 } = {}) {
|
|
17
|
-
return useNuxtApp().$api<
|
|
18
|
-
method: "
|
|
16
|
+
function updateBirthday(id: string, { month = "", day = 0, year = 0 } = {}) {
|
|
17
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/users/birthday/${id}`, {
|
|
18
|
+
method: "PATCH",
|
|
19
19
|
body: { month, day, year },
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function updateGender(gender = "") {
|
|
24
|
-
return useNuxtApp().$api<
|
|
24
|
+
return useNuxtApp().$api<Record<string, any>>("/api/users/gender", {
|
|
25
25
|
method: "PUT",
|
|
26
26
|
body: { gender },
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function updateEmail(email = "") {
|
|
31
|
-
return useNuxtApp().$api<
|
|
31
|
+
return useNuxtApp().$api<Record<string, any>>("/api/users/email", {
|
|
32
32
|
method: "PUT",
|
|
33
33
|
body: { email },
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function updateContact(contact = "") {
|
|
38
|
-
return useNuxtApp().$api<
|
|
38
|
+
return useNuxtApp().$api<Record<string, any>>("/api/users/contact", {
|
|
39
39
|
method: "PUT",
|
|
40
40
|
body: { contact },
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
function updatePassword(
|
|
45
|
+
id: string,
|
|
46
|
+
{ currentPassword = "", newPassword = "", passwordConfirmation = "" }
|
|
47
|
+
) {
|
|
48
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/users/password/${id}`, {
|
|
49
|
+
method: "PATCH",
|
|
50
|
+
body: { currentPassword, newPassword, passwordConfirmation },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
function updateUserFieldById(id = "", field = "", value = "") {
|
|
45
|
-
return useNuxtApp().$api<
|
|
55
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/users/field/${id}`, {
|
|
46
56
|
method: "PATCH",
|
|
47
57
|
body: { field, value },
|
|
48
58
|
});
|
|
@@ -54,14 +64,14 @@ export default function useUser() {
|
|
|
54
64
|
search = "",
|
|
55
65
|
page = 1,
|
|
56
66
|
} = {}) {
|
|
57
|
-
return useNuxtApp().$api<
|
|
67
|
+
return useNuxtApp().$api<Record<string, any>>("/api/users", {
|
|
58
68
|
method: "GET",
|
|
59
69
|
query: { status, search, page, type },
|
|
60
70
|
});
|
|
61
71
|
}
|
|
62
72
|
|
|
63
73
|
function getById(id = "") {
|
|
64
|
-
return useNuxtApp().$api<
|
|
74
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/users/id/${id}`, {
|
|
65
75
|
method: "GET",
|
|
66
76
|
});
|
|
67
77
|
}
|
|
@@ -72,12 +82,24 @@ export default function useUser() {
|
|
|
72
82
|
password = "",
|
|
73
83
|
id = "",
|
|
74
84
|
} = {}) {
|
|
75
|
-
return useNuxtApp().$api<
|
|
85
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/users/invite/${id}`, {
|
|
76
86
|
method: "POST",
|
|
77
87
|
body: { firstName, lastName, password },
|
|
78
88
|
});
|
|
79
89
|
}
|
|
80
90
|
|
|
91
|
+
function createUserByVerification({
|
|
92
|
+
name = "",
|
|
93
|
+
password = "",
|
|
94
|
+
id = "",
|
|
95
|
+
type = "",
|
|
96
|
+
} = {}) {
|
|
97
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/users/invite/${id}`, {
|
|
98
|
+
method: "POST",
|
|
99
|
+
body: { name, password, type },
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
81
103
|
return {
|
|
82
104
|
inviteUser,
|
|
83
105
|
updateName,
|
|
@@ -85,9 +107,11 @@ export default function useUser() {
|
|
|
85
107
|
updateGender,
|
|
86
108
|
updateEmail,
|
|
87
109
|
updateContact,
|
|
110
|
+
updatePassword,
|
|
88
111
|
updateUserFieldById,
|
|
89
112
|
getUsers,
|
|
90
113
|
createUserByInvite,
|
|
91
114
|
getById,
|
|
115
|
+
createUserByVerification,
|
|
92
116
|
};
|
|
93
117
|
}
|