@goweekdays/layer-common 0.0.9 → 0.0.11

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/components/AddPaymentMethod.vue +171 -0
  3. package/components/Container/Standard.vue +33 -0
  4. package/components/Input/ListGroupSelection.vue +93 -0
  5. package/components/SwitchOrg.vue +10 -1
  6. package/components/TableList.vue +128 -0
  7. package/composables/useAdminPermission.ts +127 -0
  8. package/composables/useFile.ts +29 -0
  9. package/composables/useInvoice.ts +38 -0
  10. package/composables/useLocalAuth.ts +2 -0
  11. package/composables/useMember.ts +86 -0
  12. package/composables/usePaymentMethod.ts +78 -0
  13. package/composables/usePrice.ts +15 -0
  14. package/composables/usePromoCode.ts +8 -1
  15. package/composables/useRole.ts +20 -6
  16. package/composables/useSubscription.ts +41 -6
  17. package/composables/useUtils.ts +21 -6
  18. package/middleware/{auth.ts → 01.auth.ts} +0 -2
  19. package/nuxt.config.ts +1 -0
  20. package/package.json +1 -1
  21. package/plugins/API.ts +56 -38
  22. package/plugins/client.ts +30 -0
  23. package/public/bdo-logo.svg +4 -0
  24. package/public/bpi-logo.svg +74 -0
  25. package/public/chinabank-logo.svg +120 -0
  26. package/public/gcash-logo.svg +65 -0
  27. package/public/grabpay-logo.svg +99 -0
  28. package/public/paymaya-logo.svg +25 -0
  29. package/public/qrph-c567ff0f-ab6d-4662-86bf-24c6c731d8a8-logo.svg +20 -0
  30. package/public/rcbc-logo.svg +15 -0
  31. package/public/shopeepay-logo.svg +89 -0
  32. package/public/ubp-logo.svg +88 -0
  33. package/types/member.d.ts +12 -0
  34. package/types/payment.d.ts +18 -0
  35. package/types/permission.d.ts +0 -10
  36. package/types/price.d.ts +17 -0
  37. package/types/role.d.ts +1 -0
  38. package/types/subscription.d.ts +16 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @goweekdays/layer-common
2
2
 
