@goweekdays/layer-common 0.0.10 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @goweekdays/layer-common
2
2
 
3
+ ## 0.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 833df66: Revise payment method
8
+
3
9
  ## 0.0.10
4
10
 
5
11
  ### 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>
@@ -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,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,
@@ -0,0 +1,86 @@
1
+ export default function useMember() {
2
+ const member = useState("member", (): TMember => {
3
+ return {
4
+ _id: "",
5
+ name: "",
6
+ user: "",
7
+ role: "",
8
+ status: "",
9
+ createdAt: "",
10
+ updatedAt: "",
11
+ deletedAt: "",
12
+ };
13
+ });
14
+
15
+ function setMember(value?: Partial<TMember>) {
16
+ member.value._id = value?._id ?? "";
17
+ member.value.user = value?.user ?? "";
18
+ member.value.role = value?.role ?? "";
19
+ member.value.status = value?.status ?? "";
20
+ member.value.createdAt = value?.createdAt ?? "";
21
+ member.value.updatedAt = value?.updatedAt ?? "";
22
+ member.value.deletedAt = value?.deletedAt ?? "";
23
+ }
24
+
25
+ function inviteMember(value: Partial<TMember>) {
26
+ delete value.createdAt;
27
+ delete value.updatedAt;
28
+ delete value._id;
29
+ delete value.status;
30
+
31
+ return useNuxtApp().$api("/api/members", {
32
+ method: "POST",
33
+ body: JSON.stringify(value),
34
+ });
35
+ }
36
+
37
+ function getAll({
38
+ search = "",
39
+ page = 1,
40
+ org = "",
41
+ user = "",
42
+ type = "main",
43
+ limit = 10,
44
+ status = "active",
45
+ } = {}) {
46
+ return useNuxtApp().$api<TKeyValuePair>("/api/members", {
47
+ method: "GET",
48
+ query: { search, page, org, user, type, limit, status },
49
+ });
50
+ }
51
+
52
+ const page = useState("memberPage", () => 1);
53
+ const pages = useState("memberPages", () => 0);
54
+ const pageRange = useState("memberPageRange", () => "0-0 of 0");
55
+
56
+ function getMemberById(id = "") {
57
+ return useNuxtApp().$api<TMember>(`/api/members/id/${id}`, {
58
+ method: "GET",
59
+ });
60
+ }
61
+
62
+ function getByUserId(id = "") {
63
+ return useNuxtApp().$api<TMember>(`/api/members/user/${id}`, {
64
+ method: "GET",
65
+ });
66
+ }
67
+
68
+ function getOrgMember(id = "") {
69
+ return useNuxtApp().$api<TKeyValuePair>(`/api/members/org/${id}/main`, {
70
+ method: "GET",
71
+ });
72
+ }
73
+
74
+ return {
75
+ member,
76
+ setMember,
77
+ inviteMember,
78
+ getAll,
79
+ page,
80
+ pages,
81
+ pageRange,
82
+ getMemberById,
83
+ getOrgMember,
84
+ getByUserId,
85
+ };
86
+ }
@@ -70,6 +70,15 @@ export default function usePaymentMethod() {
70
70
  );
71
71
  }
72
72
 
73
+ function getById(id = "") {
74
+ return useNuxtApp().$api<Record<string, any>>(
75
+ `/api/payment-methods/id/${id}`,
76
+ {
77
+ method: "GET",
78
+ }
79
+ );
80
+ }
81
+
73
82
  const eWalletNumber = useState("eWalletNumber", () => "");
74
83
  const cardNumber = useState("cardNumber", () => "");
75
84
  const cardExpiration = useState("cardExpiration", () => "");
@@ -85,6 +94,72 @@ export default function usePaymentMethod() {
85
94
  cardholderName.value = "";
86
95
  }
87
96
 
97
+ function linkOnly(value: Record<string, any>) {
98
+ return useNuxtApp().$api<Record<string, any>>(
99
+ "/api/payment-methods/link-only",
100
+ {
101
+ method: "POST",
102
+ body: value,
103
+ }
104
+ );
105
+ }
106
+
107
+ const supportedEwallets = [
108
+ {
109
+ channel: "GCASH",
110
+ logo: "/gcash-logo.svg",
111
+ type: "EWALLET",
112
+ },
113
+ {
114
+ channel: "PAYMAYA",
115
+ logo: "/paymaya-logo.svg",
116
+ type: "EWALLET",
117
+ },
118
+ {
119
+ channel: "GRABPAY",
120
+ logo: "/grabpay-logo.svg",
121
+ type: "EWALLET",
122
+ },
123
+ {
124
+ channel: "SHOPEEPAY",
125
+ logo: "/shopeepay-logo.svg",
126
+ type: "EWALLET",
127
+ },
128
+ ];
129
+
130
+ const supportedDirectDebit = [
131
+ {
132
+ channel: "UBP",
133
+ logo: "/ubp-logo.svg",
134
+ type: "DIRECT_DEBIT",
135
+ },
136
+ {
137
+ channel: "BDO",
138
+ logo: "/bdo-logo.svg",
139
+ type: "DIRECT_DEBIT",
140
+ },
141
+ {
142
+ channel: "BPI",
143
+ logo: "/bpi-logo.svg",
144
+ type: "DIRECT_DEBIT",
145
+ },
146
+ {
147
+ channel: "RCBC",
148
+ logo: "/rcbc-logo.svg",
149
+ type: "DIRECT_DEBIT",
150
+ },
151
+ {
152
+ channel: "Chinabank",
153
+ logo: "/chinabank-logo.svg",
154
+ type: "DIRECT_DEBIT",
155
+ },
156
+ ];
157
+
158
+ const supportedPaymentMethods = [
159
+ ...supportedEwallets,
160
+ ...supportedDirectDebit,
161
+ ];
162
+
88
163
  return {
89
164
  linkEWallet,
90
165
  linkCard,
@@ -97,5 +172,8 @@ export default function usePaymentMethod() {
97
172
  cardholderName,
98
173
  selectedPaymentMethod,
99
174
  reset,
175
+ linkOnly,
176
+ getById,
177
+ supportedPaymentMethods,
100
178
  };
101
179
  }
@@ -0,0 +1,15 @@
1
+ export default function usePrice() {
2
+ function getByNameType(name: string, type: string) {
3
+ return useNuxtApp().$api<Record<string, any>>("/api/prices/price", {
4
+ method: "GET",
5
+ params: {
6
+ name,
7
+ type,
8
+ },
9
+ });
10
+ }
11
+
12
+ return {
13
+ getByNameType,
14
+ };
15
+ }
@@ -18,7 +18,7 @@ export default function usePromoCode() {
18
18
  }
19
19
 
20
20
  function getByCode(code: string, type?: string, assigned?: boolean) {
21
- return useNuxtApp().$api<Record<string, any>>("/api/promo-codes/code", {
21
+ return useNuxtApp().$api<TPromoCode>("/api/promo-codes/code", {
22
22
  method: "GET",
23
23
  params: {
24
24
  code,
@@ -28,9 +28,16 @@ export default function usePromoCode() {
28
28
  });
29
29
  }
30
30
 
31
+ function getById(id: string) {
32
+ return useNuxtApp().$api<TPromoCode>(`/api/promo-codes/id/${id}`, {
33
+ method: "GET",
34
+ });
35
+ }
36
+
31
37
  return {
32
38
  add,
33
39
  getPromoCodes,
34
40
  getByCode,
41
+ getById,
35
42
  };
36
43
  }