Skip to content

Commit

Permalink
Merge pull request #36 from israel2x/josedev
Browse files Browse the repository at this point in the history
redirigir pagina makarios
  • Loading branch information
josealcivar authored Mar 14, 2024
2 parents 4a03e53 + 9527294 commit 87bda4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 35 deletions.
11 changes: 5 additions & 6 deletions pages/api/auth/[...nextauth].js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
})
],
Expand Down
39 changes: 10 additions & 29 deletions pages/registrarTorneo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand All @@ -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!",
Expand All @@ -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!",
Expand Down Expand Up @@ -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) => {
Expand All @@ -271,7 +253,6 @@ function NewUser() {
}
}, [responsePagoPlux]);


return (
// <DashboardLayout>
// <MakariosProvider>
Expand Down

0 comments on commit 87bda4a

Please sign in to comment.