3
+ ## 0.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 833df66: Revise payment method
8
+
9
+ ## 0.0.10
10
+
11
+ ### Patch Changes
12
+
13
+ - acceb5a: Revise role creation and update
14
+
3
15
  ## 0.0.9
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,171 @@
1
+ <template>
2
+ <v-row no-gutters>
3
+ <v-col cols="12">
4
+ <slot name="header">
5
+ <v-row no-gutters>
6
+ <v-col cols="12" class="text-h6 font-weight-bold">
7
+ Payment Method
8
+ </v-col>
9
+ </v-row>
10
+ </slot>
11
+ </v-col>
12
+
13
+ <v-col cols="12" class="mt-2">
14
+ <v-row no-gutters>
15
+ <v-col cols="12">
16
+ <v-item-group
17
+ v-model.number="selectedPaymentMethod"
18
+ selected-class="bg-cyan-accent-1"
19
+ mandatory
20
+ >
21
+ <v-row>
22
+ <v-col cols="12">
23
+ <InputLabel title="E-Wallet" />
24
+ </v-col>
25
+ <template v-for="eWalletItem in props.supportedEwallets">
26
+ <v-col cols="12" lg="3" md="4" sm="4">
27
+ <v-item v-slot="{ toggle, selectedClass }">
28
+ <v-card
29
+ variant="outlined"
30
+ border="thin"
31
+ @click="toggle"
32
+ :class="['px-4', selectedClass]"
33
+ >
34
+ <v-img :src="eWalletItem.logo" width="100%" height="60px">
35
+ </v-img>
36
+ </v-card>
37
+ </v-item>
38
+ </v-col>
39
+ </template>
40
+
41
+ <v-col cols="12">
42
+ <InputLabel title="Direct Debit" />
43
+ </v-col>
44
+
45
+ <template
46
+ v-for="supportedDirectDebitItem in props.supportedDirectDebit"
47
+ >
48
+ <v-col cols="12" lg="3" md="4" sm="4">
49
+ <v-item v-slot="{ toggle, selectedClass }">
50
+ <v-card
51
+ variant="outlined"
52
+ border="thin"
53
+ @click="toggle"
54
+ :class="['px-4', selectedClass]"
55
+ >
56
+ <v-img
57
+ :src="supportedDirectDebitItem.logo"
58
+ width="100%"
59
+ height="60px"
60
+ >
61
+ </v-img>
62
+ </v-card>
63
+ </v-item>
64
+ </v-col>
65
+ </template>
66
+ </v-row>
67
+ </v-item-group>
68
+ </v-col>
69
+ </v-row>
70
+ </v-col>
71
+ </v-row>
72
+ </template>
73
+
74
+ <script setup lang="ts">
75
+ const selectedPaymentMethod = ref<number | null>(null);
76
+ const channel = defineModel<string | null>("channel", {
77
+ default: null,
78
+ });
79
+ const type = defineModel<string | null>("type", {
80
+ default: null,
81
+ });
82
+ const props = defineProps({
83
+ supportedEwallets: {
84
+ type: Array as PropType<
85
+ {
86
+ channel: string;
87
+ logo: string;
88
+ type: string;
89
+ }[]
90
+ >,
91
+ default() {
92
+ return [
93
+ {
94
+ channel: "GCASH",
95
+ logo: "/gcash-logo.svg",
96
+ type: "EWALLET",
97
+ },
98
+ {
99
+ channel: "PAYMAYA",
100
+ logo: "/paymaya-logo.svg",
101
+ type: "EWALLET",
102
+ },
103
+ {
104
+ channel: "GRABPAY",
105
+ logo: "/grabpay-logo.svg",
106
+ type: "EWALLET",
107
+ },
108
+ {
109
+ channel: "SHOPEEPAY",
110
+ logo: "/shopeepay-logo.svg",
111
+ type: "EWALLET",
112
+ },
113
+ ];
114
+ },
115
+ },
116
+ supportedDirectDebit: {
117
+ type: Array as PropType<
118
+ {
119
+ channel: string;
120
+ logo: string;
121
+ type: string;
122
+ }[]
123
+ >,
124
+ default() {
125
+ return [
126
+ {
127
+ channel: "UBP",
128
+ logo: "/ubp-logo.svg",
129
+ type: "DIRECT_DEBIT",
130
+ },
131
+ {
132
+ channel: "BDO",
133
+ logo: "/bdo-logo.svg",
134
+ type: "DIRECT_DEBIT",
135
+ },
136
+ {
137
+ channel: "BPI",
138
+ logo: "/bpi-logo.svg",
139
+ type: "DIRECT_DEBIT",
140
+ },
141
+ {
142
+ channel: "RCBC",
143
+ logo: "/rcbc-logo.svg",
144
+ type: "DIRECT_DEBIT",
145
+ },
146
+ {
147
+ channel: "Chinabank",
148
+ logo: "/chinabank-logo.svg",
149
+ type: "DIRECT_DEBIT",
150
+ },
151
+ ];
152
+ },
153
+ },
154
+ });
155
+
156
+ const supportedPaymentMethods = [
157
+ ...props.supportedEwallets,
158
+ ...props.supportedDirectDebit,
159
+ ];
160
+
161
+ watch(selectedPaymentMethod, (value: number | null) => {
162
+ if (value !== null) {
163
+ const selectedPayment = supportedPaymentMethods[value];
164
+ channel.value = selectedPayment.channel;
165
+ type.value = selectedPayment.type;
166
+ } else {
167
+ channel.value = null;
168
+ type.value = null;
169
+ }
170
+ });
171
+ </script>
@@ -0,0 +1,33 @@
1
+ <template>
2
+ <v-row no-gutters>
3
+ <v-col cols="12">
4
+ <span
5
+ class="font-weight-medium text-subtitle-1 text-decoration-underline cursor-pointer"
6
+ @click="emit('back')"
7
+ >
8
+ Back
9
+ </span>
10
+ </v-col>
11
+ <v-col cols="12">
12
+ <span class="text-h5 font-weight-medium">{{ props.title }}</span>
13
+ </v-col>
14
+
15
+ <v-col cols="12" class="mt-4">
16
+ <slot name="default"> </slot>
17
+ </v-col>
18
+
19
+ <v-col cols="12" class="mt-4">
20
+ <slot name="footer"> </slot>
21
+ </v-col>
22
+ </v-row>
23
+ </template>
24
+
25
+ <script setup lang="ts">
26
+ const emit = defineEmits(["back"]);
27
+ const props = defineProps({
28
+ title: {
29
+ type: String,
30
+ default: "",
31
+ },
32
+ });
33
+ </script>
@@ -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>
@@ -1,7 +1,15 @@
1
1
  <template>
