Skip to content

Conversation

@justagoodfriend
Copy link
Contributor

@justagoodfriend justagoodfriend commented Nov 14, 2024

Adds the Voting History Page and Vote Page following the figma styling

I'll post screenshots and what not in a bit

@vercel
Copy link

vercel bot commented Nov 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sga-tooling-cq5m ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 14, 2024 6:57am

import axios from "axios";
import { VoteSelection } from "../util/Types";

export const createVote = async (
Copy link
Contributor

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);
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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}`
Copy link
Contributor

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


// Create a client
const queryClient = new QueryClient();
export const queryClient = new QueryClient();
Copy link
Contributor

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?

Copy link
Contributor Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants