add registration whit pago

This commit is contained in:
2026-01-23 13:46:46 -06:00
parent 78eee4cc64
commit fb68ddc636
+16 -22
View File
@@ -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));