Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Return user-facing name for queue types in page prop
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 5d90d0b commit 1f7335f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pages/mod-queue.page.server.tsx
Expand Up @@ -14,6 +14,13 @@ export async function onBeforeRender(pageContext: PageContext) {
gma: [1 << 5],
report: [1 << 5],
};

const typeNames: { [k: string]: string } = {
appeal: "Discord Appeals",
gma: "Game Appeals",
report: "Game Reports",
};

const { searchParams } = new URL(
pageContext.urlOriginal,
"http://localhost:8788"
Expand All @@ -22,13 +29,14 @@ export async function onBeforeRender(pageContext: PageContext) {
const allowedTypes = [];

for (const [type, ints] of Object.entries(typePermissions)) {
if (ints.find((i) => currentUser.permissions & i)) allowedTypes.push(type);
if (ints.find((i) => currentUser.permissions & i))
allowedTypes.push({ name: typeNames[type], value: type });
}

if (!allowedTypes.length)
return {
pageContext: {
allowedTypes,
entry_types: [],
},
status: 403,
};
Expand All @@ -40,7 +48,7 @@ export async function onBeforeRender(pageContext: PageContext) {
return {
pageContext: {
pageProps: {
allowedTypes,
entry_types: allowedTypes,
},
},
};
Expand Down

0 comments on commit 1f7335f

Please sign in to comment.