Skip to content

Commit

Permalink
fix anonymized results
Browse files Browse the repository at this point in the history
  • Loading branch information
JefQuidousse2 committed Oct 11, 2024
1 parent 63b44bb commit 6fa28c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/app/result/[role]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { generateRolesWithHref } from "~/utils/role-utils";
import { getServerAuthSession } from "~/server/auth";
import { Login } from "~/components/login";
import ShowTechSearchWrapper from "~/components/ui/search-expert";
import { SelectRoleResults } from "~/components/select-role-results";

export const metadata: Metadata = {
title: "Results",
Expand Down Expand Up @@ -64,6 +65,11 @@ export const ShowRolesWrapper = async ({ path }: { path: string }) => {
currentCompleted: false
};
availableRoles.unshift(def as Section);
if (path.includes("result")) {
return (
<SelectRoleResults roles={availableRoles} />
)
}
return (
<ShowTechSearchWrapper roles={availableRoles} />
);
Expand Down
10 changes: 9 additions & 1 deletion src/utils/role-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Role, Section } from "~/models/types";
import { db } from "~/server/db";
import { slugify } from "./slugify";

export function generateRolesWithHref(
resultHref: string,
Expand All @@ -19,7 +20,7 @@ export function generateRolesWithHref(
})
.map((role) => ({
id: role.id,
href: `${resultHref}?role=${role.role}`,
href: createHref(resultHref, role),
label: role.role,
current: false,
completed: false,
Expand All @@ -30,3 +31,10 @@ export function generateRolesWithHref(
return availableRoles;
};
}

const createHref = (path: string, role: Role) => {
if (path.includes("result")) {
return `${path}/${slugify(role.role)}`;
}
return `${path}?role=${role.role}`;
}

0 comments on commit 6fa28c7

Please sign in to comment.