diff --git a/src/pages/hackers/hacker.tsx b/src/pages/hackers/hacker.tsx
index 0009f983..50bd8ea1 100644
--- a/src/pages/hackers/hacker.tsx
+++ b/src/pages/hackers/hacker.tsx
@@ -27,6 +27,9 @@ const Hacker: NextPage = () => {
const hackerQuery = trpc.hackers.get.useQuery({ id: id ?? "" }, { enabled: !!id });
const presenceQuery = trpc.presence.getFromHackerId.useQuery({ id: id ?? "" }, { enabled: !!id });
+
+ const nextHackerQuery = trpc.hackers.getNext.useQuery({ id: id ?? "" }, { enabled: !!id });
+ const prevHackerQuery = trpc.hackers.getPrev.useQuery({ id: id ?? "" }, { enabled: !!id });
if (hackerQuery.isLoading || hackerQuery.data == null) {
return (
@@ -82,6 +85,24 @@ const Hacker: NextPage = () => {
>
role === Role.ORGANIZER || role === Role.SPONSOR}>
+
+ {prevHackerQuery.data ? (
+ Previous
+
+ ) : (
+
+ )}
+ {nextHackerQuery.data && (
+ Next
+
+ )}
+
role === Role.HACKER}>{t("not-authorized-to-view-this-page")}
diff --git a/src/server/api/routers/hackers.ts b/src/server/api/routers/hackers.ts
index 6f0ed750..7c20d096 100644
--- a/src/server/api/routers/hackers.ts
+++ b/src/server/api/routers/hackers.ts
@@ -42,6 +42,60 @@ export const hackerRouter = createTRPCRouter({
return hacker;
}),
+
+ // Get next hacker in db from an id
+ getNext: publicProcedure
+ .input(
+ z
+ .object({
+ id: z.string(),
+ }),
+ )
+ .query(async ({ ctx, input }) => {
+ let hacker: HackerInfo | null = null;
+ if ("id" in input) {
+ hacker = await ctx.prisma.hackerInfo.findFirst({
+ take: 1,
+ skip: 1,
+ cursor: {
+ id: input.id,
+ },
+ });
+ }
+
+ if (!hacker) {
+ throw new Error("Hacker not found");
+ }
+
+ return hacker;
+ }),
+
+ // Get prev hacker in db from an id
+ getPrev: publicProcedure
+ .input(
+ z
+ .object({
+ id: z.string(),
+ }),
+ )
+ .query(async ({ ctx, input }) => {
+ let hacker: HackerInfo | null = null;
+ if ("id" in input) {
+ hacker = await ctx.prisma.hackerInfo.findFirst({
+ take: -1,
+ skip: 1,
+ cursor: {
+ id: input.id,
+ },
+ });
+ }
+
+ if (!hacker) {
+ throw new Error("Hacker not found");
+ }
+
+ return hacker;
+ }),
// Get all hackers
all: protectedProcedure