commit wip
This commit is contained in:
@@ -43,7 +43,7 @@ export function AddAsignaturaButton({ planId, onAdded }: { planId: string; onAdd
|
||||
horas_teoricas: toNum(f.horas_teoricas),
|
||||
horas_practicas: toNum(f.horas_practicas),
|
||||
objetivos: toNull(f.objetivos),
|
||||
contenidos: {}, bibliografia: [], criterios_evaluacion: null,
|
||||
contenidos: [], bibliografia: [], criterios_evaluacion: null,
|
||||
}
|
||||
const { error } = await supabase.from("asignaturas").insert([payload])
|
||||
setSaving(false)
|
||||
|
||||
@@ -28,10 +28,10 @@ export function DeletePlanButton({ planId, onDeleted }: { planId: string; onDele
|
||||
|
||||
return confirm ? (
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" onClick={() => setConfirm(false)} disabled={loading}>Cancelar</Button>
|
||||
<Button variant="destructive" onClick={handleDelete} disabled={loading}>
|
||||
{loading ? "Eliminando…" : "Confirmar eliminación"}
|
||||
</Button>
|
||||
<Button variant="outline" onClick={() => setConfirm(false)} disabled={loading}>Cancelar</Button>
|
||||
</div>
|
||||
) : (
|
||||
<Button variant="outline" onClick={() => setConfirm(true)}>
|
||||
|
||||
33
src/components/planes/GenerarPdfButton.tsx
Normal file
33
src/components/planes/GenerarPdfButton.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Download } from "lucide-react";
|
||||
import { Button } from "../ui/button";
|
||||
|
||||
export function DescargarPdfButton({planId, opcion}: {planId: string, opcion: "plan" | "asignaturas"}) {
|
||||
return (
|
||||
<Button variant="outline" className="flex items-center gap-2 " onClick={() => descargarPdf(planId, opcion)}>
|
||||
Descargar {opcion === "plan" ? "Plan" : "Asignaturas"} PDF
|
||||
<Download className="w-4 h-4" />
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
function descargarPdf(planId: string, opcion: "plan" | "asignaturas") {
|
||||
// Lógica para generar y descargar el PDF del plan de estudios
|
||||
try {
|
||||
// Usa la variable de entorno para construir la URL completa
|
||||
const pdfUrl = opcion === "plan"
|
||||
? `${import.meta.env.VITE_BACK_ORIGIN}/api/planes/${planId}/descargar-pdf-plan`
|
||||
: `${import.meta.env.VITE_BACK_ORIGIN}/api/planes/${planId}/descargar-pdf-asignaturas`;
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.href = pdfUrl;
|
||||
link.download = opcion === "plan"
|
||||
? `plan_estudios_${planId}.pdf`
|
||||
: `asignaturas_plan_estudios_${planId}.pdf`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
} catch (error) {
|
||||
console.error("Error al descargar el PDF:", error);
|
||||
alert("Hubo un error al descargar el PDF. Por favor, inténtalo de nuevo.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user