mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Refactor: rename [:id] to [:postId] for api routes
This commit is contained in:
@@ -33,14 +33,18 @@ const BeerPostCommentsSection: FC<BeerPostCommentsSectionProps> = ({ beerPost })
|
|||||||
const commentSectionRef: MutableRefObject<HTMLDivElement | null> = useRef(null);
|
const commentSectionRef: MutableRefObject<HTMLDivElement | null> = useRef(null);
|
||||||
|
|
||||||
const handleDeleteRequest = async (id: string) => {
|
const handleDeleteRequest = async (id: string) => {
|
||||||
deleteBeerPostCommentRequest({ commentId: id });
|
await deleteBeerPostCommentRequest({ commentId: id, beerPostId: beerPost.id });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEditRequest = async (
|
const handleEditRequest = async (
|
||||||
id: string,
|
id: string,
|
||||||
data: z.infer<typeof CreateCommentValidationSchema>,
|
data: z.infer<typeof CreateCommentValidationSchema>,
|
||||||
) => {
|
) => {
|
||||||
editBeerPostCommentRequest({ body: data, commentId: id });
|
await editBeerPostCommentRequest({
|
||||||
|
body: data,
|
||||||
|
commentId: id,
|
||||||
|
beerPostId: beerPost.id,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const BeerStyleCommentsSection: FC<BeerStyleCommentsSectionProps> = ({ beerStyle
|
|||||||
const commentSectionRef: MutableRefObject<HTMLDivElement | null> = useRef(null);
|
const commentSectionRef: MutableRefObject<HTMLDivElement | null> = useRef(null);
|
||||||
|
|
||||||
const handleDeleteRequest = async (id: string) => {
|
const handleDeleteRequest = async (id: string) => {
|
||||||
const response = await fetch(`/api/beer-style-comments/${id}`, {
|
const response = await fetch(`/api/beers/styles/${beerStyle.id}/comments/${id}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ const BeerStyleCommentsSection: FC<BeerStyleCommentsSectionProps> = ({ beerStyle
|
|||||||
id: string,
|
id: string,
|
||||||
data: z.infer<typeof CreateCommentValidationSchema>,
|
data: z.infer<typeof CreateCommentValidationSchema>,
|
||||||
) => {
|
) => {
|
||||||
const response = await fetch(`/api/beer-style-comments/${id}`, {
|
const response = await fetch(`/api/beers/styles/${beerStyle.id}/comments/${id}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ content: data.content, rating: data.rating }),
|
body: JSON.stringify({ content: data.content, rating: data.rating }),
|
||||||
|
|||||||
@@ -31,9 +31,10 @@ const BreweryCommentsSection: FC<BreweryBeerSectionProps> = ({ breweryPost }) =>
|
|||||||
const commentSectionRef: MutableRefObject<HTMLDivElement | null> = useRef(null);
|
const commentSectionRef: MutableRefObject<HTMLDivElement | null> = useRef(null);
|
||||||
|
|
||||||
const handleDeleteRequest = async (commentId: string) => {
|
const handleDeleteRequest = async (commentId: string) => {
|
||||||
const response = await fetch(`/api/brewery-comments/${commentId}`, {
|
const response = await fetch(
|
||||||
method: 'DELETE',
|
`/api/breweries/${breweryPost.id}/comments/${commentId}`,
|
||||||
});
|
{ method: 'DELETE' },
|
||||||
|
);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(response.statusText);
|
throw new Error(response.statusText);
|
||||||
@@ -44,15 +45,19 @@ const BreweryCommentsSection: FC<BreweryBeerSectionProps> = ({ breweryPost }) =>
|
|||||||
commentId: string,
|
commentId: string,
|
||||||
data: z.infer<typeof CreateCommentValidationSchema>,
|
data: z.infer<typeof CreateCommentValidationSchema>,
|
||||||
) => {
|
) => {
|
||||||
const response = await fetch(`/api/brewery-comments/${commentId}`, {
|
const response = await fetch(
|
||||||
method: 'PUT',
|
`/api/breweries/${breweryPost.id}/comments/${commentId}`,
|
||||||
headers: { 'Content-Type': 'application/json' },
|
{
|
||||||
body: JSON.stringify({ content: data.content, rating: data.rating }),
|
method: 'PUT',
|
||||||
});
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ content: data.content, rating: data.rating }),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(response.statusText);
|
throw new Error(response.statusText);
|
||||||
}
|
}
|
||||||
|
console.log(await response.json());
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ export const checkIfBeerCommentOwner = async <T extends CommentRequest>(
|
|||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
next: NextHandler,
|
next: NextHandler,
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.query;
|
const { commentId } = req.query;
|
||||||
const user = req.user!;
|
const user = req.user!;
|
||||||
const comment = await getBeerPostCommentByIdService({ beerPostCommentId: id });
|
const comment = await getBeerPostCommentByIdService({ beerPostCommentId: commentId });
|
||||||
|
|
||||||
if (!comment) {
|
if (!comment) {
|
||||||
throw new ServerError('Comment not found', 404);
|
throw new ServerError('Comment not found', 404);
|
||||||
@@ -43,9 +43,9 @@ export const editBeerPostComment = async (
|
|||||||
req: EditAndCreateCommentRequest,
|
req: EditAndCreateCommentRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.query;
|
const { commentId } = req.query;
|
||||||
|
|
||||||
await editBeerPostCommentByIdService({ body: req.body, beerPostCommentId: id });
|
await editBeerPostCommentByIdService({ body: req.body, beerPostCommentId: commentId });
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
@@ -58,9 +58,9 @@ export const deleteBeerPostComment = async (
|
|||||||
req: CommentRequest,
|
req: CommentRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.query;
|
const { commentId } = req.query;
|
||||||
|
|
||||||
await deleteBeerCommentByIdService({ beerPostCommentId: id });
|
await deleteBeerCommentByIdService({ beerPostCommentId: commentId });
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
@@ -73,7 +73,7 @@ export const createBeerPostComment = async (
|
|||||||
req: EditAndCreateCommentRequest,
|
req: EditAndCreateCommentRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const beerPostId = req.query.id;
|
const beerPostId = req.query.postId;
|
||||||
|
|
||||||
const newBeerComment = await createBeerPostCommentService({
|
const newBeerComment = await createBeerPostCommentService({
|
||||||
body: req.body,
|
body: req.body,
|
||||||
@@ -93,7 +93,7 @@ export const getAllBeerPostComments = async (
|
|||||||
req: GetAllCommentsRequest,
|
req: GetAllCommentsRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const beerPostId = req.query.id;
|
const beerPostId = req.query.postId;
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
const { page_size, page_num } = req.query;
|
const { page_size, page_num } = req.query;
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,12 @@ export const checkIfBeerStyleCommentOwner = async <
|
|||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
next: NextHandler,
|
next: NextHandler,
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.query;
|
const { commentId } = req.query;
|
||||||
const user = req.user!;
|
const user = req.user!;
|
||||||
|
|
||||||
const beerStyleComment = await findBeerStyleCommentById({ beerStyleCommentId: id });
|
const beerStyleComment = await findBeerStyleCommentById({
|
||||||
|
beerStyleCommentId: commentId,
|
||||||
|
});
|
||||||
|
|
||||||
if (!beerStyleComment) {
|
if (!beerStyleComment) {
|
||||||
throw new ServerError('Beer style comment not found.', 404);
|
throw new ServerError('Beer style comment not found.', 404);
|
||||||
@@ -49,7 +51,7 @@ export const editBeerStyleComment = async (
|
|||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
await updateBeerStyleCommentById({
|
await updateBeerStyleCommentById({
|
||||||
beerStyleCommentId: req.query.id,
|
beerStyleCommentId: req.query.commentId,
|
||||||
body: req.body,
|
body: req.body,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -64,9 +66,9 @@ export const deleteBeerStyleComment = async (
|
|||||||
req: CommentRequest,
|
req: CommentRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.query;
|
const { commentId } = req.query;
|
||||||
|
|
||||||
await deleteBeerStyleCommentById({ beerStyleCommentId: id });
|
await deleteBeerStyleCommentById({ beerStyleCommentId: commentId });
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
@@ -81,7 +83,7 @@ export const createComment = async (
|
|||||||
) => {
|
) => {
|
||||||
const newBeerStyleComment = await createNewBeerStyleComment({
|
const newBeerStyleComment = await createNewBeerStyleComment({
|
||||||
body: req.body,
|
body: req.body,
|
||||||
beerStyleId: req.query.id,
|
beerStyleId: req.query.postId,
|
||||||
userId: req.user!.id,
|
userId: req.user!.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -97,7 +99,7 @@ export const getAll = async (
|
|||||||
req: GetAllCommentsRequest,
|
req: GetAllCommentsRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const beerStyleId = req.query.id;
|
const beerStyleId = req.query.postId;
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
const { page_size, page_num } = req.query;
|
const { page_size, page_num } = req.query;
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ export const checkIfBreweryCommentOwner = async <
|
|||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
next: NextHandler,
|
next: NextHandler,
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.query;
|
const { commentId } = req.query;
|
||||||
const user = req.user!;
|
const user = req.user!;
|
||||||
const comment = await getBreweryCommentById({ breweryCommentId: id });
|
const comment = await getBreweryCommentById({ breweryCommentId: commentId });
|
||||||
|
|
||||||
if (!comment) {
|
if (!comment) {
|
||||||
throw new ServerError('Comment not found', 404);
|
throw new ServerError('Comment not found', 404);
|
||||||
@@ -44,10 +44,10 @@ export const editBreweryPostComment = async (
|
|||||||
req: EditAndCreateCommentRequest,
|
req: EditAndCreateCommentRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.query;
|
const { commentId } = req.query;
|
||||||
|
|
||||||
const updated = updateBreweryCommentById({
|
const updated = await updateBreweryCommentById({
|
||||||
breweryCommentId: id,
|
breweryCommentId: commentId,
|
||||||
body: req.body,
|
body: req.body,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -63,9 +63,9 @@ export const deleteBreweryPostComment = async (
|
|||||||
req: CommentRequest,
|
req: CommentRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.query;
|
const { commentId } = req.query;
|
||||||
|
|
||||||
await deleteBreweryCommentByIdService({ breweryCommentId: id });
|
await deleteBreweryCommentByIdService({ breweryCommentId: commentId });
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
@@ -78,7 +78,7 @@ export const createComment = async (
|
|||||||
req: EditAndCreateCommentRequest,
|
req: EditAndCreateCommentRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const breweryPostId = req.query.id;
|
const breweryPostId = req.query.postId;
|
||||||
|
|
||||||
const user = req.user!;
|
const user = req.user!;
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ export const getAll = async (
|
|||||||
req: GetAllCommentsRequest,
|
req: GetAllCommentsRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const breweryPostId = req.query.id;
|
const breweryPostId = req.query.postId;
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
const { page_size, page_num } = req.query;
|
const { page_size, page_num } = req.query;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import CreateCommentValidationSchema from '@/services/schema/CommentSchema/Creat
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
export interface CommentRequest extends UserExtendedNextApiRequest {
|
export interface CommentRequest extends UserExtendedNextApiRequest {
|
||||||
query: { id: string };
|
query: { postId: string; commentId: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EditAndCreateCommentRequest extends CommentRequest {
|
export interface EditAndCreateCommentRequest extends CommentRequest {
|
||||||
@@ -11,5 +11,5 @@ export interface EditAndCreateCommentRequest extends CommentRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface GetAllCommentsRequest extends UserExtendedNextApiRequest {
|
export interface GetAllCommentsRequest extends UserExtendedNextApiRequest {
|
||||||
query: { id: string; page_size: string; page_num: string };
|
query: { postId: string; page_size: string; page_num: string };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { UserExtendedNextApiRequest } from '@/config/auth/types';
|
|||||||
import ServerError from '@/config/util/ServerError';
|
import ServerError from '@/config/util/ServerError';
|
||||||
|
|
||||||
import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema';
|
import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema';
|
||||||
import { NextApiResponse, NextApiRequest } from 'next';
|
import { NextApiResponse } from 'next';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { getBeerPostById } from '@/services/posts/beer-post';
|
import { getBeerPostById } from '@/services/posts/beer-post';
|
||||||
@@ -19,9 +19,9 @@ export const sendBeerPostLikeRequest = async (
|
|||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const user = req.user!;
|
const user = req.user!;
|
||||||
const id = req.query.id as string;
|
const { postId } = req.query;
|
||||||
|
|
||||||
const beer = await getBeerPostById({ beerPostId: id });
|
const beer = await getBeerPostById({ beerPostId: postId });
|
||||||
if (!beer) {
|
if (!beer) {
|
||||||
throw new ServerError('Could not find a beer post with that id.', 404);
|
throw new ServerError('Could not find a beer post with that id.', 404);
|
||||||
}
|
}
|
||||||
@@ -53,12 +53,12 @@ export const sendBeerPostLikeRequest = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getBeerPostLikeCount = async (
|
export const getBeerPostLikeCount = async (
|
||||||
req: NextApiRequest,
|
req: LikeRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const id = req.query.id as string;
|
const { postId } = req.query;
|
||||||
|
|
||||||
const likeCount = await getBeerPostLikeCountService({ beerPostId: id });
|
const likeCount = await getBeerPostLikeCountService({ beerPostId: postId });
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import ServerError from '@/config/util/ServerError';
|
import ServerError from '@/config/util/ServerError';
|
||||||
|
|
||||||
import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema';
|
import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema';
|
||||||
import { NextApiResponse, NextApiRequest } from 'next';
|
import { NextApiResponse } from 'next';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { UserExtendedNextApiRequest } from '@/config/auth/types';
|
import { UserExtendedNextApiRequest } from '@/config/auth/types';
|
||||||
import {
|
import {
|
||||||
@@ -18,9 +18,9 @@ export const sendBeerStyleLikeRequest = async (
|
|||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const user = req.user!;
|
const user = req.user!;
|
||||||
const { id } = req.query;
|
const { postId } = req.query;
|
||||||
|
|
||||||
const beerStyle = await getBeerStyleByIdService({ beerStyleId: id });
|
const beerStyle = await getBeerStyleByIdService({ beerStyleId: postId });
|
||||||
if (!beerStyle) {
|
if (!beerStyle) {
|
||||||
throw new ServerError('Could not find a beer style with that id.', 404);
|
throw new ServerError('Could not find a beer style with that id.', 404);
|
||||||
}
|
}
|
||||||
@@ -48,11 +48,11 @@ export const sendBeerStyleLikeRequest = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getBeerStyleLikeCountRequest = async (
|
export const getBeerStyleLikeCountRequest = async (
|
||||||
req: NextApiRequest,
|
req: LikeRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const id = req.query.id as string;
|
const { postId } = req.query;
|
||||||
const likeCount = await getBeerStyleLikeCountService({ beerStyleId: id });
|
const likeCount = await getBeerStyleLikeCountService({ beerStyleId: postId });
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { UserExtendedNextApiRequest } from '@/config/auth/types';
|
|
||||||
import ServerError from '@/config/util/ServerError';
|
import ServerError from '@/config/util/ServerError';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -9,17 +8,18 @@ import {
|
|||||||
} from '@/services/likes/brewery-post-like';
|
} from '@/services/likes/brewery-post-like';
|
||||||
import { getBreweryPostByIdService } from '@/services/posts/brewery-post';
|
import { getBreweryPostByIdService } from '@/services/posts/brewery-post';
|
||||||
import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema';
|
import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema';
|
||||||
import { NextApiResponse, NextApiRequest } from 'next';
|
import { NextApiResponse } from 'next';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
import { LikeRequest } from '../types';
|
||||||
|
|
||||||
export const sendBreweryPostLikeRequest = async (
|
export const sendBreweryPostLikeRequest = async (
|
||||||
req: UserExtendedNextApiRequest,
|
req: LikeRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const id = req.query.id! as string;
|
const { postId } = req.query;
|
||||||
const user = req.user!;
|
const user = req.user!;
|
||||||
|
|
||||||
const breweryPost = await getBreweryPostByIdService({ breweryPostId: id });
|
const breweryPost = await getBreweryPostByIdService({ breweryPostId: postId });
|
||||||
|
|
||||||
if (!breweryPost) {
|
if (!breweryPost) {
|
||||||
throw new ServerError('Could not find a brewery post with that id', 404);
|
throw new ServerError('Could not find a brewery post with that id', 404);
|
||||||
@@ -53,12 +53,12 @@ export const sendBreweryPostLikeRequest = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getBreweryPostLikeCount = async (
|
export const getBreweryPostLikeCount = async (
|
||||||
req: NextApiRequest,
|
req: LikeRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const id = req.query.id! as string;
|
const { postId } = req.query;
|
||||||
|
|
||||||
const breweryPost = await getBreweryPostByIdService({ breweryPostId: id });
|
const breweryPost = await getBreweryPostByIdService({ breweryPostId: postId });
|
||||||
if (!breweryPost) {
|
if (!breweryPost) {
|
||||||
throw new ServerError('Could not find a brewery post with that id', 404);
|
throw new ServerError('Could not find a brewery post with that id', 404);
|
||||||
}
|
}
|
||||||
@@ -76,14 +76,14 @@ export const getBreweryPostLikeCount = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getBreweryPostLikeStatus = async (
|
export const getBreweryPostLikeStatus = async (
|
||||||
req: UserExtendedNextApiRequest,
|
req: LikeRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const user = req.user!;
|
const user = req.user!;
|
||||||
const id = req.query.id as string;
|
const { postId } = req.query;
|
||||||
|
|
||||||
const liked = await findBreweryPostLikeService({
|
const liked = await findBreweryPostLikeService({
|
||||||
breweryPostId: id,
|
breweryPostId: postId,
|
||||||
likedById: user.id,
|
likedById: user.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { UserExtendedNextApiRequest } from '@/config/auth/types';
|
import { UserExtendedNextApiRequest } from '@/config/auth/types';
|
||||||
|
|
||||||
export interface LikeRequest extends UserExtendedNextApiRequest {
|
export interface LikeRequest extends UserExtendedNextApiRequest {
|
||||||
query: { id: string };
|
query: { postId: string };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ export const checkIfBeerPostOwner = async <BeerPostRequestType extends BeerPostR
|
|||||||
next: NextHandler,
|
next: NextHandler,
|
||||||
) => {
|
) => {
|
||||||
const { user, query } = req;
|
const { user, query } = req;
|
||||||
const { id } = query;
|
const { postId } = query;
|
||||||
|
|
||||||
const beerPost = await getBeerPostById({ beerPostId: id });
|
const beerPost = await getBeerPostById({ beerPostId: postId });
|
||||||
|
|
||||||
if (!beerPost) {
|
if (!beerPost) {
|
||||||
throw new ServerError('Beer post not found', 404);
|
throw new ServerError('Beer post not found', 404);
|
||||||
@@ -47,7 +47,7 @@ export const editBeerPost = async (
|
|||||||
req: EditBeerPostRequest,
|
req: EditBeerPostRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
await editBeerPostByIdService({ beerPostId: req.query.id, body: req.body });
|
await editBeerPostByIdService({ beerPostId: req.query.postId, body: req.body });
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
message: 'Beer post updated successfully',
|
message: 'Beer post updated successfully',
|
||||||
@@ -57,9 +57,9 @@ export const editBeerPost = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const deleteBeerPost = async (req: BeerPostRequest, res: NextApiResponse) => {
|
export const deleteBeerPost = async (req: BeerPostRequest, res: NextApiResponse) => {
|
||||||
const { id } = req.query;
|
const { postId } = req.query;
|
||||||
|
|
||||||
const deleted = await deleteBeerPostByIdService({ beerPostId: id });
|
const deleted = await deleteBeerPostByIdService({ beerPostId: postId });
|
||||||
if (!deleted) {
|
if (!deleted) {
|
||||||
throw new ServerError('Beer post not found', 404);
|
throw new ServerError('Beer post not found', 404);
|
||||||
}
|
}
|
||||||
@@ -75,9 +75,9 @@ export const getBeerPostRecommendations = async (
|
|||||||
req: GetBeerRecommendationsRequest,
|
req: GetBeerRecommendationsRequest,
|
||||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.query;
|
const { postId } = req.query;
|
||||||
|
|
||||||
const beerPost = await getBeerPostById({ beerPostId: id });
|
const beerPost = await getBeerPostById({ beerPostId: postId });
|
||||||
|
|
||||||
if (!beerPost) {
|
if (!beerPost) {
|
||||||
throw new ServerError('Beer post not found', 404);
|
throw new ServerError('Beer post not found', 404);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { NextApiRequest } from 'next';
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
export interface BeerPostRequest extends UserExtendedNextApiRequest {
|
export interface BeerPostRequest extends UserExtendedNextApiRequest {
|
||||||
query: { id: string };
|
query: { postId: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EditBeerPostRequest extends BeerPostRequest {
|
export interface EditBeerPostRequest extends BeerPostRequest {
|
||||||
@@ -17,7 +17,7 @@ export interface GetAllBeerPostsRequest extends NextApiRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface GetBeerRecommendationsRequest extends BeerPostRequest {
|
export interface GetBeerRecommendationsRequest extends BeerPostRequest {
|
||||||
query: { id: string; page_num: string; page_size: string };
|
query: { postId: string; page_num: string; page_size: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateBeerPostRequest extends UserExtendedNextApiRequest {
|
export interface CreateBeerPostRequest extends UserExtendedNextApiRequest {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const useGetBreweryPostLikeCount = (breweryPostId: string) => {
|
|||||||
error: error as unknown,
|
error: error as unknown,
|
||||||
isLoading,
|
isLoading,
|
||||||
mutate,
|
mutate,
|
||||||
likeCount: data as number | undefined,
|
likeCount: data,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,14 +22,16 @@ const router = createRouter<
|
|||||||
|
|
||||||
router
|
router
|
||||||
.delete(
|
.delete(
|
||||||
validateRequest({ querySchema: z.object({ id: z.string().cuid() }) }),
|
validateRequest({
|
||||||
|
querySchema: z.object({ postId: z.string().cuid(), commentId: z.string().cuid() }),
|
||||||
|
}),
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
checkIfBeerCommentOwner,
|
checkIfBeerCommentOwner,
|
||||||
deleteBeerPostComment,
|
deleteBeerPostComment,
|
||||||
)
|
)
|
||||||
.put(
|
.put(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
querySchema: z.object({ id: z.string().cuid() }),
|
querySchema: z.object({ postId: z.string().cuid(), commentId: z.string().cuid() }),
|
||||||
bodySchema: CreateCommentValidationSchema,
|
bodySchema: CreateCommentValidationSchema,
|
||||||
}),
|
}),
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
@@ -22,7 +22,7 @@ const router = createRouter<
|
|||||||
router.post(
|
router.post(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
bodySchema: CreateCommentValidationSchema,
|
bodySchema: CreateCommentValidationSchema,
|
||||||
querySchema: z.object({ id: z.string().cuid() }),
|
querySchema: z.object({ postId: z.string().cuid() }),
|
||||||
}),
|
}),
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
createBeerPostComment,
|
createBeerPostComment,
|
||||||
@@ -30,7 +30,7 @@ router.post(
|
|||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
querySchema: PaginatedQueryResponseSchema.extend({ id: z.string().cuid() }),
|
querySchema: PaginatedQueryResponseSchema.extend({ postId: z.string().cuid() }),
|
||||||
}),
|
}),
|
||||||
getAllBeerPostComments,
|
getAllBeerPostComments,
|
||||||
);
|
);
|
||||||
@@ -26,14 +26,14 @@ router
|
|||||||
.put(
|
.put(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
bodySchema: EditBeerPostValidationSchema,
|
bodySchema: EditBeerPostValidationSchema,
|
||||||
querySchema: z.object({ id: z.string() }),
|
querySchema: z.object({ postId: z.string() }),
|
||||||
}),
|
}),
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
checkIfBeerPostOwner,
|
checkIfBeerPostOwner,
|
||||||
editBeerPost,
|
editBeerPost,
|
||||||
)
|
)
|
||||||
.delete(
|
.delete(
|
||||||
validateRequest({ querySchema: z.object({ id: z.string() }) }),
|
validateRequest({ querySchema: z.object({ postId: z.string() }) }),
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
checkIfBeerPostOwner,
|
checkIfBeerPostOwner,
|
||||||
deleteBeerPost,
|
deleteBeerPost,
|
||||||
@@ -19,12 +19,12 @@ const router = createRouter<
|
|||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
validateRequest({ querySchema: z.object({ id: z.string().cuid() }) }),
|
validateRequest({ querySchema: z.object({ postId: z.string().cuid() }) }),
|
||||||
sendBeerPostLikeRequest,
|
sendBeerPostLikeRequest,
|
||||||
);
|
);
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
validateRequest({ querySchema: z.object({ id: z.string().cuid() }) }),
|
validateRequest({ querySchema: z.object({ postId: z.string().cuid() }) }),
|
||||||
getBeerPostLikeCount,
|
getBeerPostLikeCount,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ const router = createRouter<
|
|||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
validateRequest({ querySchema: z.object({ id: z.string().cuid() }) }),
|
validateRequest({ querySchema: z.object({ postId: z.string().cuid() }) }),
|
||||||
checkIfBeerPostIsLiked,
|
checkIfBeerPostIsLiked,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ const router = createRouter<
|
|||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
querySchema: PaginatedQueryResponseSchema.extend({ id: z.string().cuid() }),
|
querySchema: PaginatedQueryResponseSchema.extend({ postId: z.string().cuid() }),
|
||||||
}),
|
}),
|
||||||
getBeerPostRecommendations,
|
getBeerPostRecommendations,
|
||||||
);
|
);
|
||||||
@@ -19,7 +19,7 @@ const router = createRouter<
|
|||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
querySchema: PaginatedQueryResponseSchema.extend({ id: z.string().cuid() }),
|
querySchema: PaginatedQueryResponseSchema.extend({ postId: z.string().cuid() }),
|
||||||
}),
|
}),
|
||||||
getAllBeersByBeerStyle,
|
getAllBeersByBeerStyle,
|
||||||
);
|
);
|
||||||
@@ -22,7 +22,7 @@ const router = createRouter<
|
|||||||
router
|
router
|
||||||
.delete(
|
.delete(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
querySchema: z.object({ id: z.string().cuid() }),
|
querySchema: z.object({ postId: z.string().cuid(), commentId: z.string().cuid() }),
|
||||||
}),
|
}),
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
checkIfBeerStyleCommentOwner,
|
checkIfBeerStyleCommentOwner,
|
||||||
@@ -30,7 +30,7 @@ router
|
|||||||
)
|
)
|
||||||
.put(
|
.put(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
querySchema: z.object({ id: z.string().cuid() }),
|
querySchema: z.object({ postId: z.string().cuid(), commentId: z.string().cuid() }),
|
||||||
bodySchema: CreateCommentValidationSchema,
|
bodySchema: CreateCommentValidationSchema,
|
||||||
}),
|
}),
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
@@ -19,7 +19,7 @@ const router = createRouter<
|
|||||||
router.post(
|
router.post(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
bodySchema: CreateCommentValidationSchema,
|
bodySchema: CreateCommentValidationSchema,
|
||||||
querySchema: z.object({ id: z.string().cuid() }),
|
querySchema: z.object({ postId: z.string().cuid() }),
|
||||||
}),
|
}),
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
createComment,
|
createComment,
|
||||||
@@ -27,7 +27,7 @@ router.post(
|
|||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
querySchema: PaginatedQueryResponseSchema.extend({ id: z.string().cuid() }),
|
querySchema: PaginatedQueryResponseSchema.extend({ postId: z.string().cuid() }),
|
||||||
}),
|
}),
|
||||||
getAll,
|
getAll,
|
||||||
);
|
);
|
||||||
@@ -13,7 +13,7 @@ const router = createRouter<
|
|||||||
>();
|
>();
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
validateRequest({ querySchema: z.object({ id: z.string().cuid() }) }),
|
validateRequest({ querySchema: z.object({ postId: z.string().cuid() }) }),
|
||||||
getBeerStyle,
|
getBeerStyle,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -20,12 +20,12 @@ const router = createRouter<
|
|||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
validateRequest({ querySchema: z.object({ id: z.string().cuid() }) }),
|
validateRequest({ querySchema: z.object({ postId: z.string().cuid() }) }),
|
||||||
sendBeerStyleLikeRequest,
|
sendBeerStyleLikeRequest,
|
||||||
);
|
);
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
validateRequest({ querySchema: z.object({ id: z.string().cuid() }) }),
|
validateRequest({ querySchema: z.object({ postId: z.string().cuid() }) }),
|
||||||
getBeerStyleLikeCountRequest,
|
getBeerStyleLikeCountRequest,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ const router = createRouter<
|
|||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
validateRequest({ querySchema: z.object({ id: z.string().cuid() }) }),
|
validateRequest({ querySchema: z.object({ postId: z.string().cuid() }) }),
|
||||||
checkIfBeerStyleIsLiked,
|
checkIfBeerStyleIsLiked,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ const router = createRouter<
|
|||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
querySchema: PaginatedQueryResponseSchema.extend({ id: z.string().cuid() }),
|
querySchema: PaginatedQueryResponseSchema.extend({ postId: z.string().cuid() }),
|
||||||
}),
|
}),
|
||||||
getAllBeersByBrewery,
|
getAllBeersByBrewery,
|
||||||
);
|
);
|
||||||
@@ -24,7 +24,7 @@ const router = createRouter<
|
|||||||
router
|
router
|
||||||
.delete(
|
.delete(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
querySchema: z.object({ id: z.string().cuid() }),
|
querySchema: z.object({ commentId: z.string().cuid(), postId: z.string().cuid() }),
|
||||||
}),
|
}),
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
checkIfBreweryCommentOwner,
|
checkIfBreweryCommentOwner,
|
||||||
@@ -32,7 +32,7 @@ router
|
|||||||
)
|
)
|
||||||
.put(
|
.put(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
querySchema: z.object({ id: z.string().cuid() }),
|
querySchema: z.object({ commentId: z.string().cuid(), postId: z.string().cuid() }),
|
||||||
bodySchema: CreateCommentValidationSchema,
|
bodySchema: CreateCommentValidationSchema,
|
||||||
}),
|
}),
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
@@ -20,7 +20,7 @@ const router = createRouter<
|
|||||||
router.post(
|
router.post(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
bodySchema: CreateCommentValidationSchema,
|
bodySchema: CreateCommentValidationSchema,
|
||||||
querySchema: z.object({ id: z.string().cuid() }),
|
querySchema: z.object({ postId: z.string().cuid() }),
|
||||||
}),
|
}),
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
createComment,
|
createComment,
|
||||||
@@ -28,7 +28,7 @@ router.post(
|
|||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
validateRequest({
|
validateRequest({
|
||||||
querySchema: PaginatedQueryResponseSchema.extend({ id: z.string().cuid() }),
|
querySchema: PaginatedQueryResponseSchema.extend({ postId: z.string().cuid() }),
|
||||||
}),
|
}),
|
||||||
getAll,
|
getAll,
|
||||||
);
|
);
|
||||||
@@ -19,12 +19,12 @@ const router = createRouter<
|
|||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
validateRequest({ querySchema: z.object({ id: z.string().cuid() }) }),
|
validateRequest({ querySchema: z.object({ postId: z.string().cuid() }) }),
|
||||||
sendBreweryPostLikeRequest,
|
sendBreweryPostLikeRequest,
|
||||||
);
|
);
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
validateRequest({ querySchema: z.object({ id: z.string().cuid() }) }),
|
validateRequest({ querySchema: z.object({ postId: z.string().cuid() }) }),
|
||||||
getBreweryPostLikeCount,
|
getBreweryPostLikeCount,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -16,11 +16,7 @@ const router = createRouter<
|
|||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
getCurrentUser,
|
getCurrentUser,
|
||||||
validateRequest({
|
validateRequest({ querySchema: z.object({ postId: z.string().cuid() }) }),
|
||||||
querySchema: z.object({
|
|
||||||
id: z.string().cuid(),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
getBreweryPostLikeStatus,
|
getBreweryPostLikeStatus,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -9,8 +9,9 @@ import {
|
|||||||
export const editBeerPostCommentRequest: SendEditBeerPostCommentRequest = async ({
|
export const editBeerPostCommentRequest: SendEditBeerPostCommentRequest = async ({
|
||||||
body,
|
body,
|
||||||
commentId,
|
commentId,
|
||||||
|
beerPostId,
|
||||||
}) => {
|
}) => {
|
||||||
const response = await fetch(`/api/beer-post-comments/${commentId}`, {
|
const response = await fetch(`/api/beers/${beerPostId}/comments/${commentId}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
@@ -33,8 +34,9 @@ export const editBeerPostCommentRequest: SendEditBeerPostCommentRequest = async
|
|||||||
|
|
||||||
export const deleteBeerPostCommentRequest: SendDeleteBeerPostCommentRequest = async ({
|
export const deleteBeerPostCommentRequest: SendDeleteBeerPostCommentRequest = async ({
|
||||||
commentId,
|
commentId,
|
||||||
|
beerPostId,
|
||||||
}) => {
|
}) => {
|
||||||
const response = await fetch(`/api/beer-post-comments/${commentId}`, {
|
const response = await fetch(`/api/beers/${beerPostId}/comments/${commentId}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import { z } from 'zod';
|
|||||||
export type SendEditBeerPostCommentRequest = (args: {
|
export type SendEditBeerPostCommentRequest = (args: {
|
||||||
body: { content: string; rating: number };
|
body: { content: string; rating: number };
|
||||||
commentId: string;
|
commentId: string;
|
||||||
|
beerPostId: string;
|
||||||
}) => Promise<z.infer<typeof APIResponseValidationSchema>>;
|
}) => Promise<z.infer<typeof APIResponseValidationSchema>>;
|
||||||
|
|
||||||
export type SendDeleteBeerPostCommentRequest = (args: {
|
export type SendDeleteBeerPostCommentRequest = (args: {
|
||||||
commentId: string;
|
commentId: string;
|
||||||
|
beerPostId: string;
|
||||||
}) => Promise<z.infer<typeof APIResponseValidationSchema>>;
|
}) => Promise<z.infer<typeof APIResponseValidationSchema>>;
|
||||||
|
|
||||||
export type SendCreateBeerCommentRequest = (args: {
|
export type SendCreateBeerCommentRequest = (args: {
|
||||||
|
|||||||
Reference in New Issue
Block a user