se envía uuid de usuario
Se envia el uuid del usuario para para ponerle dueño a las asignaturas y planes de estudio creadas, y a los documentos de referencia subidos
This commit is contained in:
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "msedge",
|
||||
"request": "launch",
|
||||
"name": "Launch Edge against localhost",
|
||||
"url": "http://localhost:3000",
|
||||
"webRoot": "${workspaceFolder}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -7,13 +7,14 @@ import { Textarea } from "@/components/ui/textarea"
|
||||
import { AuroraButton } from "@/components/effect/aurora-button"
|
||||
import confetti from "canvas-confetti"
|
||||
import { useQueryClient } from "@tanstack/react-query"
|
||||
import { supabase } from "@/auth/supabase"
|
||||
import { supabase, useSupabaseAuth } from "@/auth/supabase"
|
||||
import { Field } from "./Field"
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs"
|
||||
import { asignaturaKeys } from "./planQueries"
|
||||
|
||||
export function AddAsignaturaButton({ planId, onAdded }: { planId: string; onAdded?: () => void }) {
|
||||
const qc = useQueryClient()
|
||||
const supabaseAuth = useSupabaseAuth()
|
||||
const [open, setOpen] = useState(false)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [mode, setMode] = useState<"manual" | "ia">("manual")
|
||||
@@ -56,11 +57,13 @@ export function AddAsignaturaButton({ planId, onAdded }: { planId: string; onAdd
|
||||
async function createWithAI() {
|
||||
if (!canIA) return
|
||||
setSaving(true)
|
||||
// inserte la asignatura generada directamente
|
||||
// obtengas el uuid que se insertó
|
||||
try {
|
||||
const res = await fetch(`${import.meta.env.VITE_BACK_ORIGIN}/api/generar/asignatura`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ planEstudiosId: planId, prompt: iaPrompt, semestre: iaSemestre.trim() ? Number(iaSemestre) : undefined, insert: true }),
|
||||
body: JSON.stringify({ planEstudiosId: planId, prompt: iaPrompt, semestre: iaSemestre.trim() ? Number(iaSemestre) : undefined, insert: true, uuid: supabaseAuth.user?.id }),
|
||||
})
|
||||
if (!res.ok) throw new Error(await res.text())
|
||||
confetti({ particleCount: 120, spread: 80, origin: { y: 0.6 } })
|
||||
|
||||
@@ -165,6 +165,7 @@ export function CreatePlanDialog({ open, onOpenChange }: { open: boolean; onOpen
|
||||
prompt,
|
||||
insert: true,
|
||||
files: selectedFiles,
|
||||
uuid: auth.user?.id,
|
||||
})
|
||||
const newId = (res as any)?.id || (res as any)?.plan?.id || (res as any)?.data?.id
|
||||
if (newId) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// routes/_authenticated/archivos.tsx
|
||||
import { createFileRoute, useRouter } from "@tanstack/react-router"
|
||||
import { useMemo, useState } from "react"
|
||||
import { supabase } from "@/auth/supabase"
|
||||
import { use, useMemo, useState } from "react"
|
||||
import { supabase, useSupabaseAuth } from "@/auth/supabase"
|
||||
import * as Icons from "lucide-react"
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { Input } from "@/components/ui/input"
|
||||
@@ -16,6 +16,7 @@ import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from "@
|
||||
import { DetailDialog } from "@/components/archivos/DetailDialog"
|
||||
|
||||
import type { RefRow } from "@/types/RefRow"
|
||||
import { uuid } from "zod"
|
||||
|
||||
export const Route = createFileRoute("/_authenticated/archivos")({
|
||||
component: RouteComponent,
|
||||
@@ -192,6 +193,7 @@ function RouteComponent() {
|
||||
function UploadDialog({
|
||||
open, onOpenChange, onDone,
|
||||
}: { open: boolean; onOpenChange: (o: boolean) => void; onDone: () => void }) {
|
||||
const supabaseAuth = useSupabaseAuth()
|
||||
const [file, setFile] = useState<File | null>(null)
|
||||
const [instrucciones, setInstrucciones] = useState("")
|
||||
const [tags, setTags] = useState("")
|
||||
@@ -222,6 +224,7 @@ function UploadDialog({
|
||||
prompt: instrucciones,
|
||||
fileBase64,
|
||||
insert: true,
|
||||
uuid: supabaseAuth.user?.id ?? null,
|
||||
}),
|
||||
})
|
||||
if (!res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user