Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Voting Pages UI #66

wants to merge 1 commit into from

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

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

@@ -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();
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.

2 participants