Skip to main content

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.

PropertyTypeDescription
pollDataWidgetResponse | nullThe data for the poll.
hasSelectedOptionbooleanFlag indicating if an option has been selected.
isAddOptionDialogOpenbooleanFlag indicating if the "Add Option" dialog is open.
handleAddOptionDialog(toggle: boolean) => voidFunction to toggle the "Add Option" dialog.
showSubmitVoteButtonbooleanFlag indicating if the submit vote button is shown.
showAddOptionButtonbooleanFlag indicating if the add option button is shown.
resultScreenDialogOpenbooleanFlag indicating if the result screen dialog is open.
setResultScreenDialogOpenFunction(toggle: boolean) => voidFunction to toggle the result screen dialog.
hasMultiOptionSelectMutableRefObject<boolean>Reference to track if multiple options can be selected.
pollResultSelectedTabnumberThe selected tab in the poll results.
setPollResultSelectedTabFunction(tab: number) => voidFunction to set the selected tab in poll results.
totalMultipleOptionsnumberThe total number of multiple options in the poll.
newOptionstringThe new option text input by the user.
setNewOptionFunction(option: string) => voidFunction to set the new option text.
voteDetails{ users: (User undefined)[] } | nullDetails of users who voted.
pollOptionsPollOption[]List of poll options.
handleOptionClick(index: number) => voidFunction to handle option selection.
handleAddOptionSubmit() => voidFunction to submit a newly added option.
submitVoteHandler() => voidFunction to handle the submission of a vote.
totalVotesCountnumberThe total number of votes cast in the poll.
totalMembersVotesnumberThe total number of unique voters.
isEditModebooleanFlag indicating if the poll is in edit mode.
setIsEditModeFunction(toggle: boolean) => voidFunction to toggle edit mode for the poll.
onOptionVoteCountClick(tab: number, toggle: boolean) => voidFunction to handle clicks on option vote counts.
pollReadMoreTappedbooleanFlag indicating if the "Read More" option was tapped.
pollReadMoreTappedFunction() => voidFunction to handle "Read More" taps.
fetchNextPage() => voidFunction to fetch the next page of poll votes.
hasMoreVotesbooleanFlag indicating if more votes are available to load.