From d8bc7ced8db633be24b40774c4107dbaa544a226 Mon Sep 17 00:00:00 2001 From: "D. Ror" Date: Thu, 4 Aug 2022 08:56:58 -0700 Subject: [PATCH] [MergeStep] Convert Save&Continue Button to LoadingButton Prevent clicking button twice --- .../MergeDupStep/MergeDupStepComponent.tsx | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/goals/MergeDupGoal/MergeDupStep/MergeDupStepComponent.tsx b/src/goals/MergeDupGoal/MergeDupStep/MergeDupStepComponent.tsx index fac2e9bb49..fa6fbedb97 100644 --- a/src/goals/MergeDupGoal/MergeDupStep/MergeDupStepComponent.tsx +++ b/src/goals/MergeDupGoal/MergeDupStep/MergeDupStepComponent.tsx @@ -2,6 +2,7 @@ import { Button, Grid, ImageList, Typography } from "@material-ui/core"; import React, { ReactElement } from "react"; import { WithTranslation, withTranslation } from "react-i18next"; +import LoadingButton from "components/Buttons/LoadingButton"; import MergeDragDrop from "goals/MergeDupGoal/MergeDupStep/DragDropComponents/MergeDragDrop"; import theme from "types/theme"; @@ -12,13 +13,27 @@ interface MergeDupStepProps extends WithTranslation { mergeAll: () => Promise; } -class MergeDupStep extends React.Component { +interface MergeDupStepState { + isSaving: boolean; +} + +class MergeDupStep extends React.Component< + MergeDupStepProps, + MergeDupStepState +> { + constructor(props: MergeDupStepProps) { + super(props); + this.state = { isSaving: false }; + } + next(): void { this.props.clearSidebar(); + this.setState({ isSaving: false }); this.props.advanceStep(); } saveContinue(): void { + this.setState({ isSaving: true }); this.props.clearSidebar(); this.props.mergeAll().then(() => this.next()); } @@ -43,16 +58,19 @@ class MergeDupStep extends React.Component { {/* Merge/skip buttons */} - +