mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Update: more work on beer styles, add erd to readme
This commit is contained in:
@@ -39,6 +39,10 @@ scale, or IBU, is used to approximately quantify the bitterness of beer. This sc
|
|||||||
measured on the perceived bitterness of the beer, but rather the amount of a component of
|
measured on the perceived bitterness of the beer, but rather the amount of a component of
|
||||||
beer known as iso-alpha acids.
|
beer known as iso-alpha acids.
|
||||||
|
|
||||||
|
## Database Schema
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Technologies
|
## Technologies
|
||||||
|
|
||||||
### General
|
### General
|
||||||
|
|||||||
2086
schema.svg
Normal file
2086
schema.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 194 KiB |
@@ -8,24 +8,37 @@ const BeerStyleCard: FC<{ beerStyle: z.infer<typeof BeerStyleQueryResult> }> = (
|
|||||||
beerStyle,
|
beerStyle,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div className="card card-compact bg-base-300" key={beerStyle.id}>
|
<div className="card card-compact bg-base-300">
|
||||||
<div className="card-body justify-between">
|
<div className="card-body justify-between">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<Link href={`/beers/types/${beerStyle.id}`}>
|
<Link href={`/beers/types/${beerStyle.id}`}>
|
||||||
<h3 className="link-hover link overflow-hidden whitespace-normal text-2xl font-bold lg:truncate lg:text-3xl">
|
<h3 className="link-hover link overflow-hidden whitespace-normal text-2xl font-bold lg:truncate lg:text-3xl">
|
||||||
{beerStyle.name}
|
{beerStyle.name}
|
||||||
</h3>
|
</h3>
|
||||||
<div className="text-base-content text-sm">
|
|
||||||
ABV Range: <span>{beerStyle.abvRange[0].toFixed(1)}%</span>
|
|
||||||
<span> - </span>
|
|
||||||
<span>{beerStyle.abvRange[1].toFixed(1)}%</span>
|
|
||||||
</div>
|
|
||||||
<div className="text-base-content text-sm">
|
|
||||||
IBU Range: <span>{beerStyle.ibuRange[0].toFixed(1)}</span>
|
|
||||||
<span> - </span>
|
|
||||||
<span>{beerStyle.ibuRange[1].toFixed(1)}</span>
|
|
||||||
</div>
|
|
||||||
</Link>
|
</Link>
|
||||||
|
<div className="flex w-25 space-x-3 flex-row">
|
||||||
|
<div className="text-sm font-bold">
|
||||||
|
ABV Range:{' '}
|
||||||
|
<span>
|
||||||
|
{beerStyle.abvRange[0].toFixed(1)}% - {beerStyle.abvRange[1].toFixed(1)}%
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="text-sm font-bold">
|
||||||
|
IBU Range:{' '}
|
||||||
|
<span>
|
||||||
|
{beerStyle.ibuRange[0].toFixed(1)} - {beerStyle.ibuRange[1].toFixed(1)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p>{beerStyle.description}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="font-semibold">
|
||||||
|
Recommended Glassware:{' '}
|
||||||
|
<span className="text-sm font-bold italic">{beerStyle.glassware.name}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
23
src/components/ui/SmLoadingCard.tsx
Normal file
23
src/components/ui/SmLoadingCard.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { FC } from 'react';
|
||||||
|
|
||||||
|
const SMLoadingCard: FC = () => {
|
||||||
|
return (
|
||||||
|
<div className="card bg-base-300">
|
||||||
|
<div className="card-body h-52">
|
||||||
|
<div className="flex animate-pulse space-x-4">
|
||||||
|
<div className="flex-1 space-y-4 py-1">
|
||||||
|
<div className="h-4 w-3/4 rounded bg-base-100" />
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="h-4 rounded bg-base-100" />
|
||||||
|
<div className="h-4 w-5/6 rounded bg-base-100" />
|
||||||
|
<div className="h-4 w-5/6 rounded bg-base-100" />
|
||||||
|
<div className="h-4 rounded bg-base-100" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SMLoadingCard;
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
import BeerStyleCard from '@/components/BeerStyle/BeerStyleCard';
|
|
||||||
import LoadingCard from '@/components/ui/LoadingCard';
|
|
||||||
import Spinner from '@/components/ui/Spinner';
|
|
||||||
import useBeerStyles from '@/hooks/data-fetching/beer-styles/useBeerStyles';
|
|
||||||
|
|
||||||
import { NextPage } from 'next';
|
import { NextPage } from 'next';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import { MutableRefObject, useRef } from 'react';
|
import { MutableRefObject, useRef } from 'react';
|
||||||
import { FaArrowUp } from 'react-icons/fa';
|
import { FaArrowUp } from 'react-icons/fa';
|
||||||
import { useInView } from 'react-intersection-observer';
|
import { useInView } from 'react-intersection-observer';
|
||||||
|
|
||||||
|
import BeerStyleCard from '@/components/BeerStyle/BeerStyleCard';
|
||||||
|
import SmLoadingCard from '@/components/ui/SmLoadingCard';
|
||||||
|
import Spinner from '@/components/ui/Spinner';
|
||||||
|
import useBeerStyles from '@/hooks/data-fetching/beer-styles/useBeerStyles';
|
||||||
|
|
||||||
const BeerStylePage: NextPage = () => {
|
const BeerStylePage: NextPage = () => {
|
||||||
const PAGE_SIZE = 20;
|
const PAGE_SIZE = 20;
|
||||||
const pageRef: MutableRefObject<HTMLDivElement | null> = useRef(null);
|
const pageRef: MutableRefObject<HTMLDivElement | null> = useRef(null);
|
||||||
@@ -17,7 +17,6 @@ const BeerStylePage: NextPage = () => {
|
|||||||
pageSize: PAGE_SIZE,
|
pageSize: PAGE_SIZE,
|
||||||
});
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
const { ref: lastBeerStyleRef } = useInView({
|
const { ref: lastBeerStyleRef } = useInView({
|
||||||
onChange: (visible) => {
|
onChange: (visible) => {
|
||||||
if (!visible || isAtEnd) return;
|
if (!visible || isAtEnd) return;
|
||||||
@@ -28,7 +27,7 @@ const BeerStylePage: NextPage = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>Beer Types | The Biergarten App</title>
|
<title>Beer Styles | The Biergarten App</title>
|
||||||
<meta
|
<meta
|
||||||
name="description"
|
name="description"
|
||||||
content="Find beers made by breweries near you and around the world."
|
content="Find beers made by breweries near you and around the world."
|
||||||
@@ -60,7 +59,7 @@ const BeerStylePage: NextPage = () => {
|
|||||||
{(isLoading || isLoadingMore) && (
|
{(isLoading || isLoadingMore) && (
|
||||||
<>
|
<>
|
||||||
{Array.from({ length: PAGE_SIZE }, (_, i) => (
|
{Array.from({ length: PAGE_SIZE }, (_, i) => (
|
||||||
<LoadingCard key={i} />
|
<SmLoadingCard key={i} />
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ const getAllBeerStyles = async (
|
|||||||
updatedAt: true,
|
updatedAt: true,
|
||||||
abvRange: true,
|
abvRange: true,
|
||||||
ibuRange: true,
|
ibuRange: true,
|
||||||
|
description: true,
|
||||||
|
glassware: { select: { id: true, name: true } },
|
||||||
},
|
},
|
||||||
})) as z.infer<typeof BeerStyleQueryResult>[];
|
})) as z.infer<typeof BeerStyleQueryResult>[];
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
const BeerStyleQueryResult = z.object({
|
const BeerStyleQueryResult = z.object({
|
||||||
|
abvRange: z.tuple([z.number(), z.number()]),
|
||||||
|
createdAt: z.coerce.date(),
|
||||||
|
description: z.string(),
|
||||||
|
glassware: z.object({ id: z.string().cuid(), name: z.string() }),
|
||||||
|
ibuRange: z.tuple([z.number(), z.number()]),
|
||||||
id: z.string().cuid(),
|
id: z.string().cuid(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
postedBy: z.object({
|
postedBy: z.object({ id: z.string().cuid(), username: z.string() }),
|
||||||
id: z.string().cuid(),
|
|
||||||
username: z.string(),
|
|
||||||
}),
|
|
||||||
createdAt: z.coerce.date(),
|
|
||||||
updatedAt: z.coerce.date().nullable(),
|
updatedAt: z.coerce.date().nullable(),
|
||||||
abvRange: z.tuple([z.number(), z.number()]),
|
|
||||||
ibuRange: z.tuple([z.number(), z.number()]),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default BeerStyleQueryResult;
|
export default BeerStyleQueryResult;
|
||||||
|
|||||||
Reference in New Issue
Block a user