mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Add custom hooks for time distance and retrieving like count
Documentation added to all custom hooks
This commit is contained in:
@@ -4,6 +4,17 @@ import { useContext } from 'react';
|
||||
import useSWR from 'swr';
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
* A custom React hook that checks if the current user has liked a beer post by fetching
|
||||
* data from the server.
|
||||
*
|
||||
* @param beerPostId The ID of the beer post to check for likes.
|
||||
* @returns An object containing a boolean indicating if the user has liked the beer post,
|
||||
* an error object if an error occurred during the request, and a boolean indicating if
|
||||
* the request is currently loading.
|
||||
* @throws When the user is not logged in, the server returns an error status code, or if
|
||||
* the response data fails to validate against the expected schema.
|
||||
*/
|
||||
const useCheckIfUserLikesBeerPost = (beerPostId: string) => {
|
||||
const { user } = useContext(UserContext);
|
||||
const { data, error, isLoading, mutate } = useSWR(
|
||||
|
||||
Reference in New Issue
Block a user