Skip to content

Commit

Permalink
Add correct titles for modals
Browse files Browse the repository at this point in the history
  • Loading branch information
FinThunderstorm committed Jul 24, 2024
1 parent 91c771d commit ca8a92d
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/app/@modal/(...)courses/[slug]/manage/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { notFound } from 'next/navigation'
import { Metadata } from 'next'

import { parseSlug } from '@lib/courses'
import { getCourseInfo } from '@services/archive'
Expand All @@ -8,6 +9,24 @@ import RenameCourse from '@components/tools/RenameCourse'
import DeleteCourse from '@components/tools/DeleteCourse'
import { validateUserRights } from '@services/tkoUserService'

export const generateMetadata = async ({
params
}: {
params: { slug: string }
}): Promise<Metadata> => {
const { id } = parseSlug(params.slug)
const course = await getCourseInfo(id)

if (!course) {
notFound()
}

return {
title: `Manage - ${course.name} - Tärpistö - TKO-äly ry`,
description: 'The TKO-äly ry exam archive'
}
}

const Page = async ({ params }: { params: { slug: string } }) => {
await validateUserRights('rename', 'remove')

Expand Down
19 changes: 19 additions & 0 deletions src/app/@modal/(...)courses/[slug]/upload/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { notFound } from 'next/navigation'
import { Metadata } from 'next'

import { parseSlug } from '@lib/courses'
import { getCourseInfo } from '@services/archive'
Expand All @@ -7,6 +8,24 @@ import Modal from '@components/Modal'
import UploadFiles from '@components/tools/UploadFiles'
import { validateUserRights } from '@services/tkoUserService'

export const generateMetadata = async ({
params
}: {
params: { slug: string }
}): Promise<Metadata> => {
const { id } = parseSlug(params.slug)
const course = await getCourseInfo(id)

if (!course) {
notFound()
}

return {
title: `Upload files - ${course.name} - Tärpistö - TKO-äly ry`,
description: 'The TKO-äly ry exam archive'
}
}

const Page = async ({ params }: { params: { slug: string } }) => {
await validateUserRights('upload')

Expand Down
5 changes: 5 additions & 0 deletions src/app/@modal/(...)courses/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { validateUserRights } from '@services/tkoUserService'
import Modal from '@components/Modal'
import CreateCourse from '@components/tools/CreateCourse'

export const metadata = {
title: `Create new course - Tärpistö - TKO-äly ry`,
description: 'The TKO-äly ry exam archive'
}

const Page = async () => {
await validateUserRights('upload')

Expand Down
20 changes: 20 additions & 0 deletions src/app/@modal/(...)files/[fileId]/[fileName]/manage/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { notFound } from 'next/navigation'
import { Metadata } from 'next'

import { getFileNameById } from '@services/archive'

Expand All @@ -7,6 +8,25 @@ import DeleteFile from '@components/tools/DeleteFile'
import UpdateFile from '@components/tools/UpdateFile'
import { validateUserRights } from '@services/tkoUserService'

export const generateMetadata = async ({
params
}: {
params: { fileId: string; fileName: string }
}): Promise<Metadata> => {
const fileId = parseInt(params.fileId, 10)

const file = await getFileNameById(fileId)

if (!file) {
notFound()
}

return {
title: `Manage file ${file.fileName} - Tärpistö - TKO-äly ry`,
description: 'The TKO-äly ry exam archive'
}
}

const Page = async ({
params
}: {
Expand Down

0 comments on commit ca8a92d

Please sign in to comment.