-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Voting Pages UI #66
base: master
Are you sure you want to change the base?
Voting Pages UI #66
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
import axios from "axios"; | ||
import { VoteSelection } from "../util/Types"; | ||
|
||
export const createVote = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we turn this into a react query hook instead?
|
||
const createVoteMutation = useMutation({ | ||
mutationFn: async (selectedVote: VoteSelection) => { | ||
return createVote(question.uuid, member_id, selectedVote); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh nvm, i see what's happening here. ignore above comment
}, | ||
onSuccess: () => { | ||
setSubmitted(true); | ||
// TODO: this success should update the voting history query however |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean by this? could we just invalidate the voting history query?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever a vote is successfully created it should update the content on the vote record page ( your vote and submssion). The useMutation can force an endpoint to refresh using invalidate query, so I was trying get the endpoint that fetches the votingHistory to refresh, but adding that in was essentially skipping the confirmation message shown at the end of the vote, which isn't ideal.
queryKey: ["voting", "history", id], | ||
queryFn: async (): Promise<VoteHistory[]> => { | ||
const response = await axios.get<VoteHistory[]>( | ||
`/api/voting/getVotingRecord?id=${id}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we change this a bit to make the endpoint clearer, i.e. getVotingRecordByMemberId
@@ -9,7 +9,7 @@ import reportWebVitals from "./reportWebVitals"; | |||
import { Member } from "./util/Types"; | |||
|
|||
// Create a client | |||
const queryClient = new QueryClient(); | |||
export const queryClient = new QueryClient(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this need to be exported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its needed for the (eventual?) invalidateQuery within the useMutation, i.e queryClient.invalidateQuery(queryKey)
Adds the Voting History Page and Vote Page following the figma styling
I'll post screenshots and what not in a bit