diff --git a/components/Account/Modals/AddPaymentMethodModal.tsx b/components/Account/Modals/AddPaymentMethodModal.tsx index 9b98b153..093abeff 100644 --- a/components/Account/Modals/AddPaymentMethodModal.tsx +++ b/components/Account/Modals/AddPaymentMethodModal.tsx @@ -2,7 +2,7 @@ import payloadClient from '../../../utils/axiosPayloadInstance'; import { PaymentMethods, pagoMovilSchema, zelleSchema } from '../../Checkout/CheckoutForm'; import * as yup from 'yup'; import { Form } from '../../Forms/SmartForm'; -import { useMutation } from 'react-query'; +import { useMutation, useQueryClient } from 'react-query'; import { User } from '../../../payload-types'; const postPaymentMethod = async (data: any) => { @@ -19,6 +19,7 @@ const PaymentMethodsSchema = yup.object().shape({ export default function AddPaymentMethodModal({ onClose, user }: { onClose: () => void, user: User }) { const mutation = useMutation(postPaymentMethod) + const queryClient = useQueryClient(); function onSubmit(values: any) { @@ -32,6 +33,7 @@ export default function AddPaymentMethodModal({ onClose, user }: { onClose: () = }, { onSuccess: () => { + queryClient.invalidateQueries('userPaymentMethods'); onClose(); }, onError: () => { diff --git a/components/Checkout/AdminPaymentMethods.tsx b/components/Checkout/AdminPaymentMethods.tsx new file mode 100644 index 00000000..d33de31c --- /dev/null +++ b/components/Checkout/AdminPaymentMethods.tsx @@ -0,0 +1,37 @@ +import { PagoMovil, Zelle } from "../../payload-types"; +import AccordionArrow from "../Accordion/AccordionArrow"; + +type AdminPaymentMethodsProps = { + zelle: Zelle + pagoMovil: PagoMovil; +} + +export default function AdminPaymentMethods({ zelle, pagoMovil }: AdminPaymentMethodsProps) { + return ( + <> + +
+
+

Email del beneficiario: {zelle.email}

+

Nombre del beneficiario: {zelle.zelleHolder}

+

Banco del beneficiario: {zelle.bank}

+
+
+ + } /> + +
+
+

Cédula o RIF del beneficiario: {pagoMovil.cid}

+

Nombre del beneficiario: {pagoMovil.name}

+

Banco del beneficiario: {pagoMovil.bank}

+

Número de teléfono del beneficiario: {pagoMovil.phone}

+
+
+ + } /> + + ) +} \ No newline at end of file diff --git a/components/Checkout/CheckoutFormGuestView.tsx b/components/Checkout/CheckoutFormGuestView.tsx index b1227068..ef38d9c7 100644 --- a/components/Checkout/CheckoutFormGuestView.tsx +++ b/components/Checkout/CheckoutFormGuestView.tsx @@ -6,6 +6,7 @@ import { Product } from '../../payload-types'; import { useRouter } from 'next/router'; import { DaisyUiAlert } from '../Alert/DaisyUiAlerts'; import { apiUrl } from '../../utils/env'; +import { LoadSpinner } from '../Loaders/DaisyUiLoaders'; export type GuestUserOrderData = { customer: { @@ -144,12 +145,14 @@ export default function CheckoutFormGuestView({ productData }: CheckoutFormGuest
{mutation.isError && } + {mutation.isLoading && } ); } diff --git a/components/Checkout/CheckoutFormUserView.tsx b/components/Checkout/CheckoutFormUserView.tsx index 786c2535..76be4989 100644 --- a/components/Checkout/CheckoutFormUserView.tsx +++ b/components/Checkout/CheckoutFormUserView.tsx @@ -8,6 +8,7 @@ import { useRouter } from 'next/router'; import SkeletonAcordion from '../Skeletons/SkeletonAcordion'; import { DaisyUiAlert } from '../Alert/DaisyUiAlerts'; import { PagoMovilUserOrderData, ZelleUserOrderData } from './CheckoutFormGuestView'; +import { LoadSpinner } from '../Loaders/DaisyUiLoaders'; type UserPaymentMethodsResponseSuccess = { paymentMethods: PaymentMethod[] @@ -158,7 +159,10 @@ export default function CheckoutFormUserView({ productData, user }: CheckoutForm {mutation.isSuccess ? (
-
+ + ) : null} + {mutation.isLoading ? ( + ) : null} diff --git a/components/Checkout/CheckoutItem.tsx b/components/Checkout/CheckoutItem.tsx index b3fe225a..dd8c8105 100644 --- a/components/Checkout/CheckoutItem.tsx +++ b/components/Checkout/CheckoutItem.tsx @@ -1,7 +1,11 @@ import Image from 'next/image'; import { Category, Course, Media, Plan, Product } from '../../payload-types'; -export default function CheckoutItem({ name, description, productPrice, productImage, productType }: Product) { +type CheckoutItemProps = Product & { + children?: React.ReactNode; +}; + +export default function CheckoutItem({ name, description, productPrice, productImage, productType, children }: CheckoutItemProps) { const productImages = productImage as Media; const relation = productType?.relationTo; const categorysToChoose = { @@ -81,6 +85,7 @@ export default function CheckoutItem({ name, description, productPrice, productI + {children} ); diff --git a/components/Header/Header.tsx b/components/Header/Header.tsx index e9e02958..72735c03 100644 --- a/components/Header/Header.tsx +++ b/components/Header/Header.tsx @@ -12,15 +12,18 @@ export default function Header() {
    -
  • - -
  • Menu -
  • +
  • + +
diff --git a/components/Product/RelatedProduct.tsx b/components/Product/RelatedProduct.tsx index 6d4a1dab..0121b534 100644 --- a/components/Product/RelatedProduct.tsx +++ b/components/Product/RelatedProduct.tsx @@ -16,7 +16,7 @@ export default function ReleatedProduct({ title, price, imgAlt, imgURL, productI
{imgAlt}
-
+

diff --git a/components/VerticalPadding/index.module.scss b/components/VerticalPadding/index.module.css similarity index 100% rename from components/VerticalPadding/index.module.scss rename to components/VerticalPadding/index.module.css diff --git a/components/VerticalPadding/index.tsx b/components/VerticalPadding/index.tsx index b5fc7173..34ee0190 100644 --- a/components/VerticalPadding/index.tsx +++ b/components/VerticalPadding/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import classes from './index.module.scss'; +import classes from './index.module.css'; export type VerticalPaddingOptions = 'large' | 'medium' | 'small' | 'none'; diff --git a/components/home/HomeBanner.tsx b/components/home/HomeBanner.tsx index fdc30c60..ee29d8f2 100644 --- a/components/home/HomeBanner.tsx +++ b/components/home/HomeBanner.tsx @@ -24,7 +24,7 @@ export default function HomeBanner() {

En el centro de capacitacion profesional, nuestro objetivo es transformar la forma en que aprendes y adquieres conocimiento. Nuestra plataforma LMS líder en el mercado te ofrece una experiencia de aprendizaje revolucionaria, diseñada para potenciar tu crecimiento personal y profesional.

- + Ir a la tienda diff --git a/package-lock.json b/package-lock.json index 5ec25f14..99248c6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -232,6 +232,11 @@ "stylis": "4.2.0" } }, + "node_modules/@emotion/babel-plugin/node_modules/@emotion/memoize": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", + "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" + }, "node_modules/@emotion/cache": { "version": "11.11.0", "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.11.0.tgz", @@ -244,6 +249,11 @@ "stylis": "4.2.0" } }, + "node_modules/@emotion/cache/node_modules/@emotion/memoize": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", + "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" + }, "node_modules/@emotion/hash": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.1.tgz", @@ -258,17 +268,12 @@ "@emotion/memoize": "0.7.4" } }, - "node_modules/@emotion/is-prop-valid/node_modules/@emotion/memoize": { + "node_modules/@emotion/memoize": { "version": "0.7.4", "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz", "integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==", "optional": true }, - "node_modules/@emotion/memoize": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", - "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" - }, "node_modules/@emotion/react": { "version": "11.11.0", "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.11.0.tgz", @@ -304,6 +309,11 @@ "csstype": "^3.0.2" } }, + "node_modules/@emotion/serialize/node_modules/@emotion/memoize": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", + "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" + }, "node_modules/@emotion/sheet": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.2.2.tgz", @@ -1569,14 +1579,6 @@ "node": ">=10" } }, - "node_modules/cosmiconfig/node_modules/yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "engines": { - "node": ">= 6" - } - }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -1876,11 +1878,6 @@ "is-arrayish": "^0.2.1" } }, - "node_modules/error-ex/node_modules/is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" - }, "node_modules/es-abstract": { "version": "1.21.1", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.21.1.tgz", @@ -2938,13 +2935,6 @@ "url": "https://opencollective.com/immer" } }, - "node_modules/immutable": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.0.tgz", - "integrity": "sha512-0AOCmOip+xgJwEVTQj1EfiDDOkPmuyllDuTuEX+DDXUgapLAsBIfkg3sxCYyCEA8mQqZrrxPUGjcOQ2JS3WLkg==", - "optional": true, - "peer": true - }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -3016,6 +3006,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" + }, "node_modules/is-bigint": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", @@ -4476,24 +4471,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/sass": { - "version": "1.62.1", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.62.1.tgz", - "integrity": "sha512-NHpxIzN29MXvWiuswfc1W3I0N8SXBd8UR26WntmDlRYf0bSADnwnOjsyMZ3lMezSlArD33Vs3YFhp7dWvL770A==", - "optional": true, - "peer": true, - "dependencies": { - "chokidar": ">=3.0.0 <4.0.0", - "immutable": "^4.0.0", - "source-map-js": ">=0.6.2 <2.0.0" - }, - "bin": { - "sass": "sass.js" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/scheduler": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", @@ -4917,6 +4894,14 @@ } } }, + "node_modules/tailwindcss/node_modules/yaml": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", + "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==", + "engines": { + "node": ">= 14" + } + }, "node_modules/tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", @@ -5276,11 +5261,11 @@ "dev": true }, "node_modules/yaml": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", - "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==", + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", "engines": { - "node": ">= 14" + "node": ">= 6" } }, "node_modules/yocto-queue": { @@ -5455,6 +5440,13 @@ "find-root": "^1.1.0", "source-map": "^0.5.7", "stylis": "4.2.0" + }, + "dependencies": { + "@emotion/memoize": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", + "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" + } } }, "@emotion/cache": { @@ -5467,6 +5459,13 @@ "@emotion/utils": "^1.2.1", "@emotion/weak-memoize": "^0.3.1", "stylis": "4.2.0" + }, + "dependencies": { + "@emotion/memoize": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", + "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" + } } }, "@emotion/hash": { @@ -5481,20 +5480,13 @@ "optional": true, "requires": { "@emotion/memoize": "0.7.4" - }, - "dependencies": { - "@emotion/memoize": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz", - "integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==", - "optional": true - } } }, "@emotion/memoize": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", - "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz", + "integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==", + "optional": true }, "@emotion/react": { "version": "11.11.0", @@ -5521,6 +5513,13 @@ "@emotion/unitless": "^0.8.1", "@emotion/utils": "^1.2.1", "csstype": "^3.0.2" + }, + "dependencies": { + "@emotion/memoize": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", + "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" + } } }, "@emotion/sheet": { @@ -6399,13 +6398,6 @@ "parse-json": "^5.0.0", "path-type": "^4.0.0", "yaml": "^1.10.0" - }, - "dependencies": { - "yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==" - } } }, "cross-spawn": { @@ -6656,13 +6648,6 @@ "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", "requires": { "is-arrayish": "^0.2.1" - }, - "dependencies": { - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" - } } }, "es-abstract": { @@ -7439,13 +7424,6 @@ "resolved": "https://registry.npmjs.org/immer/-/immer-9.0.21.tgz", "integrity": "sha512-bc4NBHqOqSfRW7POMkHd51LvClaeMXpm8dx0e8oE2GORbq5aRK7Bxl4FyzVLdGtLmvLKL7BTDBG5ACQm4HWjTA==" }, - "immutable": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.0.tgz", - "integrity": "sha512-0AOCmOip+xgJwEVTQj1EfiDDOkPmuyllDuTuEX+DDXUgapLAsBIfkg3sxCYyCEA8mQqZrrxPUGjcOQ2JS3WLkg==", - "optional": true, - "peer": true - }, "import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -7502,6 +7480,11 @@ "is-typed-array": "^1.1.10" } }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" + }, "is-bigint": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", @@ -8484,18 +8467,6 @@ "is-regex": "^1.1.4" } }, - "sass": { - "version": "1.62.1", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.62.1.tgz", - "integrity": "sha512-NHpxIzN29MXvWiuswfc1W3I0N8SXBd8UR26WntmDlRYf0bSADnwnOjsyMZ3lMezSlArD33Vs3YFhp7dWvL770A==", - "optional": true, - "peer": true, - "requires": { - "chokidar": ">=3.0.0 <4.0.0", - "immutable": "^4.0.0", - "source-map-js": ">=0.6.2 <2.0.0" - } - }, "scheduler": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", @@ -8789,6 +8760,11 @@ "lilconfig": "^2.0.5", "yaml": "^2.1.1" } + }, + "yaml": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", + "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==" } } }, @@ -9056,9 +9032,9 @@ "dev": true }, "yaml": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", - "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==" + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==" }, "yocto-queue": { "version": "0.1.0", diff --git a/pages/checkout/[id].tsx b/pages/checkout/[id].tsx index 6e54ea76..975ddc2f 100644 --- a/pages/checkout/[id].tsx +++ b/pages/checkout/[id].tsx @@ -1,8 +1,8 @@ -import axios from 'axios'; +import axios, { AxiosResponse } from 'axios'; import CheckoutForm from '../../components/Checkout/CheckoutForm'; import Layout from '../../components/Layout/Layout'; import payloadClient from '../../utils/axiosPayloadInstance'; -import { Product, User } from '../../payload-types'; +import { PagoMovil, Product, User, Zelle } from '../../payload-types'; import CheckoutItem from '../../components/Checkout/CheckoutItem'; import { useAuth } from '../../components/Auth'; import { forwardRef } from 'react'; @@ -10,15 +10,29 @@ import { IndexPageRef } from '../../utils/types/common'; import PageTransition from '../../components/PageTransition'; import { GetServerSidePropsContext } from 'next'; import { apiUrl } from '../../utils/env'; +import tryCatch from '../../utils/tryCatch'; +import AdminPaymentMethods from '../../components/Checkout/AdminPaymentMethods'; type CheckoutPageProps = { data: Product; + zelle: Zelle + pagoMovil: PagoMovil } function CheckoutPage(props: CheckoutPageProps, ref: IndexPageRef) { const { user } = useAuth(); - const { data } = props; + const { data, zelle, pagoMovil } = props; + + if (!data) { + return ( + +
+

