Return user-facing name for queue types in page prop

This commit is contained in:
regalijan 2023-10-19 16:49:06 -04:00
parent 5d90d0b1b1
commit 1f7335f031
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -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"
@ -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,
};
@ -40,7 +48,7 @@ export async function onBeforeRender(pageContext: PageContext) {
return {
pageContext: {
pageProps: {
allowedTypes,
entry_types: allowedTypes,
},
},
};