From 357cf4e0ef4483fbbb02c989702a6323ea3b16b0 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Mon, 26 Feb 2018 16:06:30 -0600 Subject: [PATCH] fix(lint): fix all lint errors except a few (will fix the rest after i finish the rest of the modals) --- .eslintrc | 7 +- app/components/Activity/ActivityModal.js | 7 +- app/components/Activity/InvoiceModal.js | 12 +- app/components/Activity/PaymentModal.js | 9 +- app/components/Form/Form.js | 3 +- app/components/Form/Pay.js | 36 +++--- app/components/Form/Request.js | 27 +++-- app/components/Onboarding/FormContainer.js | 8 +- app/components/Onboarding/Onboarding.js | 8 +- app/components/Onboarding/Syncing.js | 4 +- app/components/Value/Value.js | 28 ++--- app/components/Value/index.js | 2 +- app/components/Wallet/Wallet.js | 1 - app/lnd/methods/index.js | 7 +- app/reducers/activity.js | 2 +- app/reducers/invoice.js | 4 +- app/reducers/payform.js | 13 +-- app/reducers/requestform.js | 13 +-- app/reducers/transaction.js | 4 +- app/routes/activity/components/Activity.js | 27 +---- .../components/components/Invoice/Invoice.js | 1 - .../components/Modal/Invoice/Invoice.js | 74 ------------ .../components/Modal/Invoice/Invoice.scss | 106 ------------------ .../components/Modal/Invoice/index.js | 3 - .../components/components/Modal/Modal.js | 63 ----------- .../components/components/Modal/Modal.scss | 27 ----- .../components/Modal/Payment/Payment.js | 52 --------- .../components/Modal/Payment/Payment.scss | 61 ---------- .../components/Modal/Payment/index.js | 3 - .../Modal/Transaction/Transaction.js | 64 ----------- .../Modal/Transaction/Transaction.scss | 72 ------------ .../components/Modal/Transaction/index.js | 3 - .../components/components/Modal/index.js | 3 - .../components/components/Payment/Payment.js | 1 - .../components/Transaction/Transaction.js | 1 - .../activity/containers/ActivityContainer.js | 2 +- app/routes/app/components/App.js | 15 ++- app/routes/app/containers/AppContainer.js | 2 +- app/utils/btc.js | 2 + test/components/Form.spec.js | 12 +- .../Form/{Payform.spec.js => Pay.spec.js} | 14 +-- .../{RequestForm.spec.js => Request.spec.js} | 6 +- test/reducers/form.spec.js | 11 +- 43 files changed, 129 insertions(+), 691 deletions(-) delete mode 100644 app/routes/activity/components/components/Modal/Invoice/Invoice.js delete mode 100644 app/routes/activity/components/components/Modal/Invoice/Invoice.scss delete mode 100644 app/routes/activity/components/components/Modal/Invoice/index.js delete mode 100644 app/routes/activity/components/components/Modal/Modal.js delete mode 100644 app/routes/activity/components/components/Modal/Modal.scss delete mode 100644 app/routes/activity/components/components/Modal/Payment/Payment.js delete mode 100644 app/routes/activity/components/components/Modal/Payment/Payment.scss delete mode 100644 app/routes/activity/components/components/Modal/Payment/index.js delete mode 100644 app/routes/activity/components/components/Modal/Transaction/Transaction.js delete mode 100644 app/routes/activity/components/components/Modal/Transaction/Transaction.scss delete mode 100644 app/routes/activity/components/components/Modal/Transaction/index.js delete mode 100644 app/routes/activity/components/components/Modal/index.js rename test/components/Form/{Payform.spec.js => Pay.spec.js} (80%) rename test/components/Form/{RequestForm.spec.js => Request.spec.js} (74%) diff --git a/.eslintrc b/.eslintrc index b9655a20..483700a6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -40,7 +40,12 @@ "max-len": ["error", 150], "import/no-extraneous-dependencies": 0, "no-new": 0, - "compat/compat": "error" + "compat/compat": "error", + "prefer-destructuring": ["error", { + "array": false, + "object": true + }], + "prefer-promise-reject-errors": 0 }, "plugins": [ "flowtype", diff --git a/app/components/Activity/ActivityModal.js b/app/components/Activity/ActivityModal.js index 12e4661b..e9c500d0 100644 --- a/app/components/Activity/ActivityModal.js +++ b/app/components/Activity/ActivityModal.js @@ -1,12 +1,12 @@ import React from 'react' import PropTypes from 'prop-types' import Isvg from 'react-inlinesvg' +import x from 'icons/x.svg' // import Transaction from './Transaction' import PaymentModal from './PaymentModal' import InvoiceModal from './InvoiceModal' -import x from 'icons/x.svg' import styles from './ActivityModal.scss' const ActivityModal = ({ @@ -27,7 +27,6 @@ const ActivityModal = ({ if (!modalType) { return null } const SpecificModal = MODAL_COMPONENTS[modalType] - console.log('toggleCurrencyProps: ', toggleCurrencyProps) return (
@@ -46,6 +45,10 @@ const ActivityModal = ({ } ActivityModal.propTypes = { + ticker: PropTypes.object.isRequired, + currentTicker: PropTypes.object.isRequired, + toggleCurrencyProps: PropTypes.object.isRequired, + modalType: PropTypes.string, modalProps: PropTypes.object.isRequired, hideActivityModal: PropTypes.func.isRequired diff --git a/app/components/Activity/InvoiceModal.js b/app/components/Activity/InvoiceModal.js index 109d78ba..c62b541a 100644 --- a/app/components/Activity/InvoiceModal.js +++ b/app/components/Activity/InvoiceModal.js @@ -10,12 +10,10 @@ import { showNotification } from 'notifications' import { FaAngleDown } from 'react-icons/lib/fa' -import { btc } from 'utils' import Value from 'components/Value' import styles from './InvoiceModal.scss' - const InvoiceModal = ({ invoice, ticker, @@ -59,8 +57,7 @@ const InvoiceModal = ({
    { currentCurrencyFilters.map(filter => -
  • onCurrencyFilterClick(filter.key)}>{filter.name}
  • - ) +
  • onCurrencyFilterClick(filter.key)}>{filter.name}
  • ) }
@@ -88,14 +85,17 @@ const InvoiceModal = ({
Save as image
-
Copy Request
+
Copy Request
) } InvoiceModal.propTypes = { - invoice: PropTypes.object.isRequired + invoice: PropTypes.object.isRequired, + ticker: PropTypes.object.isRequired, + currentTicker: PropTypes.object.isRequired, + toggleCurrencyProps: PropTypes.object.isRequired } export default InvoiceModal diff --git a/app/components/Activity/PaymentModal.js b/app/components/Activity/PaymentModal.js index 3e738b08..2687cdec 100644 --- a/app/components/Activity/PaymentModal.js +++ b/app/components/Activity/PaymentModal.js @@ -6,12 +6,10 @@ import 'moment-timezone' import { FaAngleDown } from 'react-icons/lib/fa' -import { btc } from 'utils' import Value from 'components/Value' import styles from './PaymentModal.scss' - const PaymentModal = ({ payment, ticker, @@ -28,9 +26,7 @@ const PaymentModal = ({ return (
-
- -
+
@@ -43,8 +39,7 @@ const PaymentModal = ({
    { currentCurrencyFilters.map(filter => -
  • onCurrencyFilterClick(filter.key)}>{filter.name}
  • - ) +
  • onCurrencyFilterClick(filter.key)}>{filter.name}
  • ) }
diff --git a/app/components/Form/Form.js b/app/components/Form/Form.js index 14c3f902..9346fbd5 100644 --- a/app/components/Form/Form.js +++ b/app/components/Form/Form.js @@ -2,12 +2,11 @@ import React from 'react' import PropTypes from 'prop-types' import Isvg from 'react-inlinesvg' -import { MdClose } from 'react-icons/lib/md' +import x from 'icons/x.svg' import Pay from './Pay' import Request from './Request' -import x from 'icons/x.svg' import styles from './Form.scss' const FORM_TYPES = { diff --git a/app/components/Form/Pay.js b/app/components/Form/Pay.js index 4650215b..67ba87c6 100644 --- a/app/components/Form/Pay.js +++ b/app/components/Form/Pay.js @@ -9,7 +9,6 @@ import { FaAngleDown } from 'react-icons/lib/fa' import { btc } from 'utils' import LoadingBolt from 'components/LoadingBolt' -import CurrencyIcon from 'components/CurrencyIcon' import styles from './Pay.scss' @@ -30,9 +29,12 @@ class Pay extends Component { render() { const { - payform: { amount, payInput, showErrors, invoice, showCurrencyFilters }, - currency, - crypto, + payform: { + payInput, + showErrors, + invoice, + showCurrencyFilters + }, nodes, ticker, @@ -40,10 +42,8 @@ class Pay extends Component { isLn, currentAmount, usdAmount, - inputCaption, showPayLoadingScreen, payFormIsValid: { errors, isValid }, - payInputMin, currentCurrencyFilters, currencyName, @@ -70,7 +70,7 @@ class Pay extends Component { const onCurrencyFilterClick = (currency) => { if (!isLn) { - // change the input amount + // change the input amount setPayAmount(btc.convert(ticker.currency, currency, currentAmount)) } @@ -122,7 +122,7 @@ class Pay extends Component {
- +
{ currentCurrencyFilters.map(filter => -
  • onCurrencyFilterClick(filter.key)}>{filter.name}
  • - ) +
  • onCurrencyFilterClick(filter.key)}>{filter.name}
  • ) }
    @@ -175,8 +174,7 @@ Pay.propTypes = { payInput: PropTypes.string.isRequired, showErrors: PropTypes.object.isRequired }).isRequired, - currency: PropTypes.string.isRequired, - crypto: PropTypes.string.isRequired, + currencyName: PropTypes.string.isRequired, isOnchain: PropTypes.bool.isRequired, isLn: PropTypes.bool.isRequired, @@ -184,7 +182,10 @@ Pay.propTypes = { PropTypes.string, PropTypes.number ]), - inputCaption: PropTypes.string.isRequired, + usdAmount: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number + ]), showPayLoadingScreen: PropTypes.bool.isRequired, payFormIsValid: PropTypes.shape({ errors: PropTypes.object, @@ -197,7 +198,14 @@ Pay.propTypes = { onPayInputBlur: PropTypes.func.isRequired, fetchInvoice: PropTypes.func.isRequired, - onPaySubmit: PropTypes.func.isRequired + onPaySubmit: PropTypes.func.isRequired, + setCurrencyFilters: PropTypes.func.isRequired, + setCurrency: PropTypes.func.isRequired, + + ticker: PropTypes.object.isRequired, + + nodes: PropTypes.array.isRequired, + currentCurrencyFilters: PropTypes.array.isRequired } export default Pay diff --git a/app/components/Form/Request.js b/app/components/Form/Request.js index 8e2aa2b7..ee4ba09c 100644 --- a/app/components/Form/Request.js +++ b/app/components/Form/Request.js @@ -6,7 +6,6 @@ import hand from 'icons/hand.svg' import { FaAngleDown } from 'react-icons/lib/fa' import { btc } from 'utils' -import CurrencyIcon from 'components/CurrencyIcon' import styles from './Request.scss' const Request = ({ @@ -24,9 +23,8 @@ const Request = ({ onRequestSubmit }) => { - console.log('requestUsdAmount: ', requestUsdAmount) const onCurrencyFilterClick = (currency) => { - // change the input amount + // change the input amount setRequestAmount(btc.convert(ticker.currency, currency, amount)) setCurrency(currency) @@ -59,7 +57,7 @@ const Request = ({
    - +
    { currentCurrencyFilters.map(filter => -
  • onCurrencyFilterClick(filter.key)}>{filter.name}
  • - ) +
  • onCurrencyFilterClick(filter.key)}>{filter.name}
  • ) }
    @@ -100,14 +97,28 @@ const Request = ({ Request.propTypes = { requestform: PropTypes.shape({ - amount: PropTypes.string, + amount: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number + ]), memo: PropTypes.string }).isRequired, + requestUsdAmount: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number + ]), + currencyName: PropTypes.string.isRequired, + + currentCurrencyFilters: PropTypes.array.isRequired, + setRequestAmount: PropTypes.func.isRequired, setRequestMemo: PropTypes.func.isRequired, + onRequestSubmit: PropTypes.func.isRequired, + setCurrency: PropTypes.func.isRequired, + setRequestCurrencyFilters: PropTypes.func.isRequired, - onRequestSubmit: PropTypes.func.isRequired + ticker: PropTypes.object.isRequired } export default Request diff --git a/app/components/Onboarding/FormContainer.js b/app/components/Onboarding/FormContainer.js index c026d21d..e0df1517 100644 --- a/app/components/Onboarding/FormContainer.js +++ b/app/components/Onboarding/FormContainer.js @@ -7,7 +7,13 @@ import { FaAngleLeft, FaAngleRight } from 'react-icons/lib/fa' import zapLogo from 'icons/zap_logo.svg' import styles from './FormContainer.scss' -const FormContainer = ({ title, description, back, next, children }) => ( +const FormContainer = ({ + title, + description, + back, + next, + children +}) => (
    diff --git a/app/components/Onboarding/Onboarding.js b/app/components/Onboarding/Onboarding.js index 4c10d797..a508ab64 100644 --- a/app/components/Onboarding/Onboarding.js +++ b/app/components/Onboarding/Onboarding.js @@ -24,8 +24,8 @@ const Onboarding = ({ case 1: return ( changeStep(2)} > @@ -35,8 +35,8 @@ const Onboarding = ({ case 2: return ( changeStep(1)} next={() => submit(alias, autopilot)} > diff --git a/app/components/Onboarding/Syncing.js b/app/components/Onboarding/Syncing.js index 6426e6ae..05ea630c 100644 --- a/app/components/Onboarding/Syncing.js +++ b/app/components/Onboarding/Syncing.js @@ -24,9 +24,9 @@ class Syncing extends Component {

    Syncing to the blockchain...

    -
    +
    -

    {isNaN(parseInt(syncPercentage, 10)) || syncPercentage.toString().length === 0 ? '' : `${syncPercentage}%`}

    +

    {Number.isNaN(parseInt(syncPercentage, 10)) || syncPercentage.toString().length === 0 ? '' : `${syncPercentage}%`}

    diff --git a/app/components/Value/Value.js b/app/components/Value/Value.js index d711335e..e87a2df9 100644 --- a/app/components/Value/Value.js +++ b/app/components/Value/Value.js @@ -2,29 +2,15 @@ import React from 'react' import PropTypes from 'prop-types' import { btc } from 'utils' -const Value = ({ value, currency, currentTicker }) => { - const renderValue = () => { - switch (currency) { - case 'btc': - return btc.satoshisToBtc(value) - case 'bits': - return btc.satoshisToBits(value) - case 'sats': - return value - case 'usd': - return btc.satoshisToUsd(value, currentTicker.price_usd) - default: - return value - } - } - - return ( - {renderValue()} - ) -} +const Value = ({ value, currency, currentTicker }) => ({btc.convert('sats', currency, value, currentTicker.price_usd)}) Value.propTypes = { - + value: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number + ]).isRequired, + currency: PropTypes.string.isRequired, + currentTicker: PropTypes.object.isRequired } export default Value diff --git a/app/components/Value/index.js b/app/components/Value/index.js index bc42655d..4e1ecc82 100644 --- a/app/components/Value/index.js +++ b/app/components/Value/index.js @@ -1,3 +1,3 @@ import Value from './Value' -export default Value \ No newline at end of file +export default Value diff --git a/app/components/Wallet/Wallet.js b/app/components/Wallet/Wallet.js index f5378d27..f6f9f56a 100644 --- a/app/components/Wallet/Wallet.js +++ b/app/components/Wallet/Wallet.js @@ -23,7 +23,6 @@ class Wallet extends Component { render() { const { - setCurrency, balance, address, info, diff --git a/app/lnd/methods/index.js b/app/lnd/methods/index.js index eb238e8b..04043308 100644 --- a/app/lnd/methods/index.js +++ b/app/lnd/methods/index.js @@ -47,11 +47,8 @@ export default function (lnd, meta, event, msg, data) { networkController.queryRoutes(lnd, meta, { pubkey: invoiceData.destination, amount: invoiceData.num_satoshis - }) - ) - .then(routes => - event.sender.send('receiveInvoiceAndQueryRoutes', routes) - ) + })) + .then(routes => event.sender.send('receiveInvoiceAndQueryRoutes', routes)) .catch(error => console.log('getInvoiceAndQueryRoutes invoice error: ', error)) break case 'newaddress': diff --git a/app/reducers/activity.js b/app/reducers/activity.js index 8a6a8bde..518da898 100644 --- a/app/reducers/activity.js +++ b/app/reducers/activity.js @@ -87,7 +87,7 @@ const ACTION_HANDLERS = { [HIDE_ACTIVITY_MODAL]: state => ({ ...state, modal: { modalType: null, modalProps: {} } }), [CHANGE_FILTER]: (state, { filter }) => ({ ...state, filter, filterPulldown: false }), [TOGGLE_PULLDOWN]: state => ({ ...state, filterPulldown: !state.filterPulldown }), - + [SET_ACTIVITY_MODAL_CURRENCY_FILTERS]: (state, { showCurrencyFilters }) => ( { ...state, modal: { modalType: state.modal.modalType, modalProps: state.modal.modalProps, showCurrencyFilters } } ), diff --git a/app/reducers/invoice.js b/app/reducers/invoice.js index cb493cca..89dcd60c 100644 --- a/app/reducers/invoice.js +++ b/app/reducers/invoice.js @@ -10,7 +10,7 @@ import { resetRequestForm } from './requestform' import { setError } from './error' import { showNotification } from '../notifications' -import { btc, usd } from '../utils' +import { btc } from '../utils' // ------------------------------------ // Constants // ------------------------------------ @@ -96,7 +96,7 @@ export const fetchInvoices = () => (dispatch) => { export const receiveInvoices = (event, { invoices }) => dispatch => dispatch({ type: RECEIVE_INVOICES, invoices }) // Send IPC event for creating an invoice -export const createInvoice = (amount, memo, currency, rate) => (dispatch) => { +export const createInvoice = (amount, memo, currency) => (dispatch) => { // backend needs value in satoshis no matter what currency we are using const value = btc.convert(currency, 'sats', amount) diff --git a/app/reducers/payform.js b/app/reducers/payform.js index 4998323d..5c7c155c 100644 --- a/app/reducers/payform.js +++ b/app/reducers/payform.js @@ -164,7 +164,6 @@ payFormSelectors.currentAmount = createSelector( return invoice.num_satoshis default: return invoice.num_satoshis - } } @@ -185,17 +184,7 @@ payFormSelectors.usdAmount = createSelector( return btc.satoshisToUsd((invoice.num_satoshis || 0), ticker.price_usd) } - switch (currency) { - case 'btc': - return btc.btcToUsd(amount, ticker.price_usd) - case 'bits': - return btc.bitsToUsd(amount, ticker.price_usd) - case 'sats': - return btc.satoshisToUsd(amount, ticker.price_usd) - default: - return '' - - } + return btc.convert(currency, 'usd', amount, ticker.price_usd) } ) diff --git a/app/reducers/requestform.js b/app/reducers/requestform.js index 780a9cf4..2309219d 100644 --- a/app/reducers/requestform.js +++ b/app/reducers/requestform.js @@ -68,20 +68,11 @@ requestFormSelectors.usdAmount = createSelector( requestAmountSelector, currencySelector, tickerSelectors.currentTicker, - + (amount, currency, ticker) => { if (!ticker || !ticker.price_usd) { return false } - switch (currency) { - case 'btc': - return btc.btcToUsd(amount, ticker.price_usd) - case 'bits': - return btc.bitsToUsd(amount, ticker.price_usd) - case 'sats': - return btc.satoshisToUsd(amount, ticker.price_usd) - default: - return '' - } + return btc.convert(currency, 'usd', amount, ticker.price_usd) } ) diff --git a/app/reducers/transaction.js b/app/reducers/transaction.js index 2a588803..435afd7e 100644 --- a/app/reducers/transaction.js +++ b/app/reducers/transaction.js @@ -1,6 +1,6 @@ import { ipcRenderer } from 'electron' import { showNotification } from '../notifications' -import { btc, usd } from '../utils' +import { btc } from '../utils' import { newAddress } from './address' import { fetchBalance } from './balance' import { setFormType } from './form' @@ -46,7 +46,7 @@ export const fetchTransactions = () => (dispatch) => { export const receiveTransactions = (event, { transactions }) => dispatch => dispatch({ type: RECEIVE_TRANSACTIONS, transactions }) export const sendCoins = ({ - value, addr, currency, rate + value, addr, currency }) => (dispatch) => { // backend needs amount in satoshis no matter what currency we are using const amount = btc.convert(currency, 'sats', value) diff --git a/app/routes/activity/components/Activity.js b/app/routes/activity/components/Activity.js index c0229b7c..a4243e75 100644 --- a/app/routes/activity/components/Activity.js +++ b/app/routes/activity/components/Activity.js @@ -7,8 +7,6 @@ import Invoice from './components/Invoice' import Payment from './components/Payment' import Transaction from './components/Transaction' -import Modal from './components/Modal' - import styles from './Activity.scss' class Activity extends Component { @@ -44,18 +42,16 @@ class Activity extends Component { render() { const { - ticker, invoice: { invoiceLoading }, - address: { address }, balance, - info, payment: { paymentLoading }, - currentTicker, - activity: { modal, filters, filter, filterPulldown }, - hideActivityModal, + activity: { + filters, + filter, + filterPulldown + }, changeFilter, currentActivity, - newAddress, walletProps } = this.props @@ -66,14 +62,6 @@ class Activity extends Component { return (
    - -
    @@ -119,15 +107,12 @@ Activity.propTypes = { currentTicker: PropTypes.object.isRequired, showActivityModal: PropTypes.func.isRequired, - hideActivityModal: PropTypes.func.isRequired, changeFilter: PropTypes.func.isRequired, - newAddress: PropTypes.func.isRequired, activity: PropTypes.object.isRequired, currentActivity: PropTypes.array.isRequired, - address: PropTypes.object.isRequired, balance: PropTypes.object.isRequired, - info: PropTypes.object.isRequired + walletProps: PropTypes.object.isRequired } export default Activity diff --git a/app/routes/activity/components/components/Invoice/Invoice.js b/app/routes/activity/components/components/Invoice/Invoice.js index b356837f..c4da0efe 100644 --- a/app/routes/activity/components/components/Invoice/Invoice.js +++ b/app/routes/activity/components/components/Invoice/Invoice.js @@ -4,7 +4,6 @@ import Moment from 'react-moment' import 'moment-timezone' import Isvg from 'react-inlinesvg' import { FaBolt } from 'react-icons/lib/fa' -import { btc } from 'utils' import Value from 'components/Value' import checkmarkIcon from 'icons/check_circle.svg' import clockIcon from 'icons/clock.svg' diff --git a/app/routes/activity/components/components/Modal/Invoice/Invoice.js b/app/routes/activity/components/components/Modal/Invoice/Invoice.js deleted file mode 100644 index c8d06b8b..00000000 --- a/app/routes/activity/components/components/Modal/Invoice/Invoice.js +++ /dev/null @@ -1,74 +0,0 @@ -import React from 'react' -import PropTypes from 'prop-types' - -import Moment from 'react-moment' -import 'moment-timezone' - -import QRCode from 'qrcode.react' -import copy from 'copy-to-clipboard' -import { showNotification } from 'notifications' - -import { FaCircle, FaCopy } from 'react-icons/lib/fa' - -import { btc } from 'utils' - -import styles from './Invoice.scss' - - -const Invoice = ({ invoice, ticker, currentTicker }) => { - const copyPaymentRequest = () => { - copy(invoice.payment_request) - showNotification('Noice', 'Successfully copied to clipboard') - } - - return ( -
    -
    - { - !invoice.settled && -

    - - Not Paid -

    - } -
    -
    -

    {invoice.memo}

    -

    - - { - ticker.currency === 'usd' ? - btc.satoshisToUsd(invoice.value, currentTicker.price_usd) - : - btc.satoshisToBtc(invoice.value) - } - - BTC -

    -
    -
    - -
    -
    -

    - {invoice.payment_request} - - - -

    -
    -

    - Created on - {invoice.creation_date * 1000} -

    -
    - ) -} - -Invoice.propTypes = { - invoice: PropTypes.object.isRequired, - ticker: PropTypes.object.isRequired, - currentTicker: PropTypes.object.isRequired -} - -export default Invoice diff --git a/app/routes/activity/components/components/Modal/Invoice/Invoice.scss b/app/routes/activity/components/components/Modal/Invoice/Invoice.scss deleted file mode 100644 index 6efc1869..00000000 --- a/app/routes/activity/components/components/Modal/Invoice/Invoice.scss +++ /dev/null @@ -1,106 +0,0 @@ -@import '../../../../../../variables.scss'; - -.container { - .settled { - position: absolute; - top: 0; - padding: 10px 0 10px 40px; - color: $darkestgrey; - - svg { - line-height: 20px; - font-size: 10px; - vertical-align: middle; - } - - span { - font-size: 12px; - margin-left: 5px; - } - } - - header { - background: $lightgrey; - padding-bottom: 20px; - } - - h3 { - font-size: 20px; - color: $black; - font-weight: bold; - padding: 10px 40px; - } - - h1 { - color: $main; - padding: 10px 40px; - - .value { - font-size: 30px; - } - - i { - margin-left: 2px; - vertical-align: top; - } - } - - .qrcode { - text-align: center; - margin-top: 40px; - - } - - .input { - padding: 10px 40px; - .paymentRequest { - text-align: center; - font-size: 12px; - padding: 15px; - background: $lightgrey; - border: 1px solid transparent; - display: block; - width: 90%; - margin: 20px auto 0 auto; - } - } - - .date { - text-align: center; - padding-bottom: 40px; - margin-top: 20px; - - time { - margin-left: 3px; - } - } - - .invoiceAddress { - display: flex; - flex-direction: row; - font-family: 'Roboto'; - font-size: 14px; - font-weight: 200; - background: $lightgrey; - - span { - padding: 15px; - } - - span:nth-child(1) { - flex: 9; - overflow-x: scroll; - } - - span:nth-child(2) { - background: $darkgrey; - color: $black; - cursor: pointer; - transition: all 0.25s; - - &:hover { - background: $darkestgrey; - } - } - } -} \ No newline at end of file diff --git a/app/routes/activity/components/components/Modal/Invoice/index.js b/app/routes/activity/components/components/Modal/Invoice/index.js deleted file mode 100644 index 31b99355..00000000 --- a/app/routes/activity/components/components/Modal/Invoice/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import Invoice from './Invoice' - -export default Invoice diff --git a/app/routes/activity/components/components/Modal/Modal.js b/app/routes/activity/components/components/Modal/Modal.js deleted file mode 100644 index 48a31839..00000000 --- a/app/routes/activity/components/components/Modal/Modal.js +++ /dev/null @@ -1,63 +0,0 @@ -import React from 'react' -import PropTypes from 'prop-types' -import ReactModal from 'react-modal' -import { MdClose } from 'react-icons/lib/md' -import Isvg from 'react-inlinesvg' - -import Transaction from './Transaction' -import Payment from './Payment' -import Invoice from './Invoice' - -import x from 'icons/x.svg' -import styles from './Modal.scss' - -const Modal = ({ - modalType, modalProps, hideActivityModal, ticker, currentTicker -}) => { - const MODAL_COMPONENTS = { - TRANSACTION: Transaction, - PAYMENT: Payment, - INVOICE: Invoice - } - - const customStyles = { - overlay: { - cursor: 'pointer' - }, - content: { - top: 'auto', - left: '0', - right: '0', - bottom: 'auto', - width: '40%', - margin: '50px auto', - borderRadius: 'none', - padding: '0' - } - } - - if (!modalType) { return null } - - const SpecificModal = MODAL_COMPONENTS[modalType] - - return ( -
    -
    - hideActivityModal()}> - - -
    - -
    - ) -} - -Modal.propTypes = { - modalType: PropTypes.string, - modalProps: PropTypes.object.isRequired, - hideActivityModal: PropTypes.func.isRequired, - ticker: PropTypes.object.isRequired, - currentTicker: PropTypes.object.isRequired -} - -export default Modal diff --git a/app/routes/activity/components/components/Modal/Modal.scss b/app/routes/activity/components/components/Modal/Modal.scss deleted file mode 100644 index 46f19d56..00000000 --- a/app/routes/activity/components/components/Modal/Modal.scss +++ /dev/null @@ -1,27 +0,0 @@ -@import '../../../../../variables.scss'; - -.container { - position: relative; - height: 100vh; - background: $spaceblue; -} - -.closeContainer { - text-align: right; - padding: 20px 40px 0px; - - span { - cursor: pointer; - opacity: 1.0; - transition: 0.25s all; - - &:hover { - opacity: 0.5; - } - } - - svg { - color: $white; - } -} - diff --git a/app/routes/activity/components/components/Modal/Payment/Payment.js b/app/routes/activity/components/components/Modal/Payment/Payment.js deleted file mode 100644 index 1880be4a..00000000 --- a/app/routes/activity/components/components/Modal/Payment/Payment.js +++ /dev/null @@ -1,52 +0,0 @@ -import React from 'react' -import PropTypes from 'prop-types' - -import Moment from 'react-moment' -import 'moment-timezone' - -import { btc } from 'utils' - -import styles from './Payment.scss' - - -const Payment = ({ payment, ticker, currentTicker }) => ( -
    -
    -
    -

    Sent

    -

    - - { - ticker.currency === 'usd' ? - btc.satoshisToUsd(payment.value, currentTicker.price_usd) - : - btc.satoshisToBtc(payment.value) - } - - - BTC - -

    -
    -

    {payment.payment_hash}

    -
    -
    -
    Fee
    -
    {payment.fee}
    -
    Hops
    -
    {payment.path.length}
    -
    Date
    -
    - {payment.creation_date * 1000} -
    -
    -
    -) - -Payment.propTypes = { - payment: PropTypes.object.isRequired, - ticker: PropTypes.object.isRequired, - currentTicker: PropTypes.object.isRequired -} - -export default Payment diff --git a/app/routes/activity/components/components/Modal/Payment/Payment.scss b/app/routes/activity/components/components/Modal/Payment/Payment.scss deleted file mode 100644 index 6c88b58f..00000000 --- a/app/routes/activity/components/components/Modal/Payment/Payment.scss +++ /dev/null @@ -1,61 +0,0 @@ -@import '../../../../../../variables.scss'; - -.container { - header { - padding: 5px 40px 20px 40px; - background: $lightgrey; - - .title { - display: flex; - flex-direction: row; - margin-bottom: 30px; - - h2 { - text-transform: uppercase; - font-size: 24px; - margin-right: 10px; - } - } - } - - h1 { - color: $main; - - .value { - font-size: 24px; - } - - i { - margin-left: 2px; - vertical-align: top; - } - } - - h3 { - font-size: 14px; - text-align: center; - color: $darkestgrey; - } - - dl { - padding: 40px 40px 40px 40px; - } - - dt { - text-align: left; - float: left; - clear: left; - font-weight: 500; - padding: 20px 35px 19px 0; - color: $black; - font-weight: bold; - } - - dd { - text-align: right; - font-weight: 400; - padding: 30px 0 10px 0; - margin-left: 0; - border-bottom: 1px solid $darkgrey; - } -} \ No newline at end of file diff --git a/app/routes/activity/components/components/Modal/Payment/index.js b/app/routes/activity/components/components/Modal/Payment/index.js deleted file mode 100644 index 3f7e6951..00000000 --- a/app/routes/activity/components/components/Modal/Payment/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import Payment from './Payment' - -export default Payment diff --git a/app/routes/activity/components/components/Modal/Transaction/Transaction.js b/app/routes/activity/components/components/Modal/Transaction/Transaction.js deleted file mode 100644 index b015281a..00000000 --- a/app/routes/activity/components/components/Modal/Transaction/Transaction.js +++ /dev/null @@ -1,64 +0,0 @@ -import React from 'react' -import PropTypes from 'prop-types' - -import Moment from 'react-moment' -import 'moment-timezone' - -import { btc, blockExplorer } from 'utils' - -import styles from './Transaction.scss' - - -const Transaction = ({ transaction, ticker, currentTicker }) => ( -
    -
    -
    -

    - { - transaction.amount < 0 ? - 'Sent' - : - 'Received' - } -

    -

    - - { - ticker.currency === 'usd' ? - btc.satoshisToUsd(transaction.amount, currentTicker.price_usd) - : - btc.satoshisToBtc(transaction.amount) - } - - BTC -

    -
    -

    blockExplorer.showTransaction(transaction.tx_hash)}>{transaction.tx_hash}

    -
    -
    -
    Confirmations
    -
    {transaction.num_confirmations}
    -
    Fee
    -
    - { - ticker.currency === 'usd' ? - btc.satoshisToUsd(transaction.total_fees) - : - btc.satoshisToBtc(transaction.total_fees) - } -
    -
    Date
    -
    - {transaction.time_stamp * 1000} -
    -
    -
    -) - -Transaction.propTypes = { - transaction: PropTypes.object.isRequired, - ticker: PropTypes.object.isRequired, - currentTicker: PropTypes.object.isRequired -} - -export default Transaction diff --git a/app/routes/activity/components/components/Modal/Transaction/Transaction.scss b/app/routes/activity/components/components/Modal/Transaction/Transaction.scss deleted file mode 100644 index f7c3d0ba..00000000 --- a/app/routes/activity/components/components/Modal/Transaction/Transaction.scss +++ /dev/null @@ -1,72 +0,0 @@ -@import '../../../../../../variables.scss'; - -.container { - header { - padding: 5px 40px 20px 40px; - background: $lightgrey; - - .title { - display: flex; - flex-direction: row; - - h2 { - text-transform: uppercase; - } - } - } - - h1 { - text-align: center; - color: $main; - - .value { - font-size: 24px; - } - - i { - margin-left: 2px; - vertical-align: top; - } - } - - h3 { - font-size: 14px; - text-align: center; - color: $darkestgrey; - cursor: pointer; - - &:hover { - text-decoration: underline; - } - } - - h2 { - text-align: center; - margin-right: 10px; - margin-bottom: 30px; - text-transform: uppercase; - font-size: 24px; - } - - dl { - padding: 40px 40px 40px 40px; - } - - dt { - text-align: left; - float: left; - clear: left; - font-weight: 500; - padding: 20px 35px 19px 0; - color: $black; - font-weight: bold; - } - - dd { - text-align: right; - font-weight: 400; - padding: 30px 0 10px 0; - margin-left: 0; - border-bottom: 1px solid $darkgrey; - } -} diff --git a/app/routes/activity/components/components/Modal/Transaction/index.js b/app/routes/activity/components/components/Modal/Transaction/index.js deleted file mode 100644 index 7fc5e311..00000000 --- a/app/routes/activity/components/components/Modal/Transaction/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import Transaction from './Transaction' - -export default Transaction diff --git a/app/routes/activity/components/components/Modal/index.js b/app/routes/activity/components/components/Modal/index.js deleted file mode 100644 index 498702f4..00000000 --- a/app/routes/activity/components/components/Modal/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import Modal from './Modal' - -export default Modal diff --git a/app/routes/activity/components/components/Payment/Payment.js b/app/routes/activity/components/components/Payment/Payment.js index f27ed7bb..97f866b0 100644 --- a/app/routes/activity/components/components/Payment/Payment.js +++ b/app/routes/activity/components/components/Payment/Payment.js @@ -4,7 +4,6 @@ import Moment from 'react-moment' import 'moment-timezone' import Isvg from 'react-inlinesvg' import { FaBolt } from 'react-icons/lib/fa' -import { btc } from 'utils' import Value from 'components/Value' import checkmarkIcon from 'icons/check_circle.svg' import styles from '../Activity.scss' diff --git a/app/routes/activity/components/components/Transaction/Transaction.js b/app/routes/activity/components/components/Transaction/Transaction.js index d3594d4e..e336a877 100644 --- a/app/routes/activity/components/components/Transaction/Transaction.js +++ b/app/routes/activity/components/components/Transaction/Transaction.js @@ -4,7 +4,6 @@ import Moment from 'react-moment' import 'moment-timezone' import Isvg from 'react-inlinesvg' import { FaChain } from 'react-icons/lib/fa' -import { btc } from 'utils' import Value from 'components/Value' import checkmarkIcon from 'icons/check_circle.svg' import styles from '../Activity.scss' diff --git a/app/routes/activity/containers/ActivityContainer.js b/app/routes/activity/containers/ActivityContainer.js index e21b781c..9f5805ea 100644 --- a/app/routes/activity/containers/ActivityContainer.js +++ b/app/routes/activity/containers/ActivityContainer.js @@ -72,7 +72,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => { info: stateProps.info, ticker: stateProps.ticker, currentTicker: stateProps.currentTicker, - + setCurrency: dispatchProps.setCurrency, newAddress: dispatchProps.newAddress, openPayForm: () => dispatchProps.setFormType('PAY_FORM'), diff --git a/app/routes/app/components/App.js b/app/routes/app/components/App.js index 42160dc1..c4f3de8a 100644 --- a/app/routes/app/components/App.js +++ b/app/routes/app/components/App.js @@ -11,13 +11,20 @@ import Network from 'components/Contacts/Network' import ContactModal from 'components/Contacts/ContactModal' import ContactsForm from 'components/Contacts/ContactsForm' -import ActivityModal from 'components/activity/ActivityModal' +import ActivityModal from 'components/Activity/ActivityModal' import styles from './App.scss' class App extends Component { componentWillMount() { - const { fetchTicker, fetchInfo, newAddress, fetchChannels, fetchBalance, fetchDescribeNetwork } = this.props + const { + fetchTicker, + fetchInfo, + newAddress, + fetchChannels, + fetchBalance, + fetchDescribeNetwork + } = this.props // fetch price ticker fetchTicker() @@ -35,9 +42,6 @@ class App extends Component { render() { const { - activity, - hideActivityModal, - modal: { modalType, modalProps }, hideModal, ticker, @@ -100,6 +104,7 @@ App.propTypes = { contactModalProps: PropTypes.object, contactsFormProps: PropTypes.object, networkTabProps: PropTypes.object, + activityModalProps: PropTypes.object, newAddress: PropTypes.func.isRequired, fetchInfo: PropTypes.func.isRequired, diff --git a/app/routes/app/containers/AppContainer.js b/app/routes/app/containers/AppContainer.js index f3599e32..37108991 100644 --- a/app/routes/app/containers/AppContainer.js +++ b/app/routes/app/containers/AppContainer.js @@ -240,7 +240,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => { const requestFormProps = { requestform: stateProps.requestform, ticker: stateProps.ticker, - + currentCurrencyFilters: stateProps.currentCurrencyFilters, showCurrencyFilters: stateProps.showCurrencyFilters, currencyName: stateProps.currencyName, diff --git a/app/utils/btc.js b/app/utils/btc.js index 945cccf7..5abef070 100644 --- a/app/utils/btc.js +++ b/app/utils/btc.js @@ -1,3 +1,5 @@ +/* eslint-disable */ + import sb from 'satoshi-bitcoin' ////////////////////// // BTC to things ///// diff --git a/test/components/Form.spec.js b/test/components/Form.spec.js index ab20f73a..0df61117 100644 --- a/test/components/Form.spec.js +++ b/test/components/Form.spec.js @@ -2,8 +2,8 @@ import React from 'react' import { shallow } from 'enzyme' import Form from '../../app/components/Form' -import PayForm from '../../app/components/Form/PayForm' -import RequestForm from '../../app/components/Form/RequestForm' +import Pay from '../../app/components/Form/Pay' +import Request from '../../app/components/Form/Request' const payFormProps = { payform: { @@ -55,16 +55,16 @@ describe('Form', () => { describe('should show pay form when formType is PAY_FORM', () => { const props = { ...defaultProps, formType: 'PAY_FORM', formProps: payFormProps } const el = shallow(
    ) - it('should contain PayForm', () => { - expect(el.find(PayForm)).toHaveLength(1) + it('should contain Pay', () => { + expect(el.find(Pay)).toHaveLength(1) }) }) describe('should show request form when formType is REQUEST_FORM', () => { const props = { ...defaultProps, formType: 'REQUEST_FORM', formProps: requestFormProps } const el = shallow() - it('should contain RequestForm', () => { - expect(el.find(RequestForm)).toHaveLength(1) + it('should contain Request', () => { + expect(el.find(Request)).toHaveLength(1) }) }) }) diff --git a/test/components/Form/Payform.spec.js b/test/components/Form/Pay.spec.js similarity index 80% rename from test/components/Form/Payform.spec.js rename to test/components/Form/Pay.spec.js index 740ea4b1..3d323ec9 100644 --- a/test/components/Form/Payform.spec.js +++ b/test/components/Form/Pay.spec.js @@ -1,7 +1,7 @@ import React from 'react' import { shallow } from 'enzyme' -import PayForm from '../../../app/components/Form/PayForm' +import Pay from '../../../app/components/Form/Pay' const defaultProps = { payform: { @@ -30,9 +30,9 @@ const defaultProps = { describe('Form', () => { describe('should show the form without an input', () => { - const el = shallow() + const el = shallow() - it('should contain PayForm', () => { + it('should contain Pay', () => { expect(el.find('input#paymentRequest').props.value).toBe(undefined) expect(el.contains('lightning network')).toBe(false) expect(el.contains('on-chain')).toBe(false) @@ -41,9 +41,9 @@ describe('Form', () => { describe('should show lightning with a lightning input', () => { const props = { ...defaultProps, isLn: true } - const el = shallow() + const el = shallow() - it('should contain PayForm', () => { + it('should contain Pay', () => { expect(el.find('input#paymentRequest').props.value).toBe(undefined) expect(el.contains('lightning network')).toBe(true) expect(el.contains('on-chain')).toBe(false) @@ -52,9 +52,9 @@ describe('Form', () => { describe('should show on-chain with an on-chain input', () => { const props = { ...defaultProps, isOnchain: true } - const el = shallow() + const el = shallow() - it('should contain PayForm', () => { + it('should contain Pay', () => { expect(el.find('input#paymentRequest').props.value).toBe(undefined) expect(el.contains('lightning network')).toBe(false) expect(el.contains('on-chain')).toBe(true) diff --git a/test/components/Form/RequestForm.spec.js b/test/components/Form/Request.spec.js similarity index 74% rename from test/components/Form/RequestForm.spec.js rename to test/components/Form/Request.spec.js index a04c655c..0768dfd8 100644 --- a/test/components/Form/RequestForm.spec.js +++ b/test/components/Form/Request.spec.js @@ -1,7 +1,7 @@ import React from 'react' import { shallow } from 'enzyme' -import RequestForm from '../../../app/components/Form/RequestForm' +import Request from '../../../app/components/Form/Request' const defaultProps = { requestform: { @@ -20,8 +20,8 @@ const defaultProps = { describe('Form', () => { describe('should show request form when formType is REQUEST_FORM', () => { const props = { ...defaultProps } - const el = shallow() - it('should contain RequestForm', () => { + const el = shallow() + it('should contain Request', () => { expect(el.contains('Request')).toBe(true) }) }) diff --git a/test/reducers/form.spec.js b/test/reducers/form.spec.js index faa21642..8c8066b8 100644 --- a/test/reducers/form.spec.js +++ b/test/reducers/form.spec.js @@ -1,13 +1,4 @@ -import formReducer, { - SET_FORM_TYPE -} from '../../app/reducers/form' - -// describe('reducers', () => { -// describe('formReducer', () => { - - -// } -// } +import formReducer, { SET_FORM_TYPE } from '../../app/reducers/form' describe('reducers', () => { describe('formReducer', () => {