feat: cancel voting (frontend) - #6465
Conversation
ab9ee48 to
b93e843
Compare
b07c1ce to
ebf82ab
Compare
| changeVotingStatus: async (board: string, voting: string, status?: string) => { | ||
| try { | ||
| const response = await fetch(`${SERVER_HTTP_URL}/boards/${board}/votings/${voting}`, { | ||
| const options: RequestInit = { | ||
| method: "PUT", | ||
| credentials: "include", | ||
| }); | ||
| }; | ||
|
|
||
| if (typeof status !== "undefined") { | ||
| options.body = JSON.stringify({status}); | ||
| options.headers = {"Content-Type": "application/json"}; | ||
| } | ||
|
|
||
| const response = await fetch(`${SERVER_HTTP_URL}/boards/${board}/votings/${voting}`, options); |
There was a problem hiding this comment.
I think the status should always be set and should not be able to undefined or null. Also use the VotingStatus type
| const abortVoting = () => { | ||
| dispatch(cancelVoting(voting!)); | ||
| navigate(".."); | ||
| } |
There was a problem hiding this comment.
We should be consistent with the naming. Is it now abort or cancel?
b93e843 to
772d388
Compare
ac1ba8d to
619ec6d
Compare
393a10d to
7776c8b
Compare
568dfa4 to
fdd8eee
Compare
| <label>{t("VoteConfigurationButton.stopVoting")}</label> | ||
| </button> | ||
|
|
||
| <button className="voting-dialog__start-button voting-dialog__cancel-button" data-testid="voting-dialog__cancel-button" onClick={() => abort_voting()}> |
There was a problem hiding this comment.
should be "abort" instead of "cancel"
| navigate(".."); | ||
| }; | ||
|
|
||
| const abort_voting = () => { |
There was a problem hiding this comment.
snake case‽ this ain't python
| }, | ||
|
|
||
| changeVotingStatus: async (board: string, voting: string) => { | ||
| changeVotingStatus: async (board: string, voting: string, status?: VotingStatus) => { |
| changeVotingStatus: async (board: string, voting: string, status?: VotingStatus) => { | ||
| try { | ||
| const response = await fetch(`${SERVER_HTTP_URL}/boards/${board}/votings/${voting}`, { | ||
| const options: RequestInit = { |
There was a problem hiding this comment.
I'd prefer the options inline inside the fetch rather than an extra object, since we do it that way in all other places (not to say this is bad, I just want it to be the same if possible)
| method: "PUT", | ||
| credentials: "include", | ||
| }); | ||
| body: JSON.stringify({ status: status }), |
There was a problem hiding this comment.
properties with the same name and value can be shortened like this: {status}
|
|
||
| await retryable( | ||
| () => API.changeVotingStatus(boardId, payload), | ||
| () => API.changeVotingStatus(boardId, payload, "CLOSED"), |
There was a problem hiding this comment.
should be "ABORT(ED)" here also
Description
I implemented a new button right beneath the stop voting button that uses the backend cancel feature to stop the voting without evaluation.
Changelog
Checklist
Visual Changes
Stack created with GitHub Stacks CLI • Give Feedback 💬