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

@@ -1,7 +1,7 @@
// api.ts // api.ts
const API_BASE = const API_BASE =
(import.meta.env.VITE_API_BASE?.replace(/\/$/, "")) || (import.meta.env.VITE_API_BASE?.replace(/\/$/, "")) ||
"http://localhost:3001"; // 👈 tu Bun.serve real "https://genesis-engine.apps.lci.ulsa.mx"; // 👈 tu Bun.serve real
export async function postAPI<T=any>(path: string, body: any): Promise<T> { export async function postAPI<T=any>(path: string, body: any): Promise<T> {
const url = `${API_BASE}${path}`; const url = `${API_BASE}${path}`;

View File

@@ -13,7 +13,7 @@ import {
DropdownMenuSeparator, DropdownMenuSeparator,
DropdownMenuTrigger, DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu" } from "@/components/ui/dropdown-menu"
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet" import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"
import { ModeToggle } from "@/components/mode-toggle" import { ModeToggle } from "@/components/mode-toggle"
import { import {
Menu, Menu,
@@ -94,17 +94,17 @@ function Layout() {
</Button> </Button>
</SheetTrigger> </SheetTrigger>
<SheetContent side="left" className="p-0"> <SheetContent side="left" className="p-0">
<Sidebar onNavigate={() => { }} /> <SheetHeader>
<SheetTitle>Menú de Navegación</SheetTitle>
</SheetHeader> <Sidebar onNavigate={() => { }} />
</SheetContent> </SheetContent>
</Sheet> </Sheet>
{/* Brand */} {/* Brand */}
<Link to={user.isAdmin ? "/dashboard" : "/planes"} className="hidden items-center gap-2 md:flex"> <Link to={user.isAdmin ? "/dashboard" : "/planes"} className="hidden items-center gap-2 md:flex">
<span className="inline-flex h-8 w-8 items-center justify-center rounded-xl bg-primary/10 text-primary font-bold">U</span> <span className="inline-flex h-8 w-25 items-center justify-center rounded-xl bg-primary/10 text-primary font-bold">
<div className="flex flex-col leading-tight"> <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS8C2SvZe281wTNc9werkudO9aJiX3dOZm9T3s5DAfS0OUOvDbgc_WC61U_esY8GE8bZoI&usqp=CAU" alt="" />
<span className="font-semibold tracking-tight">La Salle · Ingeniería</span> </span>
<span className="text-[10px] text-muted-foreground font-mono uppercase tracking-wider">Génesis</span>
</div>
</Link> </Link>
{/* Search */} {/* Search */}
@@ -154,13 +154,7 @@ function Sidebar({ onNavigate }: { onNavigate?: () => void }) {
return ( return (
<div className="h-full"> <div className="h-full">
<div className="flex items-center gap-2 p-4 md:hidden">
<span className="inline-flex h-8 w-8 items-center justify-center rounded-xl bg-primary/10 text-primary font-bold">U</span>
<div className="leading-tight">
<span className="font-semibold">La Salle · Ingeniería</span>
<div className="text-[10px] text-muted-foreground font-mono uppercase tracking-wider">Génesis</div>
</div>
</div>
<Separator /> <Separator />
<ScrollArea className="h-[calc(100%-4rem)] p-2"> <ScrollArea className="h-[calc(100%-4rem)] p-2">
<nav className="grid gap-1 p-2"> <nav className="grid gap-1 p-2">
@@ -181,6 +175,7 @@ function Sidebar({ onNavigate }: { onNavigate?: () => void }) {
{canSeeCarreras && ( {canSeeCarreras && (
<Link <Link
to="/carreras" to="/carreras"
key='/carreras'
activeOptions={{ exact: true }} activeOptions={{ exact: true }}
activeProps={{ className: "bg-primary/10 text-foreground" }} activeProps={{ className: "bg-primary/10 text-foreground" }}
className="group inline-flex items-center gap-3 rounded-xl px-3 py-2 text-sm text-muted-foreground hover:bg-primary/10 hover:text-foreground" className="group inline-flex items-center gap-3 rounded-xl px-3 py-2 text-sm text-muted-foreground hover:bg-primary/10 hover:text-foreground"
@@ -193,6 +188,7 @@ function Sidebar({ onNavigate }: { onNavigate?: () => void }) {
{isAdmin && ( {isAdmin && (
<Link <Link
to="/facultades" to="/facultades"
key='facultades'
activeOptions={{ exact: true }} activeOptions={{ exact: true }}
activeProps={{ className: "bg-primary/10 text-foreground" }} activeProps={{ className: "bg-primary/10 text-foreground" }}
className="group inline-flex items-center gap-3 rounded-xl px-3 py-2 text-sm text-muted-foreground hover:bg-primary/10 hover:text-foreground" className="group inline-flex items-center gap-3 rounded-xl px-3 py-2 text-sm text-muted-foreground hover:bg-primary/10 hover:text-foreground"

View File

@@ -284,7 +284,7 @@ function UploadDialog({
try { try {
const fileBase64 = await toBase64(file) const fileBase64 = await toBase64(file)
// Enviamos al motor (inserta en la tabla si insert=true) // 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", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ body: JSON.stringify({

View File

@@ -497,7 +497,7 @@ function MejorarAIButton({ asignaturaId, onApply }: {
async function apply() { async function apply() {
setLoading(true) setLoading(true)
try { 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", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ asignatura_id: asignaturaId, prompt, insert }), body: JSON.stringify({ asignatura_id: asignaturaId, prompt, insert }),

View File

@@ -510,7 +510,7 @@ function AddAsignaturaButton({
if (!canIA) return if (!canIA) return
setSaving(true) setSaving(true)
try { 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", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ body: JSON.stringify({