From 625a92ca745bd05bb30d206abeeee48e6c21c035 Mon Sep 17 00:00:00 2001 From: olav Date: Thu, 23 Jun 2022 10:29:17 +0200 Subject: [PATCH] refactor: fix instance status modal close button (#1115) * refactor: fix instance status modal close button * refactor: only close the modal on button click --- .../common/InstanceStatus/InstanceStatus.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/frontend/src/component/common/InstanceStatus/InstanceStatus.tsx b/frontend/src/component/common/InstanceStatus/InstanceStatus.tsx index 242d5473f1..4bb3626a65 100644 --- a/frontend/src/component/common/InstanceStatus/InstanceStatus.tsx +++ b/frontend/src/component/common/InstanceStatus/InstanceStatus.tsx @@ -27,6 +27,15 @@ const TrialDialog: VFC = ({ const expired = trialHasExpired(instanceStatus); const [dialogOpen, setDialogOpen] = useState(expired); + const onClose = (event: React.SyntheticEvent, muiCloseReason?: string) => { + if (!muiCloseReason) { + setDialogOpen(false); + if (canExtendTrial(instanceStatus)) { + onExtendTrial().catch(console.error); + } + } + }; + useEffect(() => { setDialogOpen(expired); const interval = setInterval(() => { @@ -49,15 +58,7 @@ const TrialDialog: VFC = ({ navigate('/admin/billing'); setDialogOpen(false); }} - onClose={(_: any, reason?: string) => { - if ( - reason !== 'backdropClick' && - reason !== 'escapeKeyDown' - ) { - onExtendTrial(); - setDialogOpen(false); - } - }} + onClose={onClose} title={`Your free ${instanceStatus.plan} trial has expired!`} >