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

prevent multiple button click #48

Merged
merged 2 commits into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pages/poll/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const Create = (): JSX.Element => {
const [pollTitle, setTitle] = useState<string>("");
const [pollDescription, setDescription] = useState<string>("");
const [pollChoices, setChoices] = useState<Choice[]>();
const [disabled, setDisabled] = useState<boolean>(false);
const loggedInUserEmailID = useSelector(
(state: RootState) => state.authReducer.username
);
Expand Down Expand Up @@ -70,6 +71,7 @@ const Create = (): JSX.Element => {
): Promise<void> => {
e.preventDefault();
if (pollTitle && pollChoices && pollChoices?.length > 1) {
setDisabled(true);
const encryptedEmailID = encrypt(loggedInUserEmailID);
const poll: RocketMeetPoll = {
title: pollTitle,
Expand Down Expand Up @@ -143,7 +145,12 @@ const Create = (): JSX.Element => {
<Button
className="rm-primary-button create-poll-btn"
onClick={handleSubmit}
disabled={!pollTitle || !pollChoices || pollChoices?.length < 2}
disabled={
!pollTitle ||
!pollChoices ||
pollChoices?.length < 2 ||
disabled
}
>
Create Poll
</Button>
Expand Down
4 changes: 3 additions & 1 deletion src/components/SubmitChoices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ const SubmitChoices = (props: {
type: "",
msg: "",
});
const [disabled, setDisabled] = useState<boolean>(false);

const handleSubmit = async (
e: React.MouseEvent<HTMLInputElement>
): Promise<void> => {
e.preventDefault();
setDisabled(true);
const voterArgs = {
newVote,
pollid,
Expand All @@ -42,7 +44,7 @@ const SubmitChoices = (props: {
<Button
className="rm-primary-button-small mark-options-btn"
type="submit"
disabled={!newVote.name || newVote.choices.length === 0}
disabled={!newVote.name || newVote.choices.length === 0 || disabled}
onClick={handleSubmit}
>
Mark your availability
Expand Down
4 changes: 3 additions & 1 deletion src/components/SubmitFinalChoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ const SubmitFinalChoice = (props: {
type: "",
msg: "",
});
const [disabled, setDisabled] = useState<boolean>(false);

const token = useSelector((state: RootState) => state.authReducer.token);

const handleSubmit = async (
e: React.MouseEvent<HTMLInputElement>
): Promise<void> => {
e.preventDefault();
setDisabled(true);
const markFinalChoice = {
finalChoice,
open: false,
Expand Down Expand Up @@ -53,7 +55,7 @@ const SubmitFinalChoice = (props: {
<Button
className="rm-primary-button-small mark-options-btn"
type="submit"
disabled={!finalChoice}
disabled={!finalChoice || disabled}
onClick={handleSubmit}
>
Mark final option
Expand Down
1 change: 1 addition & 0 deletions src/components/shareinvite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const Invitation = (props: {
/* added void below( remove this comment at last PR) */
const handleSubmit = async (): Promise<void> => {
/* console.log(emailList); which is also to be removed */

const mailerArgs: MailerPollArgs = {
pollID: pollid,
pollTitle: polltitle,
Expand Down