- {datePicker}
-
+
void}) {
});
} else {
setQrBase64(null);
+ setPerson(null);
}
});
@@ -44,8 +45,9 @@ export function Search(props: {setPerson: (p: Person | null) => void}) {
setError("");
try {
- const response = await fetch(`/api/person/${dni()}`);
+ const response = await fetch(`${import.meta.env.VITE_BACKEND_URL}/api/person/${dni()}`);
const body = await response.json();
+
if (response.ok) {
setPerson(body);
props.setPerson(body);
diff --git a/frontend/src/components/Chip.tsx b/frontend/src/components/Chip.tsx
new file mode 100644
index 0000000..3aa48d5
--- /dev/null
+++ b/frontend/src/components/Chip.tsx
@@ -0,0 +1,9 @@
+export function Chip(props: {text: string}) {
+ return (
+
+ {props.text}
+
+ );
+}
diff --git a/frontend/src/types/Course.ts b/frontend/src/types/Course.ts
new file mode 100644
index 0000000..f209d09
--- /dev/null
+++ b/frontend/src/types/Course.ts
@@ -0,0 +1,8 @@
+export type Course = {
+ course_id: number,
+ course_code: number,
+ course_name: string,
+ course_display_name: string,
+ course_days_amount: number,
+ course_has_custom_label: boolean,
+}
diff --git a/frontend/src/types/Person.tsx b/frontend/src/types/Person.ts
similarity index 100%
rename from frontend/src/types/Person.tsx
rename to frontend/src/types/Person.ts
diff --git a/frontend/src/utils/allCourses.ts b/frontend/src/utils/allCourses.ts
new file mode 100644
index 0000000..6d4ab41
--- /dev/null
+++ b/frontend/src/utils/allCourses.ts
@@ -0,0 +1,12 @@
+import { createSignal } from "solid-js";
+import { Course } from "../types/Course";
+
+export const [allCourses, setAllCourses] = createSignal
>([]);
+
+(() => {
+ // Get all courses from the API
+ fetch(`${import.meta.env.VITE_BACKEND_URL}/api/course`)
+ .then((res) => res.json())
+ .then((data) => setAllCourses(data));
+})();
+