usePostPoll
Introduction
The usePostPoll
hook is a custom hook that provides functionality to act on a poll conversation in feed. It handles the state and logics and functions required to respond on a poll. This hook simplifies the process of creating custom UI for a poll conversation.
The usePostPoll
hook returns the following properties.
Property | Type | Description |
---|---|---|
pollData | WidgetResponse | null | The data for the poll. |
hasSelectedOption | boolean | Flag indicating if an option has been selected. |
isAddOptionDialogOpen | boolean | Flag indicating if the "Add Option" dialog is open. |
handleAddOptionDialog | (toggle: boolean) => void | Function to toggle the "Add Option" dialog. |
showSubmitVoteButton | boolean | Flag indicating if the submit vote button is shown. |
showAddOptionButton | boolean | Flag indicating if the add option button is shown. |
resultScreenDialogOpen | boolean | Flag indicating if the result screen dialog is open. |
setResultScreenDialogOpenFunction | (toggle: boolean) => void | Function to toggle the result screen dialog. |
hasMultiOptionSelect | MutableRefObject<boolean> | Reference to track if multiple options can be selected. |
pollResultSelectedTab | number | The selected tab in the poll results. |
setPollResultSelectedTabFunction | (tab: number) => void | Function to set the selected tab in poll results. |
totalMultipleOptions | number | The total number of multiple options in the poll. |
newOption | string | The new option text input by the user. |
setNewOptionFunction | (option: string) => void | Function to set the new option text. |
voteDetails | { users: (User undefined)[] } | null | Details of users who voted. |
pollOptions | PollOption[] | List of poll options. |
handleOptionClick | (index: number) => void | Function to handle option selection. |
handleAddOptionSubmit | () => void | Function to submit a newly added option. |
submitVoteHandler | () => void | Function to handle the submission of a vote. |
totalVotesCount | number | The total number of votes cast in the poll. |
totalMembersVotes | number | The total number of unique voters. |
isEditMode | boolean | Flag indicating if the poll is in edit mode. |
setIsEditModeFunction | (toggle: boolean) => void | Function to toggle edit mode for the poll. |
onOptionVoteCountClick | (tab: number, toggle: boolean) => void | Function to handle clicks on option vote counts. |
pollReadMoreTapped | boolean | Flag indicating if the "Read More" option was tapped. |
pollReadMoreTappedFunction | () => void | Function to handle "Read More" taps. |
fetchNextPage | () => void | Function to fetch the next page of poll votes. |
hasMoreVotes | boolean | Flag indicating if more votes are available to load. |