mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Update brewery/beer style to use tuples for ranges/coords. Seed updates.
This commit is contained in:
@@ -80,8 +80,10 @@ const BeerInfoHeader: FC<BeerInfoHeaderProps> = ({ beerPost }) => {
|
||||
</Link>
|
||||
</div>
|
||||
<div>
|
||||
<span className="mr-4 text-lg font-medium">{beerPost.abv}% ABV</span>
|
||||
<span className="text-lg font-medium">{beerPost.ibu} IBU</span>
|
||||
<span className="mr-4 text-lg font-medium">
|
||||
{beerPost.abv.toFixed(1)}% ABV
|
||||
</span>
|
||||
<span className="text-lg font-medium">{beerPost.ibu.toFixed(1)} IBU</span>
|
||||
</div>
|
||||
<div>
|
||||
{(!!likeCount || likeCount === 0) && (
|
||||
|
||||
@@ -73,8 +73,8 @@ const BeerRecommendationsSection: FC<{
|
||||
<span className="text-lg font-medium">{post.style.name}</span>
|
||||
</div>
|
||||
<div className="space-x-2">
|
||||
<span>{post.abv}% ABV</span>
|
||||
<span>{post.ibu} IBU</span>
|
||||
<span>{post.abv.toFixed(1)}% ABV</span>
|
||||
<span>{post.ibu.toFixed(1)} IBU</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -41,8 +41,8 @@ const BeerCard: FC<{ post: z.infer<typeof BeerPostQueryResult> }> = ({ post }) =
|
||||
<div>
|
||||
<p className="text-md lg:text-xl">{post.style.name}</p>
|
||||
<div className="space-x-3">
|
||||
<span className="text-sm lg:text-lg">{post.abv}% ABV</span>
|
||||
<span className="text-sm lg:text-lg">{post.ibu} IBU</span>
|
||||
<span className="text-sm lg:text-lg">{post.abv.toFixed(1)}% ABV</span>
|
||||
<span className="text-sm lg:text-lg">{post.ibu.toFixed(1)} IBU</span>
|
||||
</div>
|
||||
{!isLoading && (
|
||||
<span>
|
||||
|
||||
@@ -15,6 +15,16 @@ const BeerStyleCard: FC<{ beerStyle: z.infer<typeof BeerStyleQueryResult> }> = (
|
||||
<h3 className="link-hover link overflow-hidden whitespace-normal text-2xl font-bold lg:truncate lg:text-3xl">
|
||||
{beerStyle.name}
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -38,8 +38,12 @@ const createNewBeerPosts = async ({
|
||||
const breweryPost = breweryPosts[Math.floor(Math.random() * breweryPosts.length)];
|
||||
const createdAt = faker.date.past({ years: 1 });
|
||||
|
||||
const abv = Math.floor(Math.random() * (12 - 4) + 4);
|
||||
const ibu = Math.floor(Math.random() * (60 - 10) + 10);
|
||||
const [minABV, maxABV] = beerStyle.abvRange;
|
||||
const [minIBU, maxIBU] = beerStyle.ibuRange;
|
||||
|
||||
const abv = parseFloat((Math.random() * (maxABV - minABV) + minABV).toFixed(1));
|
||||
const ibu = Math.floor(Math.random() * (maxIBU - minIBU) + minIBU);
|
||||
|
||||
const name = faker.commerce.productName();
|
||||
const description = faker.lorem.lines(20).replace(/(\r\n|\n|\r)/gm, ' ');
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ const getAllBeerStyles = async (
|
||||
pageNum: number,
|
||||
pageSize: number,
|
||||
): Promise<z.infer<typeof BeerStyleQueryResult>[]> => {
|
||||
const styles = await DBClient.instance.beerStyle.findMany({
|
||||
const styles = (await DBClient.instance.beerStyle.findMany({
|
||||
take: pageSize,
|
||||
skip: (pageNum - 1) * pageSize,
|
||||
select: {
|
||||
@@ -15,8 +15,10 @@ const getAllBeerStyles = async (
|
||||
postedBy: { select: { id: true, username: true } },
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
abvRange: true,
|
||||
ibuRange: true,
|
||||
},
|
||||
});
|
||||
})) as z.infer<typeof BeerStyleQueryResult>[];
|
||||
|
||||
return styles;
|
||||
};
|
||||
|
||||
@@ -9,6 +9,8 @@ const BeerStyleQueryResult = z.object({
|
||||
}),
|
||||
createdAt: z.coerce.date(),
|
||||
updatedAt: z.coerce.date().nullable(),
|
||||
abvRange: z.tuple([z.number(), z.number()]),
|
||||
ibuRange: z.tuple([z.number(), z.number()]),
|
||||
});
|
||||
|
||||
export default BeerStyleQueryResult;
|
||||
|
||||
@@ -21,7 +21,7 @@ const createNewBreweryPost = async ({
|
||||
userId,
|
||||
}: z.infer<typeof CreateNewBreweryPostWithUserAndLocationSchema>) => {
|
||||
const breweryPost: z.infer<typeof BreweryPostQueryResult> =
|
||||
await DBClient.instance.breweryPost.create({
|
||||
(await DBClient.instance.breweryPost.create({
|
||||
data: {
|
||||
name,
|
||||
description,
|
||||
@@ -47,7 +47,7 @@ const createNewBreweryPost = async ({
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
})) as z.infer<typeof BreweryPostQueryResult>;
|
||||
|
||||
return breweryPost;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ const getAllBreweryPosts = async (pageNum?: number, pageSize?: number) => {
|
||||
const take = pageNum && pageSize ? pageSize : undefined;
|
||||
|
||||
const breweryPosts: z.infer<typeof BreweryPostQueryResult>[] =
|
||||
await prisma.breweryPost.findMany({
|
||||
(await prisma.breweryPost.findMany({
|
||||
skip,
|
||||
take,
|
||||
select: {
|
||||
@@ -32,7 +32,7 @@ const getAllBreweryPosts = async (pageNum?: number, pageSize?: number) => {
|
||||
dateEstablished: true,
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
});
|
||||
})) as z.infer<typeof BreweryPostQueryResult>[];
|
||||
|
||||
return breweryPosts;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ const prisma = DBClient.instance;
|
||||
|
||||
const getBreweryPostById = async (id: string) => {
|
||||
const breweryPost: z.infer<typeof BreweryPostQueryResult> | null =
|
||||
await prisma.breweryPost.findFirst({
|
||||
(await prisma.breweryPost.findFirst({
|
||||
select: {
|
||||
id: true,
|
||||
location: {
|
||||
@@ -26,7 +26,7 @@ const getBreweryPostById = async (id: string) => {
|
||||
dateEstablished: true,
|
||||
},
|
||||
where: { id },
|
||||
});
|
||||
})) as z.infer<typeof BreweryPostQueryResult> | null;
|
||||
|
||||
return breweryPost;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ const BreweryPostQueryResult = z.object({
|
||||
location: z.object({
|
||||
city: z.string(),
|
||||
address: z.string(),
|
||||
coordinates: z.array(z.number()),
|
||||
coordinates: z.tuple([z.number(), z.number()]),
|
||||
country: z.string().nullable(),
|
||||
stateOrProvince: z.string().nullable(),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user