-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐸 Update homepage to display current wave (#468)
Co-authored-by: mazya <[email protected]>
- Loading branch information
1 parent
749a075
commit 87d9bf3
Showing
4 changed files
with
45 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
import Link from "next/link"; | ||
import { urls } from "@/constants/urls"; | ||
import { getWaves } from "@/drizzle/queries/waves"; | ||
import { getFirstNotClosedWave } from "@/drizzle/queries/waves"; | ||
|
||
import { userHasRole, UserPermission } from "@/config/userPermissions"; | ||
import { Button } from "@/components/ui/button"; | ||
import { PageHeader } from "@/components/ui/pageHeader"; | ||
import { WavePreview } from "@/components/ui/wavePreview.tsx/wavePreview"; | ||
import { TimelinePreview } from "@/components/ui/wavesTimelinePreview/timelinePreview"; | ||
|
||
import { SubmissionsSection } from "./waves/[waveId]/applications/submissions/submissionsSection"; | ||
import { WaveBanner } from "./waves/[waveId]/waveBanner"; | ||
|
||
export default async function Home() { | ||
const isModerator = await userHasRole(UserPermission.moderator); | ||
const wave = await getFirstNotClosedWave(); | ||
if (!wave) { | ||
return <NotWaveMessage />; | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col gap-6"> | ||
<PageHeader title={wave.name} /> | ||
|
||
<WaveBanner /> | ||
|
||
const waves = await getWaves(); | ||
<TimelinePreview wave={wave} /> | ||
|
||
<SubmissionsSection wave={wave} /> | ||
</div> | ||
); | ||
} | ||
|
||
function NotWaveMessage() { | ||
return ( | ||
<div className="flex w-full flex-col gap-4"> | ||
<PageHeader title="Current waves"> | ||
{isModerator && ( | ||
<Button variant="secondary" asChild> | ||
<Link href={urls.waves.create}>Create wave</Link> | ||
</Button> | ||
)} | ||
</PageHeader> | ||
|
||
<ol className="flex flex-col gap-8"> | ||
{waves.map((wave) => ( | ||
<WavePreview wave={wave} key={wave.id} /> | ||
))} | ||
</ol> | ||
<div className="my-[25vh] flex flex-col items-center"> | ||
<h2 className="text-xl">No wave has been started yet</h2> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters