@iservice365/layer-common 1.0.3 → 1.0.5
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/CHANGELOG.md +12 -0
- package/composables/useCustomerSite.ts +36 -0
- package/composables/useLocal.ts +4 -0
- package/composables/useLocalSetup.ts +3 -0
- package/composables/useOrg.ts +12 -1
- package/package.json +1 -1
- package/plugins/secure-member.client.ts +28 -4
- package/types/customer.d.ts +12 -0
- package/types/site.d.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 1.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f7ff2ae: Revision - member only data request adjustment
|
|
8
|
+
|
|
9
|
+
## 1.0.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 789ece4: Revamp service provider site management
|
|
14
|
+
|
|
3
15
|
## 1.0.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export default function useCustomerSite() {
|
|
2
|
+
function add(payload: TCustomerSite) {
|
|
3
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/customer-sites`, {
|
|
4
|
+
method: "POST",
|
|
5
|
+
body: payload,
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async function getAll({
|
|
10
|
+
page = 1,
|
|
11
|
+
search = "",
|
|
12
|
+
limit = 10,
|
|
13
|
+
org = "",
|
|
14
|
+
status = "active",
|
|
15
|
+
sort = "",
|
|
16
|
+
order = "asc",
|
|
17
|
+
}: {
|
|
18
|
+
page?: number;
|
|
19
|
+
search?: string;
|
|
20
|
+
limit?: number;
|
|
21
|
+
org?: string;
|
|
22
|
+
status?: string;
|
|
23
|
+
sort?: string;
|
|
24
|
+
order?: string;
|
|
25
|
+
} = {}) {
|
|
26
|
+
return useNuxtApp().$api<Record<string, any>>("/api/customer-sites", {
|
|
27
|
+
method: "GET",
|
|
28
|
+
query: { page, search, limit, sort, order, status, org },
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
add,
|
|
34
|
+
getAll,
|
|
35
|
+
};
|
|
36
|
+
}
|
package/composables/useLocal.ts
CHANGED
|
@@ -31,6 +31,10 @@ export default function useLocal() {
|
|
|
31
31
|
const headerSearch = useState("headerSearch", () => "");
|
|
32
32
|
|
|
33
33
|
const natureOfBusiness = [
|
|
34
|
+
{
|
|
35
|
+
title: "Real Estate Developer",
|
|
36
|
+
value: "real_estate_developer",
|
|
37
|
+
},
|
|
34
38
|
{
|
|
35
39
|
title: "Property Management Agency",
|
|
36
40
|
value: "property_management_agency",
|
package/composables/useOrg.ts
CHANGED
|
@@ -91,17 +91,27 @@ export default function useOrg() {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
function getAll({ page = 1, search = "", limit = 20 } = {}) {
|
|
94
|
+
function getAll({ page = 1, search = "", limit = 20, nature = "" } = {}) {
|
|
95
95
|
return useNuxtApp().$api<Record<string, any>>("/api/organizations", {
|
|
96
96
|
method: "GET",
|
|
97
97
|
query: {
|
|
98
98
|
page,
|
|
99
99
|
search,
|
|
100
100
|
limit,
|
|
101
|
+
nature,
|
|
101
102
|
},
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
|
|
106
|
+
function add(
|
|
107
|
+
value: Partial<Pick<TOrg, "name" | "email" | "nature" | "contact">>
|
|
108
|
+
) {
|
|
109
|
+
return useNuxtApp().$api<TOrg>("/api/organizations", {
|
|
110
|
+
method: "POST",
|
|
111
|
+
body: value,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
105
115
|
return {
|
|
106
116
|
org,
|
|
107
117
|
getOrgs,
|
|
@@ -114,5 +124,6 @@ export default function useOrg() {
|
|
|
114
124
|
currentOrg,
|
|
115
125
|
getById,
|
|
116
126
|
getAll,
|
|
127
|
+
add,
|
|
117
128
|
};
|
|
118
129
|
}
|
package/package.json
CHANGED
|
@@ -2,21 +2,33 @@ export default defineNuxtPlugin(() => {
|
|
|
2
2
|
const router = useRouter();
|
|
3
3
|
const { getByUserType } = useMember();
|
|
4
4
|
const { getRoleById } = useRole();
|
|
5
|
+
const { getById } = useOrg();
|
|
5
6
|
|
|
6
|
-
const { userAppRole, id } = useLocalSetup();
|
|
7
|
+
const { userAppRole, id, orgNature } = useLocalSetup();
|
|
7
8
|
|
|
8
9
|
router.afterEach((to) => {
|
|
9
10
|
const isMember = to.meta?.memberOnly;
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
if (typeof isMember === "boolean" && !isMember) {
|
|
13
|
+
navigateTo(
|
|
14
|
+
{
|
|
15
|
+
name: "index",
|
|
16
|
+
},
|
|
17
|
+
{ replace: true }
|
|
18
|
+
);
|
|
19
|
+
}
|
|
11
20
|
|
|
12
21
|
const APP = useRuntimeConfig().public.APP;
|
|
13
|
-
const org = (
|
|
22
|
+
const org = computed(
|
|
23
|
+
() =>
|
|
24
|
+
(to.params.org as string) || (to.params.organization as string) || ""
|
|
25
|
+
);
|
|
14
26
|
|
|
15
27
|
const userId = computed(() => useCookie("user").value ?? "");
|
|
16
28
|
|
|
17
29
|
const { data: userMemberData, error: userMemberError } = useLazyAsyncData(
|
|
18
30
|
"get-member-by-id",
|
|
19
|
-
() => getByUserType(userId.value, APP, org),
|
|
31
|
+
() => getByUserType(userId.value, APP, org.value),
|
|
20
32
|
{ watch: [userId] }
|
|
21
33
|
);
|
|
22
34
|
|
|
@@ -37,6 +49,18 @@ export default defineNuxtPlugin(() => {
|
|
|
37
49
|
}
|
|
38
50
|
});
|
|
39
51
|
|
|
52
|
+
const { data: getOrgByIdReq } = useLazyAsyncData(
|
|
53
|
+
"get-org-by-id",
|
|
54
|
+
() => getById(org.value),
|
|
55
|
+
{ watch: [org] }
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
watchEffect(() => {
|
|
59
|
+
if (getOrgByIdReq.value) {
|
|
60
|
+
orgNature.value = getOrgByIdReq.value.nature ?? "";
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
40
64
|
const roleId = computed(() => userMemberData.value?.role ?? "");
|
|
41
65
|
|
|
42
66
|
const { data: getRoleByIdReq } = useLazyAsyncData(
|
package/types/customer.d.ts
CHANGED
|
@@ -13,3 +13,15 @@ declare type TCustomerCreate = Pick<
|
|
|
13
13
|
TCustomer,
|
|
14
14
|
"name" | "orgId" | "siteName" | "siteDescription"
|
|
15
15
|
>;
|
|
16
|
+
|
|
17
|
+
declare type TCustomerSite = {
|
|
18
|
+
name: string;
|
|
19
|
+
site?: string;
|
|
20
|
+
siteOrg: string;
|
|
21
|
+
siteOrgName: string;
|
|
22
|
+
org: string;
|
|
23
|
+
status?: string;
|
|
24
|
+
createdAt?: string;
|
|
25
|
+
updatedAt?: string;
|
|
26
|
+
deletedAt?: string;
|
|
27
|
+
};
|
package/types/site.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare type TSite = {
|
|
2
2
|
_id?: string;
|
|
3
3
|
name: string;
|
|
4
|
-
description
|
|
4
|
+
description?: string;
|
|
5
5
|
orgId: string;
|
|
6
6
|
blocks?: number;
|
|
7
7
|
customerOrgId: string;
|
|
@@ -11,6 +11,7 @@ declare type TSite = {
|
|
|
11
11
|
deletedAt?: string;
|
|
12
12
|
metadata?: {
|
|
13
13
|
block?: number; // Number of blocks in the site
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
|
+
};
|
|
15
16
|
|
|
16
17
|
declare type TSiteCreate = Pick<TSite, "name" | "description" | "orgId">;
|