From 9db5bc326c7c55ed7c18f99676bfc93a6f898bea Mon Sep 17 00:00:00 2001 From: Gobot1234 Date: Thu, 18 Apr 2024 17:26:46 +0100 Subject: [PATCH 1/4] feat: unspecified_error rather than undefined --- apps/forge/src/lib/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/forge/src/lib/utils.ts b/apps/forge/src/lib/utils.ts index aca1c7c..cb11068 100644 --- a/apps/forge/src/lib/utils.ts +++ b/apps/forge/src/lib/utils.ts @@ -41,7 +41,7 @@ export function extractError(error: Error): string { return undefined as never; } if (isAxiosError(error)) { - return `${ErrorCodes[error.response?.data.code]}: ${error.response?.data.message}`; + return `${ErrorCodes[error.response?.data.code] || "unspecified_error"}: ${error.response?.data.message}`; } return error?.message || "Unknown Error. Contact the IT Team"; } From e39b2737a738b6cb63ab5e4c9d9a4d57e0d86936 Mon Sep 17 00:00:00 2001 From: Gobot1234 Date: Fri, 19 Apr 2024 03:32:53 +0100 Subject: [PATCH 2/4] fix: sort the list of trainings on the training site --- .../components/training/TrainingLocation.tsx | 17 +++++++++++------ .../_authenticated/_reponly/users/$id.tsx | 3 +-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/forge/src/components/training/TrainingLocation.tsx b/apps/forge/src/components/training/TrainingLocation.tsx index c7a556f..a4cee4c 100644 --- a/apps/forge/src/components/training/TrainingLocation.tsx +++ b/apps/forge/src/components/training/TrainingLocation.tsx @@ -57,6 +57,7 @@ export default function TrainingLocation({ location, img, optionalTrainingText } }, { compulsory: [] as PartialTrainingWithStatus[], not_compulsory: [] as PartialTrainingWithStatus[] }, ); + return ( <> @@ -83,9 +84,11 @@ export default function TrainingLocation({ location, img, optionalTrainingText } </div> </div> <div className="grid gap-4 align-middle w-full grid-cols-1 items-stretch justify-center md:grid-cols-2 lg:grid-cols-3"> - {compulsory.map((training) => ( - <TrainingCourseCard training={training} isRep={isRep} /> - ))} + {compulsory + .sort((a, b) => a.name.localeCompare(b.name)) + .map((training) => ( + <TrainingCourseCard training={training} isRep={isRep} /> + ))} </div> </div> </div> @@ -103,9 +106,11 @@ export default function TrainingLocation({ location, img, optionalTrainingText } </div> </div> <div className="grid gap-4 align-middle w-full grid-cols-1 items-stretch justify-center md:grid-cols-2 lg:grid-cols-3"> - {not_compulsory.map((training) => ( - <TrainingCourseCard training={training} isRep={isRep} /> - ))} + {not_compulsory + .sort((a, b) => a.name.localeCompare(b.name)) + .map((training) => ( + <TrainingCourseCard training={training} isRep={isRep} /> + ))} </div> </div> </div> diff --git a/apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx b/apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx index 60a4fd3..33ed6a7 100644 --- a/apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx +++ b/apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx @@ -110,9 +110,8 @@ export default function Component() { </TableRow> </TableHeader> <TableBody> - {/* sorting stably is for losers */} {trainings - .sort((a, b) => (a.name < b.name ? -1 : 1)) + .sort((a, b) => a.name.localeCompare(b.name)) .map((training) => training["@created_at"] ? ( <TableRow> From 79b1df484994d72d4140a7bc036bdc11032ba250 Mon Sep 17 00:00:00 2001 From: Gobot1234 <gobot1234yt@gmail.com> Date: Fri, 19 Apr 2024 03:33:11 +0100 Subject: [PATCH 3/4] feat: concurrently request data for user profiles --- apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx b/apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx index 33ed6a7..d85444d 100644 --- a/apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx +++ b/apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx @@ -15,9 +15,7 @@ import { isAxiosError } from "axios"; import { Check, Loader, X } from "lucide-react"; async function getData(id: string) { - const user = await getUser(id); - const trainings = await getUserTraining(id); - const signIns = await getUserSignIns(id); + const [user, trainings, signIns] = await Promise.all([getUser(id), getUserTraining(id), getUserSignIns(id)]); return { user, trainings, From 367ccc201229e8123725fe6e41a7b9cdf42d0c78 Mon Sep 17 00:00:00 2001 From: Gobot1234 <gobot1234yt@gmail.com> Date: Fri, 19 Apr 2024 03:33:54 +0100 Subject: [PATCH 4/4] fix: swap out bad loader for good one --- apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx b/apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx index d85444d..7abab73 100644 --- a/apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx +++ b/apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx @@ -10,9 +10,10 @@ import { Training } from "@ignis/types/users.ts"; import { useQuery } from "@tanstack/react-query"; import { createFileRoute, notFound } from "@tanstack/react-router"; import { Badge } from "@ui/components/ui/badge.tsx"; +import { Loader } from "@ui/components/ui/loader"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@ui/components/ui/table.tsx"; import { isAxiosError } from "axios"; -import { Check, Loader, X } from "lucide-react"; +import { Check, X } from "lucide-react"; async function getData(id: string) { const [user, trainings, signIns] = await Promise.all([getUser(id), getUserTraining(id), getUserSignIns(id)]);