-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
89 additions
and
20 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
apps/web/src/app/(default)/dashbord/[slug]/_components/box.tsx
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { cn } from "@/utils/cn"; | ||
|
||
export const Box = ({ children, className }: { children: React.ReactNode; className?: string }) => ( | ||
<div className={cn("space-y-4 rounded-lg border bg-muted px-3 py-8", className)}>{children}</div> | ||
); |
63 changes: 63 additions & 0 deletions
63
apps/web/src/app/(default)/dashbord/[slug]/_components/fastest-registrations.tsx
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { type getFullHappening } from "@/data/happenings/queries"; | ||
import { type RegistrationWithUser } from "../_lib/types"; | ||
import { Box } from "./box"; | ||
|
||
type FastestRegistrationsProps = { | ||
happening: Exclude<Awaited<ReturnType<typeof getFullHappening>>, undefined>; | ||
registrations: Array<RegistrationWithUser>; | ||
}; | ||
|
||
export const FastestRegistrations = ({ happening, registrations }: FastestRegistrationsProps) => { | ||
const fastestRegistrations = registrations | ||
.filter((registration) => registration.status === "registered") | ||
.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()); | ||
|
||
const topThree = fastestRegistrations.slice(0, 3); | ||
|
||
return ( | ||
<Box> | ||
<ul className="mt-2 px-4"> | ||
<li> | ||
Påmelding for grupper åpnet:{" "} | ||
<span className="text-muted-foreground"> | ||
{happening.registrationStartGroups?.toLocaleString() ?? "Ingen påmelding for grupper"} | ||
</span> | ||
</li> | ||
<li> | ||
Påmelding for alle åpnet:{" "} | ||
<span className="text-muted-foreground"> | ||
{happening.registrationStart?.toLocaleString()} | ||
</span> | ||
</li> | ||
</ul> | ||
|
||
<ul className="space-y-2 px-4"> | ||
{topThree.map((registration, i) => { | ||
const createdAtMs = registration.createdAt.getTime(); | ||
const normalStartMs = happening.registrationStart!.getTime(); | ||
const groupStartMs = happening.registrationStartGroups?.getTime(); | ||
|
||
let ms = createdAtMs - normalStartMs; | ||
if (ms < 0 && groupStartMs) { | ||
ms = createdAtMs - groupStartMs; | ||
} | ||
|
||
return ( | ||
<li className="flex flex-col justify-between sm:flex-row" key={registration.user.id}> | ||
<p> | ||
<span className="text-muted-foreground">{i + 1}.</span> {registration.user.name} | ||
</p> | ||
<p className="text-sm text-muted-foreground">{(ms / 1000).toFixed(2)} sekunder</p> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
|
||
<p className="mt-2 px-4 text-sm text-muted-foreground"> | ||
Om det er negativt tall, så har brukeren meldt seg på før påmeldingen åpnet. Dette kan | ||
skyldes at de har blitt lagt til manuelt, eller at påmeldingsdatoen har blitt endret etter | ||
at de meldte seg på. | ||
</p> | ||
</Box> | ||
); | ||
}; |
3 changes: 3 additions & 0 deletions
3
apps/web/src/app/(default)/dashbord/[slug]/_components/heading.tsx
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const Heading = ({ children }: { children: React.ReactNode }) => ( | ||
<h2 className="text-2xl font-medium">{children}</h2> | ||
); |
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
10 changes: 2 additions & 8 deletions
10
apps/web/src/app/(default)/dashbord/[slug]/_tabs/utilities.tsx
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