mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Add beer post, brewery post GET service and page
Add prettier, eslint config
This commit is contained in:
35
pages/breweries/index.tsx
Normal file
35
pages/breweries/index.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import { GetServerSideProps, NextPage } from 'next';
|
||||
|
||||
import Link from 'next/link';
|
||||
import getAllBreweryPosts from '@/services/BreweryPost/getAllBreweryPosts';
|
||||
import GetAllBreweryPostsQueryResult from '@/services/BreweryPost/types/BreweryPostQueryResult';
|
||||
|
||||
interface BreweryPageProps {
|
||||
breweryPosts: GetAllBreweryPostsQueryResult[];
|
||||
}
|
||||
|
||||
const BreweryPage: NextPage<BreweryPageProps> = ({ breweryPosts }) => {
|
||||
return (
|
||||
<>
|
||||
<h1 className="text-3xl font-bold underline">Brewery Posts</h1>
|
||||
{breweryPosts.map((post) => {
|
||||
return (
|
||||
<div key={post.id}>
|
||||
<h2>
|
||||
<Link href={`/breweries/${post.id}`}>{post.name}</Link>
|
||||
</h2>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<BreweryPageProps> = async () => {
|
||||
const breweryPosts = await getAllBreweryPosts();
|
||||
return {
|
||||
props: { breweryPosts: JSON.parse(JSON.stringify(breweryPosts)) },
|
||||
};
|
||||
};
|
||||
|
||||
export default BreweryPage;
|
||||
Reference in New Issue
Block a user