Skip to content

Commit

Permalink
Merge branch 'main' of github.com:iforge-uos/ignis
Browse files Browse the repository at this point in the history
  • Loading branch information
Sampiiiii committed Apr 19, 2024
2 parents 26cb594 + 367ccc2 commit 66f13b1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
17 changes: 11 additions & 6 deletions apps/forge/src/components/training/TrainingLocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default function TrainingLocation({ location, img, optionalTrainingText }
},
{ compulsory: [] as PartialTrainingWithStatus[], not_compulsory: [] as PartialTrainingWithStatus[] },
);

return (
<>
<Title prompt={`${name} Training`} />
Expand All @@ -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>
Expand All @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion apps/forge/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
10 changes: 4 additions & 6 deletions apps/forge/src/routes/_authenticated/_reponly/users/$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ 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 = 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,
Expand Down Expand Up @@ -110,9 +109,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>
Expand Down

0 comments on commit 66f13b1

Please sign in to comment.