Add beer post, brewery post GET service and page

Add prettier, eslint config
This commit is contained in:
Aaron William Po
2023-01-22 20:56:33 -05:00
parent a434e1bb98
commit 0065525f5c
29 changed files with 8696 additions and 6977 deletions

35
pages/breweries/index.tsx Normal file
View 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;