@goweekdays/layer-common 0.0.8 → 0.0.10
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/components/Input/ListGroupSelection.vue +93 -0
- package/composables/useAdminPermission.ts +127 -0
- package/composables/usePayment.ts +22 -0
- package/composables/usePaymentMethod.ts +2 -6
- package/composables/useRole.ts +16 -2
- package/composables/useUtils.ts +5 -0
- package/package.json +1 -1
- package/types/user.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-input v-bind="attrs">
|
|
3
|
+
<v-card width="100%" v-bind="attrs">
|
|
4
|
+
<v-list
|
|
5
|
+
v-model:selected="selected"
|
|
6
|
+
lines="two"
|
|
7
|
+
:select-strategy="attrs.readonly ? 'classic' : 'leaf'"
|
|
8
|
+
class="pa-0"
|
|
9
|
+
density="compact"
|
|
10
|
+
read-only
|
|
11
|
+
open-strategy="single"
|
|
12
|
+
>
|
|
13
|
+
<template
|
|
14
|
+
v-for="(permission, permissionKey, permissionIndex) in props.items"
|
|
15
|
+
:key="permissionKey"
|
|
16
|
+
>
|
|
17
|
+
<v-divider v-if="permissionIndex > 0"></v-divider>
|
|
18
|
+
<v-list-group :value="permissionKey" fluid>
|
|
19
|
+
<template v-slot:activator="{ props }">
|
|
20
|
+
<v-list-item v-bind="props" density="compact">
|
|
21
|
+
<span class="text-capitalize">
|
|
22
|
+
{{ String(permissionKey).replace(/-/g, " ") }}
|
|
23
|
+
</span>
|
|
24
|
+
|
|
25
|
+
<template #prepend>
|
|
26
|
+
<v-chip class="mr-2" small>
|
|
27
|
+
{{ selectedActionCount(String(permissionKey)) }}
|
|
28
|
+
</v-chip>
|
|
29
|
+
</template>
|
|
30
|
+
</v-list-item>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<template v-for="(item, itemKey) in permission" :key="itemKey">
|
|
34
|
+
<v-divider></v-divider>
|
|
35
|
+
<v-list-item v-if="attrs.readonly" density="compact">
|
|
36
|
+
<template #title class="pl-2">
|
|
37
|
+
<span class="text-subtitle-2 text-capitalize">
|
|
38
|
+
{{ String(itemKey).replace(/-/g, " ") }}
|
|
39
|
+
</span>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<template #subtitle class="pl-2">
|
|
43
|
+
<span class="text-subtitle-2">{{ item.description }}</span>
|
|
44
|
+
</template>
|
|
45
|
+
</v-list-item>
|
|
46
|
+
|
|
47
|
+
<v-list-item
|
|
48
|
+
v-else
|
|
49
|
+
:value="`${permissionKey}:${itemKey}`"
|
|
50
|
+
density="compact"
|
|
51
|
+
>
|
|
52
|
+
<template #title class="pl-2">
|
|
53
|
+
<span class="text-subtitle-2 text-capitalize">
|
|
54
|
+
{{ String(itemKey).replace(/-/g, " ") }}
|
|
55
|
+
</span>
|
|
56
|
+
</template>
|
|
57
|
+
|
|
58
|
+
<template #subtitle class="pl-2">
|
|
59
|
+
<span class="text-subtitle-2 text-capitalize">
|
|
60
|
+
{{ String(item.description).replace(/-/g, " ") }}
|
|
61
|
+
</span>
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<template #prepend="{ isSelected }" class="pl-1">
|
|
65
|
+
<v-list-item-action start>
|
|
66
|
+
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
|
67
|
+
</v-list-item-action>
|
|
68
|
+
</template>
|
|
69
|
+
</v-list-item>
|
|
70
|
+
</template>
|
|
71
|
+
</v-list-group>
|
|
72
|
+
</template>
|
|
73
|
+
</v-list>
|
|
74
|
+
</v-card>
|
|
75
|
+
</v-input>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<script setup lang="ts">
|
|
79
|
+
const selected = defineModel<Array<string>>({ default: [] });
|
|
80
|
+
const attrs = useAttrs();
|
|
81
|
+
const props = defineProps({
|
|
82
|
+
items: {
|
|
83
|
+
type: Object,
|
|
84
|
+
required: true,
|
|
85
|
+
default: () => ({}),
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const selectedActionCount = (resource: string) => {
|
|
90
|
+
return selected.value.filter((permission) => permission.startsWith(resource))
|
|
91
|
+
.length;
|
|
92
|
+
};
|
|
93
|
+
</script>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export default function useAdminPermission() {
|
|
2
|
+
const permissions: TPermissions = {
|
|
3
|
+
organizations: {
|
|
4
|
+
"see-all-organizations": {
|
|
5
|
+
check: true,
|
|
6
|
+
description: "Allows the user to view the list of all organizations.",
|
|
7
|
+
},
|
|
8
|
+
"see-organization-details": {
|
|
9
|
+
check: true,
|
|
10
|
+
description:
|
|
11
|
+
"Allows the user to view the details of a specific organization.",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
"promo-codes": {
|
|
15
|
+
"create-promo-code": {
|
|
16
|
+
check: true,
|
|
17
|
+
description: "Allows the user to add new promo codes to the system.",
|
|
18
|
+
},
|
|
19
|
+
"see-promo-code-details": {
|
|
20
|
+
check: true,
|
|
21
|
+
description:
|
|
22
|
+
"Allows the user to view the details of a specific promo code.",
|
|
23
|
+
},
|
|
24
|
+
"edit-promo-code-details": {
|
|
25
|
+
check: true,
|
|
26
|
+
description:
|
|
27
|
+
"Allows the user to update the promo code’s name, discount value, and other settings.",
|
|
28
|
+
},
|
|
29
|
+
"change-promo-code-status": {
|
|
30
|
+
check: true,
|
|
31
|
+
description:
|
|
32
|
+
"Allows the user to activate, deactivate, or expire a promo code.",
|
|
33
|
+
},
|
|
34
|
+
"delete-promo-code": {
|
|
35
|
+
check: true,
|
|
36
|
+
description:
|
|
37
|
+
"Allows the user to remove a promo code from the system permanently.",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
users: {
|
|
41
|
+
"see-all-users": {
|
|
42
|
+
check: true,
|
|
43
|
+
description: "Allows the user to view the list of all users.",
|
|
44
|
+
},
|
|
45
|
+
"see-user-details": {
|
|
46
|
+
check: true,
|
|
47
|
+
description: "Allows the user to view the details of a specific user.",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
invitations: {
|
|
51
|
+
"see-all-invitations": {
|
|
52
|
+
check: true,
|
|
53
|
+
description: "Allows the user to view the list of all invitations.",
|
|
54
|
+
},
|
|
55
|
+
"see-invitation-details": {
|
|
56
|
+
check: true,
|
|
57
|
+
description:
|
|
58
|
+
"Allows the user to view the details of a specific invitation.",
|
|
59
|
+
},
|
|
60
|
+
"edit-invitation-details": {
|
|
61
|
+
check: true,
|
|
62
|
+
description:
|
|
63
|
+
"Allows the user to update the details of a specific invitation.",
|
|
64
|
+
},
|
|
65
|
+
"change-invitation-status": {
|
|
66
|
+
check: true,
|
|
67
|
+
description: "Allows the user to update the status of an invitation.",
|
|
68
|
+
},
|
|
69
|
+
"delete-invitation": {
|
|
70
|
+
check: true,
|
|
71
|
+
description:
|
|
72
|
+
"Allows the user to remove an invitation from the system permanently.",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
members: {
|
|
76
|
+
"see-all-members": {
|
|
77
|
+
check: true,
|
|
78
|
+
description: "Allows the user to view the list of all members.",
|
|
79
|
+
},
|
|
80
|
+
"see-member-details": {
|
|
81
|
+
check: true,
|
|
82
|
+
description:
|
|
83
|
+
"Allows the user to view the details of a specific member.",
|
|
84
|
+
},
|
|
85
|
+
"change-member-status": {
|
|
86
|
+
check: true,
|
|
87
|
+
description: "Allows the user to update the status of a member.",
|
|
88
|
+
},
|
|
89
|
+
"remove-member": {
|
|
90
|
+
check: true,
|
|
91
|
+
description: "Allows the user to remove a member from the system.",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
"roles-and-permissions": {
|
|
95
|
+
"view-all-roles": {
|
|
96
|
+
check: true,
|
|
97
|
+
description: "Allows the user to view the list of all roles.",
|
|
98
|
+
},
|
|
99
|
+
"view-role-details": {
|
|
100
|
+
check: true,
|
|
101
|
+
description: "Allows the user to view the details of a specific role.",
|
|
102
|
+
},
|
|
103
|
+
"update-role-name": {
|
|
104
|
+
check: true,
|
|
105
|
+
description: "Allows the user to edit the name of an existing role.",
|
|
106
|
+
},
|
|
107
|
+
"update-role-permissions": {
|
|
108
|
+
check: true,
|
|
109
|
+
description:
|
|
110
|
+
"Allows the user to modify permissions assigned to a role.",
|
|
111
|
+
},
|
|
112
|
+
"update-role-status": {
|
|
113
|
+
check: true,
|
|
114
|
+
description: "Allows the user to activate or deactivate a role.",
|
|
115
|
+
},
|
|
116
|
+
"delete-role": {
|
|
117
|
+
check: true,
|
|
118
|
+
description:
|
|
119
|
+
"Allows the user to remove a role from the system permanently.",
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
permissions,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default function usePayment() {
|
|
2
|
+
function getPayments({
|
|
3
|
+
search = "",
|
|
4
|
+
id = "",
|
|
5
|
+
page = 1,
|
|
6
|
+
status = "completed",
|
|
7
|
+
} = {}) {
|
|
8
|
+
return useNuxtApp().$api<Record<string, any>>("/api/payments", {
|
|
9
|
+
method: "GET",
|
|
10
|
+
query: {
|
|
11
|
+
search,
|
|
12
|
+
id,
|
|
13
|
+
page,
|
|
14
|
+
status,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
getPayments,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export default function usePaymentMethod() {
|
|
2
2
|
function linkEWallet({
|
|
3
|
-
mobile_number = "",
|
|
4
3
|
type = "GCASH",
|
|
5
|
-
|
|
6
|
-
user = "",
|
|
4
|
+
customer_id = "",
|
|
7
5
|
success_return_url = "",
|
|
8
6
|
failure_return_url = "",
|
|
9
7
|
cancel_return_url = "",
|
|
@@ -14,10 +12,8 @@ export default function usePaymentMethod() {
|
|
|
14
12
|
{
|
|
15
13
|
method: "POST",
|
|
16
14
|
body: {
|
|
17
|
-
|
|
15
|
+
customer_id,
|
|
18
16
|
type,
|
|
19
|
-
user,
|
|
20
|
-
org,
|
|
21
17
|
success_return_url,
|
|
22
18
|
failure_return_url,
|
|
23
19
|
cancel_return_url,
|
package/composables/useRole.ts
CHANGED
|
@@ -12,10 +12,16 @@ export default function useRole() {
|
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function getRoles({
|
|
15
|
+
function getRoles({
|
|
16
|
+
search = "",
|
|
17
|
+
page = 1,
|
|
18
|
+
limit = 20,
|
|
19
|
+
type = "",
|
|
20
|
+
org = "",
|
|
21
|
+
} = {}) {
|
|
16
22
|
return useNuxtApp().$api<TKeyValuePair>("/api/roles", {
|
|
17
23
|
method: "GET",
|
|
18
|
-
query: { search, page, limit, type },
|
|
24
|
+
query: { search, page, limit, type, org },
|
|
19
25
|
});
|
|
20
26
|
}
|
|
21
27
|
|
|
@@ -36,6 +42,13 @@ export default function useRole() {
|
|
|
36
42
|
});
|
|
37
43
|
}
|
|
38
44
|
|
|
45
|
+
function updatePermissionById(_id: string, permissions?: Array<string>) {
|
|
46
|
+
return useNuxtApp().$api(`/api/roles/permissions/id/${_id}`, {
|
|
47
|
+
method: "PATCH",
|
|
48
|
+
body: { permissions },
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
39
52
|
function updateRoleFieldById(_id: string, field: string, value: string) {
|
|
40
53
|
return useNuxtApp().$api(`/api/roles/${_id}`, {
|
|
41
54
|
method: "PATCH",
|
|
@@ -69,5 +82,6 @@ export default function useRole() {
|
|
|
69
82
|
updateRoleById,
|
|
70
83
|
updateRoleFieldById,
|
|
71
84
|
deleteRole,
|
|
85
|
+
updatePermissionById,
|
|
72
86
|
};
|
|
73
87
|
}
|
package/composables/useUtils.ts
CHANGED
|
@@ -14,6 +14,10 @@ export default function useUtils() {
|
|
|
14
14
|
return true;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
function requireListRule(value: string[]) {
|
|
18
|
+
return value.length ? "" : "Required";
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
const minOneMonthAdvance = (value: string): boolean | string => {
|
|
18
22
|
if (!/^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/\d{4}$/.test(value)) {
|
|
19
23
|
return "Invalid date format (MM/DD/YYYY)";
|
|
@@ -227,5 +231,6 @@ export default function useUtils() {
|
|
|
227
231
|
validateDate,
|
|
228
232
|
minOneMonthAdvance,
|
|
229
233
|
computeTieredCost,
|
|
234
|
+
requireListRule,
|
|
230
235
|
};
|
|
231
236
|
}
|
package/package.json
CHANGED