2
2
  <v-row no-gutters class="mb-4 pl-4 fill-height" align="center">
3
3
  <v-avatar color="surface-variant" size="28">
4
- <v-img :src="profile" width="200" height="200"></v-img>
4
+ <v-img
5
+ v-if="currentUser?.profile"
6
+ :src="profile"
7
+ width="200"
8
+ height="200"
9
+ />
10
+ <span v-else class="text-subtitle-1">{{
11
+ getNameInitials(selectedOrg?.text)
12
+ }}</span>
5
13
  </v-avatar>
6
14
 
7
15
  <v-menu
@@ -70,6 +78,7 @@
70
78
  const { currentUser } = useLocalAuth();
71
79
 
72
80
  const menu = ref(false);
81
+ const { getNameInitials } = useUtils();
73
82
 
74
83
  const profile = computed(() => {
75
84
  return `/api/public/${currentUser.value?.profile}`;
@@ -0,0 +1,128 @@
1
+ <template>
2
+ <v-card
3
+ width="100%"
4
+ variant="outlined"
5
+ border="thin"
6
+ rounded="lg"
7
+ :loading="loading"
8
+ >
9
+ <v-toolbar density="compact" color="grey-lighten-4">
10
+ <template #prepend>
11
+ <v-checkbox v-model="selectAll" hide-details class="mx-1"></v-checkbox>
12
+
13
+ <v-btn fab icon density="comfortable" @click="emit('refresh')">
14
+ <v-icon>mdi-refresh</v-icon>
15
+ </v-btn>
16
+ </template>
17
+
18
+ <template #append>
19
+ <v-row no-gutters justify="end" align="center">
20
+ <span class="mr-2 text-caption text-fontgray">
21
+ {{ props.pageRange }}
22
+ </span>
23
+ <div class="arrow-navigation">
24
+ <v-btn
25
+ icon="mdi-chevron-left"
26
+ variant="text"
27
+ density="comfortable"
28
+ :disabled="page <= 1"
29
+ @click="decrement"
30
+ />
31
+ <v-btn
32
+ icon="mdi-chevron-right"
33
+ variant="text"
34
+ density="comfortable"
35
+ :disabled="page >= props.pages"
36
+ @click="increment"
37
+ />
38
+ </div>
39
+ </v-row>
40
+ </template>
41
+
42
+ <template v-if="$slots.extension" v-slot:extension>
43
+ <slot name="extension"></slot>
44
+ </template>
45
+ </v-toolbar>
46
+
47
+ <v-data-table
48
+ v-model="selected"
49
+ v-bind="$attrs"
50
+ :headers="props.headers"
51
+ :items="props.items"
52
+ item-value="_id"
53
+ items-per-page="10"
54
+ show-select
55
+ fixed-header
56
+ hide-default-footer
57
+ hide-default-header
58
+ :loading="props.loading"
59
+ :style="`max-height: ${props.height};`"
60
+ >
61
+ <template v-if="$slots.item" v-slot:item>
62
+ <slot name="item"></slot>
63
+ </template>
64
+ </v-data-table>
65
+ </v-card>
66
+ </template>
67
+
68
+ <script setup lang="ts">
69
+ const selected = defineModel({
70
+ type: Array as PropType<Array<string>>,
71
+ default: () => [],
72
+ });
73
+ const page = defineModel("page", { type: Number, default: 0 });
74
+
75
+ const props = defineProps({
76
+ headers: {
77
+ type: Array as PropType<Array<Record<string, string>>>,
78
+ required: true,
79
+ default: () => [],
80
+ },
81
+ items: {
82
+ type: Array as PropType<Array<Record<string, string>>>,
83
+ required: true,
84
+ default: () => [],
85
+ },
86
+ pages: {
87
+ type: Number,
88
+ required: true,
89
+ default: 0,
90
+ },
91
+ pageRange: {
92
+ type: String,
93
+ required: true,
94
+ default: "-- - -- of --",
95
+ },
96
+ loading: {
97
+ type: Boolean,
98
+ required: true,
99
+ default: true,
100
+ },
101
+ height: {
102
+ type: String,
103
+ default: "",
104
+ },
105
+ });
106
+
107
+ const emit = defineEmits(["refresh", "update:pagination"]);
108
+
109
+ function increment() {
110
+ page.value++;
111
+ emit("update:pagination", page.value);
112
+ }
113
+
114
+ function decrement() {
115
+ page.value--;
116
+ emit("update:pagination", page.value);
117
+ }
118
+
119
+ const selectAll = ref(false);
120
+
121
+ watch(selectAll, (curr) => {
122
+ selected.value.splice(0, selected.value.length);
123
+ if (curr) {
124
+ const ids = props.items.map((i) => i._id as string);
125
+ selected.value.push(...ids);
126
+ }
127
+ });
128
+ </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,29 @@
1
+ export default function useFile() {
2
+ function addFile(file: File | null) {
3
+ if (!file) {
4
+ throw new Error("File not found.");
5
+ }
6
+
7
+ const formData = new FormData();
8
+ formData.append("file", file);
9
+
10
+ return useNuxtApp().$api<Record<string, any>>("/api/files", {
11
+ method: "POST",
12
+ body: formData,
13
+ });
14
+ }
15
+
16
+ function deleteFile(attachmentId: string) {
17
+ return useNuxtApp().$api<Record<string, any>>(
18
+ `/api/files/${attachmentId}`,
19
+ {
20
+ method: "DELETE",
21
+ }
22
+ );
23
+ }
24
+
25
+ return {
26
+ addFile,
27
+ deleteFile,
28
+ };
29
+ }
@@ -0,0 +1,38 @@
1
+ export default function useInvoice() {
2
+ function getBySubscriptionId({ search = "", id = "", page = 1 } = {}) {
3
+ return useNuxtApp().$api<Record<string, any>>(
4
+ `/api/invoices/subscription/${id}`,
5
+ {
6
+ method: "GET",
7
+ params: {
8
+ search,
9
+ page,
10
+ },
11
+ }
12
+ );
13
+ }
14
+
15
+ function getByNumber(number: string) {
16
+ return useNuxtApp().$api<Record<string, any>>(
17
+ `/api/invoices/number/${number}`,
18
+ {
19
+ method: "GET",
20
+ }
21
+ );
22
+ }
23
+
24
+ function getByDueDateStatus(date: string, status: string) {
25
+ return useNuxtApp().$api<Record<string, any>>(
26
+ `/api/invoices/due-date/${date}/status/${status}`,
27
+ {
28
+ method: "GET",
29
+ }
30
+ );
31
+ }
32
+
33
+ return {
34
+ getBySubscriptionId,
35
+ getByNumber,
36
+ getByDueDateStatus,
37
+ };
38
+ }
@@ -102,6 +102,8 @@ export default function useLocalAuth() {
102
102
  });
103
103
  }
104
104
 
105
+ const permissions = useState("permissions", (): Array<string> => []);
106
+
105
107
  return {
106
108
  login,
107
109
  logout,