@monkeyplus/payscope 1.0.0

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 (82) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md +41 -0
  2. package/dist/_chunks/auth.d.mts +707 -0
  3. package/dist/_chunks/database.mjs +831 -0
  4. package/dist/_chunks/db.d.mts +7100 -0
  5. package/dist/_chunks/index.d.mts +178 -0
  6. package/dist/_chunks/lib.mjs +3073 -0
  7. package/dist/_chunks/libs/better-call.d.mts +478 -0
  8. package/dist/_chunks/libs/postgres.d.mts +1 -0
  9. package/dist/_chunks/rolldown-runtime.mjs +11 -0
  10. package/dist/server/db.d.mts +2 -0
  11. package/dist/server/db.mjs +108 -0
  12. package/dist/server/env.d.mts +21 -0
  13. package/dist/server/env.mjs +22 -0
  14. package/dist/server/lib.d.mts +362 -0
  15. package/dist/server/lib.mjs +2 -0
  16. package/dist/server/router.d.mts +1218 -0
  17. package/dist/server/router.mjs +1157 -0
  18. package/dist/server/schemas/auth.d.mts +2 -0
  19. package/dist/server/schemas/auth.mjs +62 -0
  20. package/package.json +58 -0
  21. package/storefront/Readme.md +0 -0
  22. package/storefront/auth.ts +29 -0
  23. package/storefront/cart/ResumeCart.vue +217 -0
  24. package/storefront/cart/ResumeCartSelect.vue +32 -0
  25. package/storefront/cart/ShoppinCart.vue +100 -0
  26. package/storefront/cart/ShoppinCartItem.vue +99 -0
  27. package/storefront/checkout/App.vue +36 -0
  28. package/storefront/checkout/AppCart.vue +72 -0
  29. package/storefront/checkout/AppCartDiscount.vue +74 -0
  30. package/storefront/checkout/AppCartTotals.vue +72 -0
  31. package/storefront/checkout/AppLoading.vue +55 -0
  32. package/storefront/checkout/composables.ts +28 -0
  33. package/storefront/checkout/constants.ts +0 -0
  34. package/storefront/checkout/main.ts +11 -0
  35. package/storefront/checkout/pages/Address/Address.vue +95 -0
  36. package/storefront/checkout/pages/Info/Info.vue +94 -0
  37. package/storefront/checkout/pages/Info/InfoUser.vue +38 -0
  38. package/storefront/checkout/pages/Pay/Pay.vue +115 -0
  39. package/storefront/checkout/pages/Pay/Providers/BancoEconomico/BancoEconomico.vue +9 -0
  40. package/storefront/checkout/pages/Pay/Providers/Cybersource/Cybersource.vue +9 -0
  41. package/storefront/checkout/pages/Pay/Providers/Datafast/Datafast.vue +9 -0
  42. package/storefront/checkout/pages/Pay/Providers/Multipago/Multipago.vue +9 -0
  43. package/storefront/checkout/pages/Pay/Providers/Pagomedios/Pagomedios.vue +93 -0
  44. package/storefront/checkout/pages/Pay/Providers/Pagomedios/composable.ts +23 -0
  45. package/storefront/checkout/pages/Pay/Providers/Paypal/Paypal.vue +168 -0
  46. package/storefront/checkout/pages/Pay/Providers/Paypal/composable.ts +33 -0
  47. package/storefront/checkout/pages/Pay/Providers/Placetopay/Placetopay.vue +9 -0
  48. package/storefront/checkout/pages/Pay/Providers/Wabi/Wabi.vue +9 -0
  49. package/storefront/checkout/pages/Pay/Providers/composable.ts +30 -0
  50. package/storefront/checkout/pages/Payment/Payment.vue +19 -0
  51. package/storefront/checkout/pages/Payment/PaymentStatus.vue +187 -0
  52. package/storefront/checkout/pages/Payment/PaymentStatusDetail.vue +77 -0
  53. package/storefront/checkout/pages/Payment/composable.ts +81 -0
  54. package/storefront/checkout/pages/Shipping/Shipping.vue +67 -0
  55. package/storefront/checkout/pages/StepInfo.vue +37 -0
  56. package/storefront/checkout/router.ts +59 -0
  57. package/storefront/index.ts +3 -0
  58. package/storefront/login/App.vue +9 -0
  59. package/storefront/login/main.ts +10 -0
  60. package/storefront/login/pages/SignIn/Login.vue +82 -0
  61. package/storefront/login/pages/SignUp/SignUp.vue +99 -0
  62. package/storefront/login/router.ts +15 -0
  63. package/storefront/product/AddProduct.vue +303 -0
  64. package/storefront/product/AddProductNumber.vue +62 -0
  65. package/storefront/product/AddProductVariant.vue +66 -0
  66. package/storefront/profile/App.vue +88 -0
  67. package/storefront/profile/main.ts +10 -0
  68. package/storefront/profile/pages/Addresses/Addresses.vue +79 -0
  69. package/storefront/profile/pages/Addresses/AddressesForm.vue +95 -0
  70. package/storefront/profile/pages/Addresses/AddressesModal.vue +24 -0
  71. package/storefront/profile/pages/Buys/Buys.vue +8 -0
  72. package/storefront/profile/pages/Me/Me.vue +15 -0
  73. package/storefront/profile/pages/Me/MeBilling.vue +79 -0
  74. package/storefront/profile/pages/Me/MeBillingForm.vue +66 -0
  75. package/storefront/profile/pages/Me/MeBillingModal.vue +24 -0
  76. package/storefront/profile/pages/Me/MeInfo.vue +75 -0
  77. package/storefront/profile/pages/Me/MePassword.vue +53 -0
  78. package/storefront/profile/pages/Me/MeSubscriptions.vue +15 -0
  79. package/storefront/profile/pages/Returns/Returns.vue +8 -0
  80. package/storefront/profile/pages/Whislist/Whislist.vue +8 -0
  81. package/storefront/profile/router.ts +32 -0
  82. package/storefront/stores.ts +320 -0
