diff --git a/backend/.gitignore b/backend/.gitignore index e4986af..4197690 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -1,3 +1,4 @@ target .env aulavirtual +scraps diff --git a/frontend/src/OnlineClassroom/index.tsx b/frontend/src/OnlineClassroom/index.tsx index e06ad66..54827d0 100644 --- a/frontend/src/OnlineClassroom/index.tsx +++ b/frontend/src/OnlineClassroom/index.tsx @@ -5,6 +5,10 @@ import { FilledCard } from "../components/FilledCard"; import { LinkIcon } from "../icons/LinkIcon"; import { ClassroomUserCreation } from "./ClassroomUserCreation"; import { ClassroomRegistrationUser } from "../types/ClassroomRegistrationUser"; +import { SpinnerGapIcon } from "../icons/SpinnerGapIcon"; +import { QuestionIcon } from "../icons/QuestionIcon"; +import { JsonResult } from "../types/JsonResult"; +import { XcircleIcon } from "../icons/XCircleIcon"; type TabType = "Vinculate" | "Create"; @@ -54,19 +58,25 @@ function ClassroomUser(props: {person: Person}) { ); } +type Status = "Init" | "Ok" | "Loading" | "Error"; function ClassroomVinculation(props: {person_surname: string}) { const [classroomUsers, setClassroomUsers] = createSignal([]); + const [error, setError] = createSignal(""); + const [status, setStatus] = createSignal("Init"); const loadUsers = async() => { + setStatus("Loading"); const response = await fetch(`${import.meta.env.VITE_BACKEND_URL}/api/classroom/users/${encodeURIComponent(props.person_surname)}`); - const json = await response.json(); + const json: JsonResult> = await response.json(); if (response.ok) { - setClassroomUsers(json); + setClassroomUsers(json.Ok); + setStatus("Ok"); } else { console.error("Error loading users", json); + setError(json.Err.reason); + setStatus("Error"); } - }; onMount(loadUsers); @@ -76,32 +86,58 @@ function ClassroomVinculation(props: {person_surname: string}) {

Vincule un usuario existente:

- - {(_) => } - + + +
+ +
+
+ + + +
+
+ +
+

No se encontraron usuarios en el aula virtual.

+
+
+ + {(u) => } + +
+ + +
+
+ +
+

Error buscando usuarios: {error()}.

+
+
); } -function ClassroomSingleUser() { +function ClassroomSingleUser(props: {user: ClassroomRegistrationUser}) { return (
- NOMBRE NOMBRE APELLIDO APELLIDO + {props.user.name} {props.user.surname}
- NNAPELLA + {props.user.username}
registrado:  - 26/05/2023 + ??/??/????
diff --git a/frontend/src/icons/QuestionIcon.tsx b/frontend/src/icons/QuestionIcon.tsx new file mode 100644 index 0000000..1a1065f --- /dev/null +++ b/frontend/src/icons/QuestionIcon.tsx @@ -0,0 +1,16 @@ + + +export function QuestionIcon(props: {fill: string, size?: number, class?: string}) { + return ( + + + + ); +} diff --git a/frontend/src/icons/SpinnerGapIcon.tsx b/frontend/src/icons/SpinnerGapIcon.tsx new file mode 100644 index 0000000..ec70b45 --- /dev/null +++ b/frontend/src/icons/SpinnerGapIcon.tsx @@ -0,0 +1,16 @@ + + +export function SpinnerGapIcon(props: {fill: string, size?: number, class?: string}) { + return ( + + + + ); +} diff --git a/frontend/src/icons/XCircleIcon.tsx b/frontend/src/icons/XCircleIcon.tsx new file mode 100644 index 0000000..16b264f --- /dev/null +++ b/frontend/src/icons/XCircleIcon.tsx @@ -0,0 +1,16 @@ + + +export function XcircleIcon(props: {fill: string, size?: number, class?: string}) { + return ( + + + + ); +} diff --git a/frontend/src/types/JsonResult.ts b/frontend/src/types/JsonResult.ts new file mode 100644 index 0000000..553f6c5 --- /dev/null +++ b/frontend/src/types/JsonResult.ts @@ -0,0 +1,6 @@ +export type JsonResult = { + Ok: T, + Err: { + reason: string + } +};