UNPKG

@selfcommunity/react-core

Version:

React Core Components useful for integrating UI Community components (react-ui).

64 lines (63 loc) 1.78 kB
import { CacheStrategies } from '@selfcommunity/utils'; import { SCCommentType, SCContributionType, SCFeedObjectType, SCReactionType, SCVoteType } from '@selfcommunity/types'; interface FetchVoteProps { /** * Id of the contribution object to vote * @default null */ id: number; /** * Type of the contribution object to vote * @default null */ contributionType: SCContributionType; /** * Contribution object to vote * @default null */ contribution?: SCFeedObjectType | SCCommentType | null; /** * onVote callback * @default null */ onVote?: (contribution: SCFeedObjectType | SCCommentType, error: any) => any; /** * Cache strategy * @default CACHE_FIRST * */ cacheStrategy?: CacheStrategies; } /** :::info This custom hook is used to fetch a contribution vote. ::: * @param object * @param object.id * @param object.contribution * @param object.contributionType * @param object.onVote * @param object.cacheStrategy */ export default function useSCFetchVote({ id, contribution, contributionType, onVote, cacheStrategy, }: FetchVoteProps): { isLoading: boolean; isVoting: boolean; handleVote: (reaction?: SCReactionType) => void; reactions: { default: SCReactionType; reactions: SCReactionType[]; isLoading: boolean; }; error: string; handleFetchVoteList: ({ reaction, reset }: { reaction?: SCReactionType; reset?: boolean; }) => void; voteList: SCVoteType[]; isLoadingVoteList: boolean; voteListHasNext: boolean; contributionVoted: boolean; contributionVoteCount: number; contributionReaction: SCReactionType; contributionReactionsCount: any[]; }; export {};