Skip to content

Commit

Permalink
feat: add alliance manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
simonknittel committed Dec 26, 2024
1 parent 995d894 commit d758314
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 20 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/app/app/documents/_assets/introduction_compendium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 43 additions & 12 deletions app/src/app/app/documents/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Hero } from "@/common/components/Hero";
import { type Metadata } from "next";
import Image from "next/image";
import Link from "next/link";
import { redirect } from "next/navigation";
import allianceManifest from "./_assets/alliance_manifest.png";
import introductionCompendium from "./_assets/introduction_compendium.png";

export const metadata: Metadata = {
Expand All @@ -11,7 +13,14 @@ export const metadata: Metadata = {

export default async function Page() {
const authentication = await authenticatePage("/app/documents");
await authentication.authorizePage("documentIntroductionCompendium", "read");
if (
!(await authentication.authorize(
"documentIntroductionCompendium",
"read",
)) &&
!(await authentication.authorize("documentAllianceManifest", "read"))
)
redirect("/app/forbidden");

return (
<main className="p-4 pb-20 lg:p-8 max-w-[1920px] mx-auto">
Expand All @@ -20,17 +29,39 @@ export default async function Page() {
</div>

<div className="flex flex-col gap-8 items-center mt-8">
<Link
href="https://downloads.sinister-incorporated.de/introduction.pdf"
className="block"
>
<Image
src={introductionCompendium}
alt="Einführungskompendium"
width={720}
height={405}
/>
</Link>
{(await authentication.authorize(
"documentIntroductionCompendium",
"read",
)) && (
<Link
href="https://downloads.sinister-incorporated.de/introduction.pdf"
className="block"
>
<Image
src={introductionCompendium}
alt="Einführungskompendium"
width={720}
height={405}
/>
</Link>
)}

{(await authentication.authorize(
"documentAllianceManifest",
"read",
)) && (
<Link
href="https://downloads.sinister-incorporated.de/alliance.pdf"
className="block"
>
<Image
src={allianceManifest}
alt="Alliance Manifest"
width={720}
height={405}
/>
</Link>
)}
</div>
</main>
);
Expand Down
9 changes: 9 additions & 0 deletions app/src/app/app/roles/_components/tabs/DocumentsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ export const DocumentsTab = () => {

<YesNoCheckbox {...register("documentIntroductionCompendium;read")} />
</div>

<div className="py-2 flex justify-between items-center mt-2">
<div>
<h4 className="font-bold">Alliance Manifest</h4>
{/* <p></p> */}
</div>

<YesNoCheckbox {...register("documentAllianceManifest;read")} />
</div>
</TabPanel>
);
};
1 change: 1 addition & 0 deletions app/src/auth/PermissionSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type PermissionSet = {
| "note"
| "eventFleet"
| "documentIntroductionCompendium"
| "documentAllianceManifest"
| "algolia"
| "career";
// TODO: Use ENUM (https://www.prisma.io/docs/concepts/components/prisma-schema/data-model#defining-enums)
Expand Down
9 changes: 5 additions & 4 deletions app/src/common/components/Sidebar/DesktopSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ export const DesktopSidebar = async () => {
const showOperations =
(await dedupedGetUnleashFlag("EnableOperations")) &&
(await authentication.authorize("operation", "manage"));
const showDocuments = await authentication.authorize(
"documentIntroductionCompendium",
"read",
);
const showDocuments =
(await authentication.authorize(
"documentIntroductionCompendium",
"read",
)) || (await authentication.authorize("documentAllianceManifest", "read"));
const showShipManage = await authentication.authorize("ship", "manage");
const showOrgFleetRead = await authentication.authorize("orgFleet", "read");
const showCitizenRead = await authentication.authorize("citizen", "read");
Expand Down
9 changes: 5 additions & 4 deletions app/src/common/components/Sidebar/MobileActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ export const MobileActionBar = async ({ className }: Props) => {
const showOperations =
(await dedupedGetUnleashFlag("EnableOperations")) &&
(await authentication.authorize("operation", "manage"));
const showDocuments = await authentication.authorize(
"documentIntroductionCompendium",
"read",
);
const showDocuments =
(await authentication.authorize(
"documentIntroductionCompendium",
"read",
)) || (await authentication.authorize("documentAllianceManifest", "read"));
const showCareerRead = await authentication.authorize("career", "read");

return (
Expand Down

0 comments on commit d758314

Please sign in to comment.