From c22837e9747b006e0ee1375b02e41686e7db818c Mon Sep 17 00:00:00 2001 From: antkr Date: Sun, 30 Jun 2024 10:58:58 +0530 Subject: [PATCH] feat:init hostels page --- app/[locale]/hostels/[url_name]/page.tsx | 174 +++++++++++++++++++++++ app/[locale]/hostels/page.tsx | 163 +++++++++++++++++++++ app/[locale]/notifications.tsx | 2 +- i18n/en.ts | 27 ++++ i18n/hi.ts | 27 ++++ i18n/translations.ts | 27 ++++ server/db/schema/notifications.schema.ts | 2 +- 7 files changed, 420 insertions(+), 2 deletions(-) create mode 100644 app/[locale]/hostels/[url_name]/page.tsx create mode 100644 app/[locale]/hostels/page.tsx 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} +
+