Fix: Avoid showing confirmation dialog on closing spreadsheet import with no changes (#1284)
fix: not showing confirmation dialog on closing with no changes
This commit is contained in:
@ -1,10 +1,13 @@
|
|||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
|
import { useSpreadsheetImportInitialStep } from '@/spreadsheet-import/hooks/useSpreadsheetImportInitialStep';
|
||||||
|
import { useSpreadsheetImportInternal } from '@/spreadsheet-import/hooks/useSpreadsheetImportInternal';
|
||||||
import { ButtonVariant } from '@/ui/button/components/Button';
|
import { ButtonVariant } from '@/ui/button/components/Button';
|
||||||
import { IconButton } from '@/ui/button/components/IconButton';
|
import { IconButton } from '@/ui/button/components/IconButton';
|
||||||
import { useDialog } from '@/ui/dialog/hooks/useDialog';
|
import { useDialog } from '@/ui/dialog/hooks/useDialog';
|
||||||
import { IconX } from '@/ui/icon/index';
|
import { IconX } from '@/ui/icon/index';
|
||||||
|
import { useStepBar } from '@/ui/step-bar/hooks/useStepBar';
|
||||||
|
|
||||||
const StyledCloseButtonContainer = styled.div`
|
const StyledCloseButtonContainer = styled.div`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -24,9 +27,23 @@ type ModalCloseButtonProps = {
|
|||||||
export const ModalCloseButton = ({ onClose }: ModalCloseButtonProps) => {
|
export const ModalCloseButton = ({ onClose }: ModalCloseButtonProps) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
|
const { initialStepState } = useSpreadsheetImportInternal();
|
||||||
|
|
||||||
|
const { initialStep } = useSpreadsheetImportInitialStep(
|
||||||
|
initialStepState?.type,
|
||||||
|
);
|
||||||
|
|
||||||
|
const { activeStep } = useStepBar({
|
||||||
|
initialStep,
|
||||||
|
});
|
||||||
|
|
||||||
const { enqueueDialog } = useDialog();
|
const { enqueueDialog } = useDialog();
|
||||||
|
|
||||||
function handleClose() {
|
function handleClose() {
|
||||||
|
if (activeStep === -1) {
|
||||||
|
onClose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
enqueueDialog({
|
enqueueDialog({
|
||||||
title: 'Exit import flow',
|
title: 'Exit import flow',
|
||||||
message: 'Are you sure? Your current information will not be saved.',
|
message: 'Are you sure? Your current information will not be saved.',
|
||||||
|
|||||||
Reference in New Issue
Block a user