Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 37 additions & 14 deletions app/(standalone)/join/[groupId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,31 @@ import { QueryOrigin } from '@/constants'
import JoinGroupForm from './_components/join-group-form'
import { Path } from '@/lib/utils/path'

export const metadata: Metadata = {
title: 'Join Group',
export async function generateMetadata({
params,
}: {
params: Promise<{ groupId: string }>
}): Promise<Metadata> {
const { groupId } = await params

if (!groupId) {
return {
title: 'Join Group',
}
}

const group = await getGroup(groupId)

if (!group) {
return {
title: 'Join Group',
}
}

return {
title: `Join ${group.name}`,
description: `Join ${group.name} to tip on Formula 1 races with the group members.`,
}
}

export default async function JoinGroup({
Expand Down Expand Up @@ -142,18 +165,6 @@ export default async function JoinGroup({
}))
}

function getGroup(id: Database.Group['id']) {
return db.query.groupsTable.findFirst({
where(fields, operators) {
return operators.eq(fields.id, id)
},
columns: {
name: true,
iconName: true,
},
})
}

function EmptyState() {
return (
<Card>
Expand Down Expand Up @@ -192,3 +203,15 @@ export default async function JoinGroup({
)
}
}

function getGroup(id: Database.Group['id']) {
return db.query.groupsTable.findFirst({
where(fields, operators) {
return operators.eq(fields.id, id)
},
columns: {
name: true,
iconName: true,
},
})
}
Loading