-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new page to show past-event detail (#199)
* feat: new page to show past-event detail * fix: missing import header * fix: update stats naming
- Loading branch information
1 parent
92a6057
commit 5273228
Showing
7 changed files
with
517 additions
and
41 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { eventService } from '@/(server)/api/_index'; | ||
import EventPastDashboard from '@/_features/event/components/event-past-dashboard'; | ||
import AppContainer from '@/_shared/components/containers/app-container'; | ||
import HTTPError from '@/_shared/components/errors/http-error'; | ||
import { AuthType } from '@/_shared/types/auth'; | ||
import { headers } from 'next/headers'; | ||
import { notFound } from 'next/navigation'; | ||
|
||
type PageProps = { | ||
params: { | ||
eventID: string; | ||
}; | ||
}; | ||
export default async function Page({ params: { eventID } }: PageProps) { | ||
const headersList = headers(); | ||
const userAuthHeader = headersList.get('user-auth'); | ||
|
||
const user: AuthType.CurrentAuthData | null = | ||
typeof userAuthHeader === 'string' | ||
? JSON.parse(userAuthHeader) | ||
: userAuthHeader; | ||
|
||
if (!user || !user.id) { | ||
return ( | ||
<AppContainer user={user}> | ||
<HTTPError | ||
code={401} | ||
title="Login Required" | ||
description="You need to be logged in to access this page" | ||
/> | ||
</AppContainer> | ||
); | ||
} | ||
|
||
const event = await eventService.getEventBySlugOrID(eventID, user.id); | ||
|
||
if (!event) { | ||
return notFound(); | ||
} | ||
|
||
const isHost = user.id === event.createdBy; | ||
|
||
if (!isHost) { | ||
return ( | ||
<AppContainer user={user}> | ||
<HTTPError | ||
code={403} | ||
title="You are not authorized" | ||
description="You don't have permission to access this page. Please use an account which has access to this page." | ||
/> | ||
</AppContainer> | ||
); | ||
} | ||
|
||
return <EventPastDashboard event={event} />; | ||
} |
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
Oops, something went wrong.