-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
139 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { | ||
SPACING, | ||
COLORS, | ||
StyledText, | ||
Flex, | ||
DIRECTION_COLUMN, | ||
TYPOGRAPHY, | ||
} from '@opentrons/components' | ||
import { Modal } from '../../molecules/Modal' | ||
import { SmallButton } from '../../atoms/buttons' | ||
|
||
interface ConfirmExitModalProps { | ||
confirmExit: () => void | ||
cancelExit: () => void | ||
} | ||
|
||
export const ConfirmExitModal = (props: ConfirmExitModalProps): JSX.Element => { | ||
const { i18n, t } = useTranslation(['quick_transfer', 'shared']) | ||
|
||
return ( | ||
<Modal | ||
header={{ | ||
title: t('exit_quick_transfer'), | ||
iconName: 'alert-circle', | ||
iconColor: COLORS.yellow50, | ||
}} | ||
> | ||
<Flex | ||
flexDirection={DIRECTION_COLUMN} | ||
gridGap={SPACING.spacing10} | ||
width="100%" | ||
> | ||
<StyledText css={TYPOGRAPHY.bodyTextRegular}> | ||
{t('lose_all_progress')} | ||
</StyledText> | ||
<Flex gridGap={SPACING.spacing8}> | ||
<SmallButton | ||
width="50%" | ||
buttonText={i18n.format(t('shared:cancel'), 'capitalize')} | ||
onClick={props.cancelExit} | ||
/> | ||
<SmallButton | ||
width="50%" | ||
buttonText={i18n.format(t('shared:delete'), 'capitalize')} | ||
onClick={props.confirmExit} | ||
buttonType="alert" | ||
/> | ||
</Flex> | ||
</Flex> | ||
</Modal> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/organisms/QuickTransferFlow/__tests__/ConfirmExitModal.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as React from 'react' | ||
import { fireEvent, screen } from '@testing-library/react' | ||
import { describe, it, expect, afterEach, vi, beforeEach } from 'vitest' | ||
|
||
import { renderWithProviders } from '../../../__testing-utils__' | ||
import { i18n } from '../../../i18n' | ||
import { ConfirmExitModal } from '../ConfirmExitModal' | ||
|
||
const render = (props: React.ComponentProps<typeof ConfirmExitModal>) => { | ||
return renderWithProviders(<ConfirmExitModal {...props} />, { | ||
i18nInstance: i18n, | ||
}) | ||
} | ||
|
||
describe('ConfirmExitModal', () => { | ||
let props: React.ComponentProps<typeof ConfirmExitModal> | ||
|
||
beforeEach(() => { | ||
props = { | ||
confirmExit: vi.fn(), | ||
cancelExit: vi.fn(), | ||
} | ||
}) | ||
afterEach(() => { | ||
vi.resetAllMocks() | ||
}) | ||
|
||
it('renders the create new transfer screen and header', () => { | ||
render(props) | ||
screen.getByText('Exit quick transfer?') | ||
screen.getByText('You will lose all progress on this quick transfer.') | ||
}) | ||
it('renders exit and cancel buttons and they work as expected', () => { | ||
render(props) | ||
const cancelBtn = screen.getByText('Cancel') | ||
fireEvent.click(cancelBtn) | ||
expect(props.cancelExit).toHaveBeenCalled() | ||
const deleteBtn = screen.getByText('Delete') | ||
fireEvent.click(deleteBtn) | ||
expect(props.confirmExit).toHaveBeenCalled() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters