|
1 | | -import {useState} from "react"; |
2 | | -import {useTranslation} from "react-i18next"; |
3 | | -import {Dialog} from "components/Dialog"; |
4 | | -import {useNavigate} from "react-router"; |
5 | | -import {useAppDispatch, useAppSelector} from "store"; |
6 | | -import {Toggle} from "components/Toggle"; |
7 | | -import {getNumberFromStorage, saveToStorage, getFromStorage} from "utils/storage"; |
8 | | -import {CUMULATIVE_VOTING_DEFAULT_STORAGE_KEY, CUSTOM_NUMBER_OF_VOTES_STORAGE_KEY} from "constants/storage"; |
9 | | -import {PlusIcon, MinusIcon} from "components/Icon"; |
| 1 | +import { useState } from "react"; |
| 2 | +import { useTranslation } from "react-i18next"; |
| 3 | +import { Dialog } from "components/Dialog"; |
| 4 | +import { useNavigate } from "react-router"; |
| 5 | +import { useAppDispatch, useAppSelector } from "store"; |
| 6 | +import { Toggle } from "components/Toggle"; |
| 7 | +import { getNumberFromStorage, saveToStorage, getFromStorage } from "utils/storage"; |
| 8 | +import { CUMULATIVE_VOTING_DEFAULT_STORAGE_KEY, CUSTOM_NUMBER_OF_VOTES_STORAGE_KEY } from "constants/storage"; |
| 9 | +import { PlusIcon, MinusIcon } from "components/Icon"; |
10 | 10 | import "./VotingDialog.scss"; |
11 | | -import {closeVoting, createVoting} from "store/features"; |
| 11 | +import { closeVoting, createVoting, cancelVoting } from "store/features"; |
12 | 12 |
|
13 | 13 | export const VotingDialog = () => { |
14 | 14 | const dispatch = useAppDispatch(); |
15 | | - const {t} = useTranslation(); |
| 15 | + const { t } = useTranslation(); |
16 | 16 | const navigate = useNavigate(); |
17 | 17 | const isAdmin = useAppSelector((state) => state.participants?.self?.role === "OWNER" || state.participants?.self?.role === "MODERATOR"); |
18 | 18 | const voting = useAppSelector((state) => state.votings.open?.id); |
@@ -46,12 +46,23 @@ export const VotingDialog = () => { |
46 | 46 | navigate(".."); |
47 | 47 | }; |
48 | 48 |
|
| 49 | + const abortVoting = () => { |
| 50 | + dispatch(cancelVoting(voting!)); |
| 51 | + navigate(".."); |
| 52 | + } |
| 53 | + |
49 | 54 | return ( |
50 | 55 | <Dialog className="voting-dialog accent-color__planning-pink" title={t("VoteConfigurationButton.label")} onClose={() => navigate("..")}> |
51 | 56 | {voting ? ( |
52 | | - <button className="voting-dialog__start-button" data-testid="voting-dialog__stop-button" onClick={() => stopVoting()}> |
53 | | - <label>{t("VoteConfigurationButton.stopVoting")}</label> |
54 | | - </button> |
| 57 | + <> |
| 58 | + <button className="voting-dialog__start-button" data-testid="voting-dialog__stop-button" onClick={() => stopVoting()}> |
| 59 | + <label>{t("VoteConfigurationButton.stopVoting")}</label> |
| 60 | + </button> |
| 61 | + |
| 62 | + <button className="voting-dialog__start-button voting-dialog__cancel-button" data-testid="voting-dialog__cancel-button" onClick={() => abortVoting()}> |
| 63 | + <label>{t("VoteConfigurationButton.cancelVoting")}</label> |
| 64 | + </button> |
| 65 | + </> |
55 | 66 | ) : ( |
56 | 67 | <> |
57 | 68 | <button |
|
0 commit comments