Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
refactor(autopay): add edit mode to settings form
Browse files Browse the repository at this point in the history
  • Loading branch information
korhaliv committed Apr 2, 2019
1 parent 0a5c696 commit f8809c5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
6 changes: 4 additions & 2 deletions renderer/components/Autopay/AutopayCreateForm.js
Expand Up @@ -32,7 +32,7 @@ const AutopayCreateForm = props => {
showNotification,
...rest
} = props

const isEditMode = true
const onSubmit = async values => {
try {
const { limit } = values
Expand All @@ -55,6 +55,8 @@ const AutopayCreateForm = props => {
const front = (
<AutopayCreateSettings
defaultValue={defaultValue}
editMode
isEditMode={isEditMode}
limit={limit}
max={max}
merchantName={merchantName}
Expand Down Expand Up @@ -91,7 +93,7 @@ const AutopayCreateForm = props => {
</Heading.h1>
<Bar my={2} />
</Panel.Header>
<Panel.Body css={{ height: '195px' }}>
<Panel.Body css={{ height: editMode ? '250px' : '195px' }}>
<Spring
native
to={{
Expand Down
28 changes: 26 additions & 2 deletions renderer/components/Autopay/AutopayCreateSettings.js
@@ -1,21 +1,44 @@
import React from 'react'
import PropTypes from 'prop-types'

import styled from 'styled-components'
import { FormattedMessage, injectIntl, intlShape } from 'react-intl'
import { Flex } from 'rebass'

import { CryptoValue, CryptoSelector, FiatValue } from 'containers/UI'
import { Bar, DataRow, Range, Text } from 'components/UI'
import { Bar, DataRow, Range, Text, Toggle } from 'components/UI'
import { Truncate } from 'components/Util'
import messages from './messages'
import AutopayStatus from './AutopayStatus'

const SettingsContainer = styled.div`
position: relative;
left: -50%;
`

const AutopayCreateSettings = ({ min, max, intl, defaultValue, limit, merchantName, pubkey }) => (
const AutopayCreateSettings = ({
min,
max,
intl,
defaultValue,
limit,
merchantName,
pubkey,
isEditMode,
}) => (
<SettingsContainer>
{isEditMode && (
<DataRow
left={intl.formatMessage({ ...messages.autopay_status })}
right={
<Flex>
<Toggle field="isEnabled" id="isEnabled" />
<AutopayStatus ml={2} />
</Flex>
}
/>
)}
<Bar variant="light" />
<DataRow
left={
<>
Expand Down Expand Up @@ -61,6 +84,7 @@ const AutopayCreateSettings = ({ min, max, intl, defaultValue, limit, merchantNa
AutopayCreateSettings.propTypes = {
defaultValue: PropTypes.string.isRequired,
intl: intlShape.isRequired,
isEditMode: PropTypes.bool.isRequired,
limit: PropTypes.string.isRequired,
max: PropTypes.string.isRequired,
merchantName: PropTypes.string.isRequired,
Expand Down
4 changes: 2 additions & 2 deletions renderer/components/Autopay/AutopayStatus.js
Expand Up @@ -6,8 +6,8 @@ import { FormattedMessage, injectIntl } from 'react-intl'
import { Text } from 'components/UI'
import messages from './messages'

const AutopayStatus = ({ fieldState }) => (
<Text>
const AutopayStatus = ({ fieldState, ...rest }) => (
<Text {...rest}>
{
<FormattedMessage
{...(fieldState && fieldState.value
Expand Down

0 comments on commit f8809c5

Please sign in to comment.