Move next js project to archive (#207)

This commit is contained in:
Aaron Po
2026-04-20 02:30:25 -04:00
committed by GitHub
parent 92ec16ce93
commit d47e3ed7f0
347 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema';
/**
* Sends a POST request to the server to like or unlike a beer post.
*
* @param beerPostId The ID of the beer post to like or unlike.
* @returns An object containing a success boolean and a message string.
* @throws An error if the response is not ok or if the API response is invalid.
*/
const sendBeerPostLikeRequest = async (beerPostId: string) => {
const response = await fetch(`/api/beers/${beerPostId}/like`, {
method: 'POST',
});
if (!response.ok) {
throw new Error('Something went wrong.');
}
const data = await response.json();
const parsed = APIResponseValidationSchema.safeParse(data);
if (!parsed.success) {
throw new Error('Invalid API response.');
}
const { success, message } = parsed.data;
return { success, message };
};
export default sendBeerPostLikeRequest;

View File

@@ -0,0 +1,31 @@
import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema';
/**
* Sends a POST request to the server to like or unlike a beer post.
*
* @param beerStyleId The ID of the beer post to like or unlike.
* @returns An object containing a success boolean and a message string.
* @throws An error if the response is not ok or if the API response is invalid.
*/
const sendBeerStyleLikeRequest = async (beerStyleId: string) => {
const response = await fetch(`/api/beers/styles/${beerStyleId}/like`, {
method: 'POST',
});
if (!response.ok) {
throw new Error('Something went wrong.');
}
const data = await response.json();
const parsed = APIResponseValidationSchema.safeParse(data);
if (!parsed.success) {
throw new Error('Invalid API response.');
}
const { success, message } = parsed.data;
return { success, message };
};
export default sendBeerStyleLikeRequest;

View File

@@ -0,0 +1,18 @@
import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema';
const sendBreweryPostLikeRequest = async (breweryPostId: string) => {
const response = await fetch(`/api/breweries/${breweryPostId}/like`, {
method: 'POST',
});
const json = await response.json();
const parsed = APIResponseValidationSchema.safeParse(json);
if (!parsed.success) {
throw new Error('Invalid API response.');
}
return parsed.data;
};
export default sendBreweryPostLikeRequest;