From c4fdc6ed02f97976d65a1c6870be01088387b556 Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Tue, 10 Nov 2020 10:59:07 +0100 Subject: [PATCH] feat: Use Dialog for transfer state modal --- src/ducks/transfers/TransferPage.jsx | 17 ++++--- src/ducks/transfers/TransferPage.spec.jsx | 6 +-- src/ducks/transfers/steps/TransferState.jsx | 55 ++++++++++++--------- src/ducks/transfers/styles.styl | 6 --- 4 files changed, 46 insertions(+), 38 deletions(-) delete mode 100644 src/ducks/transfers/styles.styl diff --git a/src/ducks/transfers/TransferPage.jsx b/src/ducks/transfers/TransferPage.jsx index b2a550d9ad..7ce605c4d9 100644 --- a/src/ducks/transfers/TransferPage.jsx +++ b/src/ducks/transfers/TransferPage.jsx @@ -5,7 +5,7 @@ import { withRouter } from 'react-router' import withBreakpoints from 'cozy-ui/transpiled/react/helpers/withBreakpoints' import Stack from 'cozy-ui/transpiled/react/Stack' -import { translate, Text, Modal, useI18n } from 'cozy-ui/transpiled/react' +import { translate, Text, useI18n } from 'cozy-ui/transpiled/react' import { withClient, queryConnect, @@ -30,8 +30,8 @@ import * as recipientUtils from 'ducks/transfers/recipients' import * as transfers from 'ducks/transfers/transfers' import { - TransferSuccess, - TransferError + TransferSuccessDialog, + TransferErrorDialog } from 'ducks/transfers/steps/TransferState' import ChooseRecipientCategory from 'ducks/transfers/steps/Category' import ChooseBeneficiary from 'ducks/transfers/steps/Beneficiary' @@ -467,15 +467,18 @@ class TransferPage extends React.Component { return ( <> {transferState ? ( - + <> {transferState === 'sending' && } {transferState === 'success' && ( - + )} {transferState instanceof Error && ( - + )} - + ) : null} {showingPersonalInfo ? ( { jest.restoreAllMocks() }) - it('should pass error to TransferError', async () => { + it('should pass error to TransferErrorDialog', async () => { root.instance().setState({ senderAccount: accounts[0], beneficiary: { @@ -77,7 +77,7 @@ describe('transfer page', () => { } catch (e) { // eslint-disable-line no-empty } - const errorView = root.find(TransferError) + const errorView = root.find(TransferErrorDialog) expect(errorView.length).toBe(1) expect(errorView.props().error).toBe(err) }) diff --git a/src/ducks/transfers/steps/TransferState.jsx b/src/ducks/transfers/steps/TransferState.jsx index 8ce6c80507..ca68365380 100644 --- a/src/ducks/transfers/steps/TransferState.jsx +++ b/src/ducks/transfers/steps/TransferState.jsx @@ -1,38 +1,47 @@ import React from 'react' -import Padded from 'components/Spacing/Padded' -import { Text, Button, useI18n } from 'cozy-ui/transpiled/react' +import Button from 'cozy-ui/transpiled/react/Button' +import Typography from 'cozy-ui/transpiled/react/Typography' +import { useI18n } from 'cozy-ui/transpiled/react/I18n' +import { IllustrationDialog } from 'cozy-ui/transpiled/react/CozyDialogs' +import Stack from 'cozy-ui/transpiled/react/Stack' -import styles from 'ducks/transfers/styles.styl' -import Title from 'ducks/transfers/steps/Title' import TransferDoneImg from 'ducks/transfers/steps/TransferDoneImg' import TransferErrorImg from 'ducks/transfers/steps/TransferErrorImg' import { useTrackPage } from 'ducks/tracking/browser' -const TransferState = ({ +const TransferStateDialog = ({ title, description, onClickPrimaryButton, primaryLabel, Img }) => ( - - {title} - {Img} - {description} -