diff --git a/app/[locale]/hostels/[url_name]/page.tsx b/app/[locale]/hostels/[url_name]/page.tsx new file mode 100644 index 00000000..ee833e34 --- /dev/null +++ b/app/[locale]/hostels/[url_name]/page.tsx @@ -0,0 +1,174 @@ +import Link from 'next/link'; +import { Fragment } from 'react'; +import { notFound } from 'next/navigation'; + +import Heading from '~/components/heading'; +import ImageHeader from '~/components/image-header'; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from '~/components/ui'; +import { getTranslations, type Translations } from '~/i18n/translations'; +import { db } from '~/server/db'; + +export default async function Hostel({ + params: { locale, url_name }, +}: { + params: { + locale: string; + url_name: string; + }; +}) { + const hostel = await db.query.hostels.findFirst({ + where: (hostels, { eq }) => eq(hostels.urlName, url_name), + columns: { + address: true, + name: true, + telephone: true, + type: true, + alternateTelephone: true, + email: true, + overview: true, + staffOverview: true, + facilities: true, + }, + with: { + hostelFaculty: { + columns: { + post: true, + }, + with: { + faculty: { + columns: { + designation: true, + }, + with: { + person: { + columns: { + name: true, + telephone: true, + email: true, + }, + }, + }, + }, + }, + }, + hostelStaff: { + columns: { + post: true, + }, + with: { + staff: { + columns: { + designation: true, + }, + with: { + person: { + columns: { + name: true, + telephone: true, + email: true, + }, + }, + }, + }, + }, + }, + }, + }); + + if (!hostel) { + return notFound(); + } + + const text = (await getTranslations(locale)).Hostels.hostelDetails; + + return ( + <> + +
+
+ {text.contact} + {hostel.telephone} + {hostel.alternateTelephone && ', ' + hostel.alternateTelephone} +
+
+ {text.email} + {hostel.email} +
+