From 9527294a19aeb146d1921b1bd25ac5239389cd79 Mon Sep 17 00:00:00 2001 From: jose andre alcivar Date: Thu, 14 Mar 2024 08:00:16 -0500 Subject: [PATCH] redirigir pagina makarios --- pages/api/auth/[...nextauth].js | 11 +++++----- pages/registrarTorneo/index.js | 39 +++++++++------------------------ 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index a25846d..17cf05a 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -25,14 +25,13 @@ const authOptions = { const matchPassword = await bcrypt.compare(credentials.password, userFound.password); if (!matchPassword) throw new Error('Wrong password'); - - return { + const user = { id: userFound.id, - firstname: userFound.firstname, - lastname: userFound.lastname, + name: userFound.firstname, email: userFound.email, - role:userFound.role - } + } + + return user; } }) ], diff --git a/pages/registrarTorneo/index.js b/pages/registrarTorneo/index.js index 1147f3c..3f16335 100644 --- a/pages/registrarTorneo/index.js +++ b/pages/registrarTorneo/index.js @@ -23,7 +23,7 @@ import Swal from "sweetalert2"; import PageLayout from "/examples/LayoutContainers/PageLayout"; import { MakariosProvider } from "/contextMakarios"; - +import { signOut } from "next-auth/react"; // @mui material components import Grid from "@mui/material/Grid"; import Card from "@mui/material/Card"; @@ -111,19 +111,14 @@ function NewUser() { PayboxCobroPrueba: false, onAuthorize: async (response) => { if (response.status === "succeeded") { - console.log(response); - await setPagado(true); await setResponsePagoPlux(response); - console.log("pagado:", pagado); - console.log("dentro de data, despues de success"); } }, }; const [dataPagoCita, setDataPagoCita] = useState(dataPagos); - const submitForm = (values, actions) => { sleep(1500).then(async () => { await handleResetForm(actions); @@ -132,21 +127,20 @@ function NewUser() { const handleResetForm = async (actions) => { setActiveStep(0); - await actions.resetForm(); - await window.location.reload(); + if (pagado) { + await signOut(); + window.location.href = "https://makarios.club/"; + } else { + await actions.resetForm(); + await window.location.reload(); + } }; const onPayPagoPluxCreate = async (data) => { try { - console.log("data"); - const response = await axios.post("/api/pagoplux/", data); - // console.log(" antes del response"); - console.log("response event PagoPlux"); - console.log(response); if (response.statusText === "OK" || response.status === 200) { - // setPagoplux(response.data.id); await Swal.fire({ icon: "success", title: "Pago exitoso!", @@ -172,23 +166,13 @@ function NewUser() { const onSubmitCreate = async (data) => { try { - console.log("data on submit Create"); - console.log(data); - console.log(pagado); if (pagado) { // procede a guardar la informacion de pagoplux response const responseCard = await onPayPagoPluxCreate(responsePagoPlux.detail); - console.log("responseCard"); - console.log(responseCard); - data.pagoplux = responseCard; + data.pagoplux = responseCard; const response = await axios.post("/api/torneo/", data); - // console.log(" antes del response"); - console.log("response event Torneo"); - console.log(response); if (response.statusText === "OK" || response.status === 200) { - console.log("response"); - console.log("guardado el registro OK"); await Swal.fire({ icon: "success", title: "Registro exitoso!", @@ -242,15 +226,13 @@ function NewUser() { const handleNextStep = async (values, actions) => { const session = await getSession(values); - // setPagado(false); + setPrecio(values.precio); setEmailUser(session.user.email); setActiveStep(activeStep + 1); actions.setTouched({}); actions.setSubmitting(false); - console.log("activeStep"); - console.log(activeStep); }; const handleFinalStep = async (values, actions) => { @@ -271,7 +253,6 @@ function NewUser() { } }, [responsePagoPlux]); - return ( // //