Refactored api services into sep files. Client fix

Fixed hydration errors in beers/[id] by implementing timeDistanceState
This commit is contained in:
Aaron William Po
2023-01-31 22:38:13 -05:00
parent 0b96c8f1f5
commit 5cf2087cd1
29 changed files with 380 additions and 430 deletions

View File

@@ -1,27 +1,17 @@
import BeerPostQueryResult from '@/services/BeerPost/types/BeerPostQueryResult';
import DBClient from '@/prisma/DBClient';
import BeerPostQueryResult from './schema/BeerPostQueryResult';
const getBeerRecommendations = async (
beerPost: Pick<BeerPostQueryResult, 'type' | 'brewery'>,
beerPost: Pick<BeerPostQueryResult, 'type' | 'brewery' | 'id'>,
) => {
const beerRecommendations = await DBClient.instance.beerPost.findMany({
where: {
OR: [
{
typeId: beerPost.type.id,
},
{
breweryId: beerPost.brewery.id,
},
],
OR: [{ typeId: beerPost.type.id }, { breweryId: beerPost.brewery.id }],
NOT: { id: beerPost.id },
},
include: {
beerImages: {
select: { id: true, url: true, alt: true },
},
brewery: {
select: { id: true, name: true },
},
beerImages: { select: { id: true, url: true, alt: true } },
brewery: { select: { id: true, name: true } },
},
});