Skip to content

Commit

Permalink
feat: offer page
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykomiotek committed Feb 1, 2024
1 parent 09e72a4 commit 5bbef18
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
39 changes: 39 additions & 0 deletions apps/jobboard/src/app/(public)/job-offers/[publicId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Metadata } from 'next';

import { Header } from '@jobboard/common-ui';

import Link from 'next/link';
import { fetchOffer } from '../../../../services/offers';
import { notFound } from 'next/navigation';

// export const metadata: Metadata = {
// title: 'Job Offers',
// };

type Params = {
params: {
publicId: string;
};
};

export default async function JobOfferPage({ params }: Params) {
console.log(params.publicId);
const offer = await fetchOffer(params.publicId);
console.log(offer);

if (!offer) {
notFound();
}

return (
<div>
<Header>Job Offer</Header>
<Link href="/job-offers">Back to list</Link>
<div key={offer.public_id} className="my-4">
<h2 className="font-bold text-2xl">{offer.title}</h2>
<p>{offer.description}</p>
<p>Salary: {offer.salary} PLN</p>
</div>
</div>
);
}
9 changes: 8 additions & 1 deletion apps/jobboard/src/app/(public)/job-offers/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ export default async function JobOffersPage() {
<Link href="/job-offers/create">Create offer</Link>
{jobOffers.map((offer) => (
<div key={offer.public_id} className="my-4">
<h2 className="font-bold text-2xl">{offer.title}</h2>
<h2 className="font-bold text-2xl">
<Link
href={`/job-offers/${offer.public_id}`}
className="text-blue-600"
>
{offer.title}
</Link>
</h2>
<p>{offer.description}</p>
<p>Salary: {offer.salary} PLN</p>
</div>
Expand Down
5 changes: 5 additions & 0 deletions apps/jobboard/src/services/offers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { JobOffer } from '@prisma/client';
import db from '@jobboard/prisma-client';

export const fetchJobOffers = async () => {
Expand All @@ -10,3 +11,7 @@ export const fetchJobOffers = async () => {
},
});
};

export const fetchOffer = async (publicId: JobOffer['public_id']) => {
return db.jobOffer.findUnique({ where: { public_id: publicId } });
};

0 comments on commit 5bbef18

Please sign in to comment.