@@ -0,0 +1,320 @@
1
+ import { useAsyncState } from '@vueuse/core';
2
+ import { ofetch } from 'ofetch';
3
+ import { defineStore } from 'pinia';
4
+ import { computed, ref } from 'vue';
5
+
6
+ export const useCartStore = defineStore('cart', () => {
7
+ const { state: items, isLoading: loadingInit } = useAsyncState(async () => {
8
+ const r = await ofetch('/storefront/cart');
9
+ return r.lineItems as any[];
10
+ }, [] as any[]);
11
+
12
+ const { executeImmediate: addToCart, isLoading: loadingAdd } = useAsyncState(
13
+ async (body: { id: any, quantity: number }) => {
14
+ const r = await ofetch('/storefront/cart', {
15
+ method: 'POST',
16
+ body,
17
+ });
18
+ items.value = r.lineItems || [];
19
+ return {} as any;
20
+ },
21
+ null,
22
+ {
23
+ immediate: false,
24
+ },
25
+ );
26
+
27
+ const total = computed(() => {
28
+ return items.value.reduce((acc: number, item: any) => acc + (item.variant?.price * item.quantity), 0).toFixed(2);
29
+ });
30
+ const drawer = ref(false);
31
+ const loading = computed(() => {
32
+ return loadingInit.value || loadingAdd.value;
33
+ });
34
+ return {
35
+ addToCart,
36
+ items,
37
+ drawer,
38
+ total,
39
+ loading,
40
+ };
41
+ });
42
+
43
+ interface Checkout {
44
+ lineItems: any[]
45
+ invoice: {
46
+ total: number
47
+ base: number
48
+ discounts: any[]
49
+ discount: number
50
+ totalTax: number
51
+ shipping: number
52
+ lineItemsSubtotalPrice: number
53
+ totalDiscount: number
54
+ }
55
+ address: {
56
+ id: number
57
+ formatted: string
58
+ }
59
+ billing: {
60
+ id: number
61
+ formatted: string
62
+ }
63
+ shipping: {
64
+ id: any
65
+ }
66
+ }
67
+ export const useCheckoutStore = defineStore('checkout', () => {
68
+ const isReady = ref(false);
69
+ const { execute, state: checkout, executeImmediate: getCheckout } = useAsyncState(async () => {
70
+ const r = await ofetch<Checkout>('/storefront/checkout');
71
+ return r;
72
+ }, {
73
+ invoice: {
74
+ total: 0,
75
+ base: 0,
76
+ discounts: [],
77
+ shipping: 0,
78
+ discount: 0,
79
+ totalTax: 0,
80
+ lineItemsSubtotalPrice: 0,
81
+ totalDiscount: 0,
82
+ },
83
+ lineItems: [],
84
+ address: {
85
+ id: 0,
86
+ formatted: '',
87
+ },
88
+ billing: {
89
+ id: 0,
90
+ formatted: '',
91
+ },
92
+ shipping: {
93
+ id: 0,
94
+ },
95
+ }, {
96
+ immediate: false,
97
+ resetOnExecute: false,
98
+ onSuccess() {
99
+ isReady.value = true;
100
+ },
101
+
102
+ });
103
+ execute(800);
104
+
105
+ const items = computed(() => {
106
+ return (checkout.value.lineItems || []).map((v) => {
107
+ return {
108
+ id: v.id,
109
+ title: v.title,
110
+ subtitle: v.variant,
111
+ image: v.variant?.image?.src,
112
+ quantity: v.quantity,
113
+ options: v.variant?.selectedOptions?.map((option: any) => {
114
+ return option;
115
+ }) as { name: string, value: string }[],
116
+ total: (v.quantity * v.variant?.price).toFixed(2),
117
+ };
118
+ });
119
+ });
120
+ const invoice = computed(() => {
121
+ return checkout.value.invoice;
122
+ });
123
+
124
+ const totals = computed(() => {
125
+ return {
126
+ subtotal: Number(checkout.value.invoice.lineItemsSubtotalPrice).toFixed(2),
127
+ total: Number(checkout.value.invoice.total).toFixed(2),
128
+ base: Number(checkout.value.invoice.base).toFixed(2),
129
+ totalTax: Number(checkout.value.invoice.totalTax).toFixed(2),
130
+ shipping: Number(checkout.value.invoice.shipping).toFixed(2),
131
+ discount: Number(checkout.value.invoice.totalDiscount).toFixed(2),
132
+ };
133
+ });
134
+
135
+ const toast = useToast();
136
+ const { isLoading: loadingDiscount, executeImmediate: applyDiscount } = useAsyncState(async (coupon: string) => {
137
+ if (!coupon) {
138
+ return;
139
+ }
140
+ await ofetch<Checkout>('/storefront/checkout/discount', {
141
+ method: 'POST',
142
+ body: { coupon },
143
+ });
144
+ await getCheckout();
145
+ }, null, {
146
+ immediate: false,
147
+ onSuccess() {
148
+ toast.add({
149
+ title: 'Código de descuento aplicado',
150
+ description: 'El código de descuento ha sido aplicado a tu pedido',
151
+ });
152
+ },
153
+ onError(e: any) {
154
+ console.error(e);
155
+ toast.add({
156
+ title: 'Error al aplicar el código de descuento',
157
+ description: 'El código de descuento no es válido',
158
+ color: 'error',
159
+ });
160
+ },
161
+ });
162
+
163
+ const { isLoading: loadingAddress, executeImmediate: setAddress } = useAsyncState(async (address: any) => {
164
+ await ofetch<Checkout>('/storefront/checkout/address', {
165
+ method: 'POST',
166
+ body: address,
167
+ });
168
+ await getCheckout();
169
+ }, null, {
170
+ immediate: false,
171
+ onSuccess() {
172
+ // toast.add({
173
+ // title: 'Código de descuento aplicado',
174
+ // description: 'El código de descuento ha sido aplicado a tu pedido',
175
+ // });
176
+ },
177
+ onError(e: any) {
178
+ console.error(e);
179
+ // toast.add({
180
+ // title: 'Error al aplicar el código de descuento',
181
+ // description: 'El código de descuento no es válido',
182
+ // color: 'error',
183
+ // });
184
+ },
185
+ });
186
+ const address = computed(() => {
187
+ return checkout.value.address;
188
+ });
189
+ const billing = computed(() => {
190
+ return checkout.value.billing;
191
+ });
192
+ const shipping = computed(() => {
193
+ return checkout.value.shipping;
194
+ });
195
+
196
+ const { isLoading: loadingShipping, executeImmediate: getShippings, state: shippings } = useAsyncState(async () => {
197
+ const r = await ofetch<any>('/storefront/checkout/shippings');
198
+ return r.items as any[];
199
+ }, [] as any[], {
200
+ immediate: false,
201
+ });
202
+
203
+ const { isLoading: loadingSetShipping, executeImmediate: setShipping } = useAsyncState(async (body: any) => {
204
+ await ofetch<Checkout>('/storefront/checkout/shippings', {
205
+ method: 'POST',
206
+ body,
207
+ });
208
+ await getCheckout();
209
+ }, null, {
210
+ immediate: false,
211
+ onSuccess() {
212
+ // toast.add({
213
+ // title: 'Código de descuento aplicado',
214
+ // description: 'El código de descuento ha sido aplicado a tu pedido',
215
+ // });
216
+ },
217
+ onError(e: any) {
218
+ console.error(e);
219
+ // toast.add({
220
+ // title: 'Error al aplicar el código de descuento',
221
+ // description: 'El código de descuento no es válido',
222
+ // color: 'error',
223
+ // });
224
+ },
225
+ });
226
+ const { isLoading: loadingSetBilling, executeImmediate: setBilling } = useAsyncState(async (body: any) => {
227
+ await ofetch<Checkout>('/storefront/checkout/billing', {
228
+ method: 'POST',
229
+ body,
230
+ });
231
+ await getCheckout();
232
+ }, null, {
233
+ immediate: false,
234
+ onSuccess() {
235
+ // toast.add({
236
+ // title: 'Código de descuento aplicado',
237
+ // description: 'El código de descuento ha sido aplicado a tu pedido',
238
+ // });
239
+ },
240
+ onError(e: any) {
241
+ console.error(e);
242
+ // toast.add({
243
+ // title: 'Error al aplicar el código de descuento',
244
+ // description: 'El código de descuento no es válido',
245
+ // color: 'error',
246
+ // });
247
+ },
248
+ });
249
+ return {
250
+ address,
251
+ billing,
252
+ checkout,
253
+ items,
254
+ invoice,
255
+ totals,
256
+ applyDiscount,
257
+ loadingDiscount,
258
+ loadingSetBilling,
259
+ setAddress,
260
+ setBilling,
261
+ loadingAddress,
262
+ isReady,
263
+ getShippings,
264
+ shippings,
265
+ loadingShipping,
266
+ loadingSetShipping,
267
+ setShipping,
268
+ shipping,
269
+ };
270
+ });
271
+
272
+ export const useAccountStore = defineStore('account', () => {
273
+ const { state: billings, isLoading: loadingGetBilling, executeImmediate: getBillings } = useAsyncState(async () => {
274
+ const r = await ofetch('/storefront/account/billings');
275
+ return r;
276
+ }, [] as any[]);
277
+ const { state: addresses, isLoading: loadingGetAddress, executeImmediate: getAddress } = useAsyncState(async () => {
278
+ const r = await ofetch('/storefront/account/addresses');
279
+ return r;
280
+ }, [] as any[]);
281
+
282
+ const { executeImmediate: mutate, isLoading: loadingMutation } = useAsyncState(async (type: 'create' | 'update' | 'delete', method: 'addresses' | 'billings', body: any) => {
283
+ if (type === 'create') {
284
+ await ofetch(`/storefront/account/${method}`, {
285
+ method: 'POST',
286
+ body,
287
+ });
288
+ }
289
+ if (type === 'update') {
290
+ await ofetch(`/storefront/account/${method}/${body.id}`, {
291
+ method: 'PATCH',
292
+ body,
293
+ });
294
+ }
295
+ if (type === 'delete') {
296
+ await ofetch(`/storefront/account/${method}/${body.id}`, {
297
+ method: 'DELETE',
298
+ });
299
+ }
300
+ return method;
301
+ }, null, {
302
+ onSuccess(method) {
303
+ if (method === 'addresses') {
304
+ getAddress();
305
+ }
306
+ if (method === 'billings') {
307
+ getBillings();
308
+ }
309
+ },
310
+ });
311
+ return {
312
+ billings,
313
+ addresses,
314
+ loadingMutation,
315
+ mutate,
316
+ loadingGetAddress,
317
+ loadingGetBilling,
318
+
319
+ };
320
+ });