feat: update API endpoints to use production URL and enhance UI components in authenticated routes

This commit is contained in:
2025-08-25 15:07:09 -06:00
parent 012a5a58b0
commit 602c5dbb31
5 changed files with 27 additions and 31 deletions

View File

@@ -284,7 +284,7 @@ function UploadDialog({
try {
const fileBase64 = await toBase64(file)
// Enviamos al motor (inserta en la tabla si insert=true)
const res = await fetch("http://localhost:3001/api/upload/documento", {
const res = await fetch("https://genesis-engine.apps.lci.ulsa.mx/api/upload/documento", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({

View File

@@ -497,7 +497,7 @@ function MejorarAIButton({ asignaturaId, onApply }: {
async function apply() {
setLoading(true)
try {
const res = await fetch("http://localhost:3001/api/mejorar/asignatura", {
const res = await fetch("https://genesis-engine.apps.lci.ulsa.mx/api/mejorar/asignatura", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ asignatura_id: asignaturaId, prompt, insert }),

View File

@@ -479,10 +479,10 @@ function AddAsignaturaButton({
const [iaSemestre, setIaSemestre] = useState("")
const toNull = (s: string) => s.trim() ? s : null
const toNum = (s: string) => s.trim() ? Number(s) || null : null
const toNum = (s: string) => s.trim() ? Number(s) || null : null
const canManual = f.nombre.trim().length > 0
const canIA = iaPrompt.trim().length > 0
const canIA = iaPrompt.trim().length > 0
const canSubmit = mode === "manual" ? canManual : canIA
async function createManual() {
@@ -510,7 +510,7 @@ function AddAsignaturaButton({
if (!canIA) return
setSaving(true)
try {
const res = await fetch("http://localhost:3001/api/generar/asignatura", {
const res = await fetch("https://genesis-engine.apps.lci.ulsa.mx/api/generar/asignatura", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
@@ -522,7 +522,7 @@ function AddAsignaturaButton({
})
if (!res.ok) throw new Error(await res.text())
setOpen(false); onAdded?.()
} catch (e:any) {
} catch (e: any) {
alert(e?.message ?? "Error al generar la asignatura")
} finally {
setSaving(false)
@@ -568,29 +568,29 @@ function AddAsignaturaButton({
<TabsContent value="manual" className="mt-4">
<div className="grid gap-3 sm:grid-cols-2">
<Field label="Nombre">
<Input value={f.nombre} onChange={e=>setF(s=>({...s, nombre:e.target.value}))} />
<Input value={f.nombre} onChange={e => setF(s => ({ ...s, nombre: e.target.value }))} />
</Field>
<Field label="Clave">
<Input value={f.clave} onChange={e=>setF(s=>({...s, clave:e.target.value}))} />
<Input value={f.clave} onChange={e => setF(s => ({ ...s, clave: e.target.value }))} />
</Field>
<Field label="Tipo">
<Input value={f.tipo} onChange={e=>setF(s=>({...s, tipo:e.target.value}))} placeholder="Obligatoria / Optativa / Taller…" />
<Input value={f.tipo} onChange={e => setF(s => ({ ...s, tipo: e.target.value }))} placeholder="Obligatoria / Optativa / Taller…" />
</Field>
<Field label="Semestre">
<Input value={f.semestre} onChange={e=>setF(s=>({...s, semestre:e.target.value}))} placeholder="110" />
<Input value={f.semestre} onChange={e => setF(s => ({ ...s, semestre: e.target.value }))} placeholder="110" />
</Field>
<Field label="Créditos">
<Input value={f.creditos} onChange={e=>setF(s=>({...s, creditos:e.target.value}))} />
<Input value={f.creditos} onChange={e => setF(s => ({ ...s, creditos: e.target.value }))} />
</Field>
<Field label="Horas teóricas">
<Input value={f.horas_teoricas} onChange={e=>setF(s=>({...s, horas_teoricas:e.target.value}))} />
<Input value={f.horas_teoricas} onChange={e => setF(s => ({ ...s, horas_teoricas: e.target.value }))} />
</Field>
<Field label="Horas prácticas">
<Input value={f.horas_practicas} onChange={e=>setF(s=>({...s, horas_practicas:e.target.value}))} />
<Input value={f.horas_practicas} onChange={e => setF(s => ({ ...s, horas_practicas: e.target.value }))} />
</Field>
<div className="sm:col-span-2">
<Field label="Objetivo (opcional)">
<Textarea value={f.objetivos} onChange={e=>setF(s=>({...s, objetivos:e.target.value}))} className="min-h-[90px]" />
<Textarea value={f.objetivos} onChange={e => setF(s => ({ ...s, objetivos: e.target.value }))} className="min-h-[90px]" />
</Field>
</div>
</div>
@@ -603,14 +603,14 @@ function AddAsignaturaButton({
<Field label="Indica el enfoque / requisitos">
<Textarea
value={iaPrompt}
onChange={e=>setIaPrompt(e.target.value)}
onChange={e => setIaPrompt(e.target.value)}
className="min-h-[120px]"
placeholder="Ej.: Diseña una materia de Programación Web con proyectos, evaluación por rúbricas y bibliografía actual…"
/>
</Field>
</div>
<Field label="Periodo (opcional)">
<Input value={iaSemestre} onChange={e=>setIaSemestre(e.target.value)} placeholder="110" />
<Input value={iaSemestre} onChange={e => setIaSemestre(e.target.value)} placeholder="110" />
</Field>
</div>
</TabsContent>