No se pudo cargar el producto

+
+
+ ) + } return ( @@ -42,9 +56,9 @@ function CheckoutPage(props: CheckoutPageProps, ref: IndexPageRef) { }
- + + +
(apiUrl + '/api/products/' + productId, { - // const response = await payloadClient.get('/api/products' + productId, { - // const response = await axios.get(process.env.NEXT_PUBLIC_CMS_URL + '/api/products/644e84b7b0808709d2584aa2', { - // Make sure to include cookies with fetch - withCredentials: true, - headers: { - Authorization: `JWT ${context.req.cookies['payload-token']}`, - }, - }); + const [response, responseError] = await tryCatch>(axios.get(apiUrl + '/api/products/' + productId, { + // const response = await payloadClient.get('/api/products' + productId, { + // const response = await axios.get(process.env.NEXT_PUBLIC_CMS_URL + '/api/products/644e84b7b0808709d2584aa2', { + // Make sure to include cookies with fetch + withCredentials: true, + headers: { + Authorization: `JWT ${context.req.cookies['payload-token']}`, + }, + })) + + if (responseError) { + console.log(responseError) + return { + props: { + data: null, + } + } + } + + const [pagoMovil, pagoMovilError] = await tryCatch>(axios.get(apiUrl + '/api/globals/pago-movil/')) + + if (pagoMovilError) { + console.log(pagoMovilError) + } + + const [zelle, zelleError] = await tryCatch>(axios.get(apiUrl + '/api/globals/zelle/')) + + if (zelleError) { + console.log(zelleError) + } - console.log(response.data) - return { - props: { - data: response.data, - }, // will be passed to the page component as props - }; - } catch (error) { - console.log(error); return { props: { - data: null, + data: response?.data, + zelle: zelle?.data, + pagoMovil: pagoMovil?.data, }, // will be passed to the page component as props }; - } } export default forwardRef(CheckoutPage) \ No newline at end of file diff --git a/pages/dashboard/order/[id].tsx b/pages/dashboard/order/[id].tsx index 70e84d34..65b496cd 100644 --- a/pages/dashboard/order/[id].tsx +++ b/pages/dashboard/order/[id].tsx @@ -1,7 +1,7 @@ -import axios from 'axios'; +import axios, { AxiosResponse } from 'axios'; import CheckoutForm from '../../../components/Checkout/CheckoutForm'; import Layout from '../../../components/Layout/Layout'; -import { Order, Product, User } from '../../../payload-types'; +import { Order, PagoMovil, Product, User, Zelle } from '../../../payload-types'; import CheckoutItem from '../../../components/Checkout/CheckoutItem'; import { useAuth } from '../../../components/Auth'; import { forwardRef } from 'react'; @@ -10,15 +10,19 @@ import PageTransition from '../../../components/PageTransition'; import { GetServerSidePropsContext } from 'next'; import OrderForm from '../../../components/Order/OrderForm'; import { apiUrl } from '../../../utils/env'; +import tryCatch from '../../../utils/tryCatch'; +import AdminPaymentMethods from '../../../components/Checkout/AdminPaymentMethods'; type OrderPageProps = { data: Product; user: User; + zelle: Zelle + pagoMovil: PagoMovil } function OrderPage(props: OrderPageProps, ref: IndexPageRef) { - const { data, user } = props; + const { data, user, zelle, pagoMovil } = props; console.log(user) @@ -30,8 +34,10 @@ function OrderPage(props: OrderPageProps, ref: IndexPageRef) {
  • Pagar Orden
  • Orden Completada
  • -
    - +
    +
    + +
    @@ -79,10 +85,25 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { } } + + const [pagoMovil, pagoMovilError] = await tryCatch>(axios.get(apiUrl + '/api/globals/pago-movil/')) + + if (pagoMovilError) { + console.log(pagoMovilError) + } + + const [zelle, zelleError] = await tryCatch>(axios.get(apiUrl + '/api/globals/zelle/')) + + if (zelleError) { + console.log(zelleError) + } + return { props: { data: response.data, - user: user.data.user + user: user.data.user, + zelle: zelle?.data, + pagoMovil: pagoMovil?.data, }, // will be passed to the page component as props }; } catch (error) { diff --git a/pages/thank-you.tsx b/pages/thank-you.tsx index 4ee67333..7d7e2bb7 100644 --- a/pages/thank-you.tsx +++ b/pages/thank-you.tsx @@ -3,9 +3,13 @@ import Layout from '../components/Layout/Layout'; import { CONTACT_EMAIL } from '../utils/constants'; import { IndexPageRef } from '../utils/types/common'; import { forwardRef } from 'react'; +import { useAuth } from '../components/Auth'; function ThankYouPage(props: any, ref: IndexPageRef) { + + const { user } = useAuth(); + return (
    @@ -25,8 +29,10 @@ function ThankYouPage(props: any, ref: IndexPageRef) {

    diff --git a/payload-types.ts b/payload-types.ts index 9dfcc623..0a657b00 100644 --- a/payload-types.ts +++ b/payload-types.ts @@ -25,7 +25,10 @@ export interface Config { examns: Examn; 'examns-submissions': ExamnsSubmission; }; - globals: {}; + globals: { + 'pago-movil': PagoMovil; + zelle: Zelle; + }; } export interface Course { id: string; @@ -540,3 +543,33 @@ export interface ExamnsSubmission { updatedAt: string; createdAt: string; } +export interface PagoMovil { + id: string; + phone: string; + name: string; + cid: string; + bank?: + | 'banco-de-venezuela' + | 'banco-mercantil' + | 'banco-provincial' + | 'banco-bicentenario' + | 'banco-exterior' + | 'banco-occidental-de-descuento' + | 'banco-sofitasa' + | 'banco-plaza' + | 'banco-caroni' + | 'banco-activo' + | 'banco-del-tesoro' + | 'banco-agricola-de-venezuela' + | 'banco-de-la-fuerza-armada-nacional-bolivariana' + | 'banco-del-pueblo-soberano' + | 'banco-nacional-de-credito' + | 'banco-venezolano-de-credito' + | 'banesco'; +} +export interface Zelle { + id: string; + email: string; + zelleHolder: string; + bank: string; +} diff --git a/yarn.lock b/yarn.lock index 639a5f53..0a93361b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -783,7 +783,7 @@ "ansi-styles" "^4.1.0" "supports-color" "^7.1.0" -"chokidar@^3.5.3", "chokidar@>=3.0.0 <4.0.0": +"chokidar@^3.5.3": "integrity" "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==" "resolved" "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz" "version" "3.5.3" @@ -1743,11 +1743,6 @@ "resolved" "https://registry.npmjs.org/immer/-/immer-9.0.21.tgz" "version" "9.0.21" -"immutable@^4.0.0": - "integrity" "sha512-0AOCmOip+xgJwEVTQj1EfiDDOkPmuyllDuTuEX+DDXUgapLAsBIfkg3sxCYyCEA8mQqZrrxPUGjcOQ2JS3WLkg==" - "resolved" "https://registry.npmjs.org/immutable/-/immutable-4.3.0.tgz" - "version" "4.3.0" - "import-fresh@^3.0.0", "import-fresh@^3.2.1": "integrity" "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==" "resolved" "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz" @@ -2669,15 +2664,6 @@ "get-intrinsic" "^1.1.3" "is-regex" "^1.1.4" -"sass@^1.3.0": - "integrity" "sha512-NHpxIzN29MXvWiuswfc1W3I0N8SXBd8UR26WntmDlRYf0bSADnwnOjsyMZ3lMezSlArD33Vs3YFhp7dWvL770A==" - "resolved" "https://registry.npmjs.org/sass/-/sass-1.62.1.tgz" - "version" "1.62.1" - dependencies: - "chokidar" ">=3.0.0 <4.0.0" - "immutable" "^4.0.0" - "source-map-js" ">=0.6.2 <2.0.0" - "scheduler@^0.23.0": "integrity" "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==" "resolved" "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz" @@ -2737,7 +2723,7 @@ "is-plain-object" "^5.0.0" "tiny-warning" "^1.0.3" -"source-map-js@^1.0.2", "source-map-js@>=0.6.2 <2.0.0": +"source-map-js@^1.0.2": "integrity" "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==" "resolved" "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz" "version" "1.0.2"