From fb68ddc6360645fe5eca671b5f9c4886c69fbfe3 Mon Sep 17 00:00:00 2001 From: IO420 <320154041@pcpuma.acatlan.unam.mx> Date: Fri, 23 Jan 2026 13:46:46 -0600 Subject: [PATCH] add registration whit pago --- app/Components/Receipt/Inscripcion.tsx | 38 +++++++++++--------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/app/Components/Receipt/Inscripcion.tsx b/app/Components/Receipt/Inscripcion.tsx index 2e6784c..995f5c8 100644 --- a/app/Components/Receipt/Inscripcion.tsx +++ b/app/Components/Receipt/Inscripcion.tsx @@ -2,12 +2,14 @@ import toast from "react-hot-toast"; import { useState } from "react"; -import { PostReceipt } from "@/app/lib/postReceipt"; import { useRouter } from "next/navigation"; -import "./Receipt.css"; import Selection from "../Selection/Selection"; import { envConfig } from "@/app/lib/config"; +import Cookies from "js-cookie"; +import axios from "axios"; + +import "./Receipt.css"; interface ReceiptsProps { numAcount: number | null; @@ -75,28 +77,21 @@ export default function Inscripcion({ const id_plataforma = PLATAFORMA_MAP[plataformaSeleccionada]; try { - await PostReceipt({ - id_cuenta: numAcount, - folio_recibo: folio, - monto: Number(amount), - fecha_recibo: date, - }); + const token = Cookies.get("token"); + const headers = { Authorization: `Bearer ${token}` }; - const res = await fetch(`${envConfig.apiUrl}/alumno-inscrito`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ + await axios.post( + `${envConfig.apiUrl}/operations/registration`, + { + monto: Number(amount), id_cuenta: numAcount, id_plataforma, - realizo_pago: false, - }), - }); - - const data = await res.json(); - - if (!res.ok) { - throw new Error(data.message || "Error al inscribir"); - } + folio_recibo: folio, + fecha_recibo: date, + realizo_pago: true, + }, + { headers }, + ); toast.success("Alumno con pago"); @@ -104,7 +99,6 @@ export default function Inscripcion({ setAmount(""); setDate(""); - toast.success("Recibo guardado"); router.refresh(); } catch (err: any) { toast.error(String(err));