-
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.
- Loading branch information
1 parent
e290e01
commit 0a5695d
Showing
7 changed files
with
994 additions
and
2 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,256 @@ | ||
import Link from 'next/link'; | ||
import { Fragment } from 'react'; | ||
|
||
import NotFound from '~/app/[...catchAll]/page'; | ||
import Heading from '~/components/heading'; | ||
import ImageHeader from '~/components/image-header'; | ||
import { | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
} from '~/components/ui'; | ||
import { | ||
getTranslations, | ||
type HostelDetails, | ||
type Translations, | ||
} from '~/i18n/translations'; | ||
//import { db } from '~/server/db'; | ||
|
||
export default async function Hostel({ | ||
params: { locale, url_name }, | ||
}: { | ||
params: { | ||
locale: string; | ||
url_name: keyof Translations['Hostels']['hostels']; | ||
}; | ||
}) { | ||
// const hostel = await db.query.hostels.findFirst({ | ||
// where: (hostels, { eq }) => eq(hostels.urlName, url_name), | ||
// columns: { | ||
// name: true, | ||
// telephone: true, | ||
// type: true, | ||
// alternateTelephone: true, | ||
// email: true, | ||
// }, | ||
// with: { | ||
// wardens: { | ||
// columns: { | ||
// designation: true, | ||
// }, | ||
// with: { | ||
// person: { | ||
// columns: { | ||
// name: true, | ||
// email: true, | ||
// telephone: true, | ||
// }, | ||
// }, | ||
// }, | ||
// }, | ||
// deputyWardens: { | ||
// columns: { | ||
// designation: true, | ||
// }, | ||
// with: { | ||
// person: { | ||
// columns: { | ||
// name: true, | ||
// email: true, | ||
// telephone: true, | ||
// }, | ||
// }, | ||
// }, | ||
// }, | ||
// hostelStaff: { | ||
// columns: { | ||
// post: true, | ||
// }, | ||
// with: { | ||
// staff: { | ||
// columns: { | ||
// designation: true, | ||
// }, | ||
// with: { | ||
// person: { | ||
// columns: { | ||
// name: true, | ||
// telephone: true, | ||
// email: true, | ||
// }, | ||
// }, | ||
// }, | ||
// }, | ||
// }, | ||
// }, | ||
// }, | ||
// }); | ||
const hostel = { | ||
id: 1, | ||
name: 'H1 Abhimanyu Bhawan', | ||
telephone: '+1234567890', | ||
type: 'boys', | ||
alternateTelephone: '+0987654321', | ||
email: '[email protected]', | ||
wardens: [ | ||
{ | ||
designation: 'Associate Professor', | ||
person: { | ||
name: 'John Doe', | ||
email: '[email protected]', | ||
telephone: '+1234567891', | ||
}, | ||
}, | ||
], | ||
deputyWardens: [ | ||
{ | ||
designation: 'Assistant Professor Grade-I', | ||
person: { | ||
name: 'Jane Smith', | ||
email: '[email protected]', | ||
telephone: '+1234567892', | ||
}, | ||
}, | ||
], | ||
hostelStaff: [ | ||
{ | ||
post: 'A block Electrician', | ||
staff: { | ||
designation: 'Maintenance Officer', | ||
person: { | ||
name: 'Alice Brown', | ||
telephone: '+1234567893', | ||
email: '[email protected]', | ||
}, | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
if (!hostel) { | ||
return <NotFound params={{ locale, catchAll: [] }} />; | ||
} | ||
const urlName: keyof Translations['Hostels']['hostels'][typeof hostel.type] = | ||
url_name as keyof Translations['Hostels']['hostels'][typeof hostel.type]; | ||
const { | ||
Hostels: { | ||
hostels: { | ||
[hostel.type]: { [urlName]: hostelText }, | ||
}, | ||
hostelDetails: tagText, | ||
}, | ||
} = await getTranslations(locale); | ||
const hostelDetails: HostelDetails = hostelText; | ||
|
||
return ( | ||
<> | ||
<ImageHeader title={hostel.name} src={`hostels/${url_name}/logo.png`} /> | ||
<section className="container"> | ||
<h5> | ||
<b className="text-primary-700">{tagText.contact}</b> | ||
{hostel.telephone} | ||
{hostel.alternateTelephone && ', ' + hostel.alternateTelephone} | ||
</h5> | ||
<h5> | ||
<b className="text-primary-700">{tagText.email}</b> | ||
<Link href={`mailto:${hostel.email}`}>{hostel.email}</Link> | ||
</h5> | ||
<br /> | ||
<h4>{tagText.overview}</h4> | ||
<ul className="list-inside list-disc"> | ||
{hostelDetails.overview?.map((paragraph, i) => ( | ||
<li key={i}>{paragraph}</li> | ||
))} | ||
</ul> | ||
<h4>{tagText.staffOverview}</h4> | ||
<ul className="list-inside list-disc"> | ||
{hostelDetails.staffOverview.map((paragraph, i) => ( | ||
<li key={i}>{paragraph}</li> | ||
))} | ||
</ul> | ||
<h4>{tagText.facilities}</h4> | ||
<ul className="list-inside list-disc"> | ||
{hostelDetails.facilities.map((paragraph, i) => ( | ||
<li key={i}>{paragraph}</li> | ||
))} | ||
</ul> | ||
</section> | ||
<Heading | ||
heading="h3" | ||
text={tagText.staff} | ||
glyphDirection="rtl" | ||
href={'#staff'} | ||
className="container" | ||
/> | ||
<section className="container"> | ||
<h4>{tagText.faculty}</h4> | ||
<Table> | ||
<TableHeader> | ||
<TableRow> | ||
<TableHead>{tagText.hostelsStaffTable.name}</TableHead> | ||
<TableHead>{tagText.hostelsStaffTable.designation}</TableHead> | ||
<TableHead>{tagText.hostelsStaffTable.hostelPost}</TableHead> | ||
<TableHead>{tagText.contact}</TableHead> | ||
<TableHead>{tagText.email}</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody> | ||
{[hostel.wardens, hostel.deputyWardens].map((group, index) => ( | ||
<Fragment key={index}> | ||
{group.map((staff) => ( | ||
<TableRow key={staff.person.email}> | ||
<TableCell>{staff.person.name}</TableCell> | ||
<TableCell>{staff.designation}</TableCell> | ||
<TableCell> | ||
{index === 0 | ||
? tagText.hostelsStaffTable.wardens | ||
: tagText.hostelsStaffTable.deputyWardens} | ||
</TableCell> | ||
<TableCell>{staff.person.telephone}</TableCell> | ||
<TableCell> | ||
<Link href={`mailto:${staff.person.email}`}> | ||
{staff.person.email} | ||
</Link> | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
</Fragment> | ||
))} | ||
</TableBody> | ||
</Table> | ||
<h4 className="mt-10"> | ||
{tagText.general} {tagText.staff} | ||
</h4> | ||
<Table> | ||
<TableHeader> | ||
<TableRow> | ||
<TableHead>{tagText.hostelsStaffTable.name}</TableHead> | ||
<TableHead>{tagText.hostelsStaffTable.designation}</TableHead> | ||
<TableHead>{tagText.hostelsStaffTable.hostelPost}</TableHead> | ||
<TableHead>{tagText.contact}</TableHead> | ||
<TableHead>{tagText.email}</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody> | ||
{hostel.hostelStaff.map(({ post, staff }) => ( | ||
<TableRow key={staff.person.email}> | ||
<TableCell>{staff.person.name}</TableCell> | ||
<TableCell>{staff.designation}</TableCell> | ||
<TableCell>{post}</TableCell> | ||
<TableCell>{staff.person.telephone}</TableCell> | ||
<TableCell> | ||
<Link href={`mailto:${staff.person.email}`}> | ||
{staff.person.email} | ||
</Link> | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</section> | ||
</> | ||
); | ||
} |
Oops, something went wrong.