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

@@ -0,0 +1,15 @@
import { z } from 'zod';
export const BeerCommentQueryResult = z.object({
id: z.string().uuid(),
content: z.string().min(1).max(300),
rating: z.number().int().min(1).max(5),
createdAt: z.date().or(z.string().datetime()),
postedBy: z.object({
id: z.string().uuid(),
username: z.string().min(1).max(50),
}),
});
export const BeerCommentQueryResultArray = z.array(BeerCommentQueryResult);
export type BeerCommentQueryResultT = z.infer<typeof BeerCommentQueryResult>;
export type BeerCommentQueryResultArrayT = z.infer<typeof BeerCommentQueryResultArray>;

View File

@@ -0,0 +1,22 @@
import { z } from 'zod';
const BeerCommentValidationSchema = z.object({
content: z
.string()
.min(1, {
message: 'Comment must not be empty.',
})
.max(300, {
message: 'Comment must be less than 300 characters.',
}),
rating: z
.number()
.int()
.min(1, { message: 'Rating must be greater than 1.' })
.max(5, { message: 'Rating must be less than 5.' }),
beerPostId: z.string().uuid({
message: 'Beer post ID must be a valid UUID.',
}),
});
export default BeerCommentValidationSchema;