aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/pages/send/send-header/send-header.selectors.js
blob: 01b90409b21d5ccd3564b7e5e88b66dc05bc6a24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const {
  getSelectedToken,
  getSendEditingTransactionId,
  getSendTo,
} = require('../send.selectors.js')

const selectors = {
  getTitleKey,
  getSubtitleParams,
}

module.exports = selectors

function getTitleKey (state) {
  const isEditing = Boolean(getSendEditingTransactionId(state))
  const isToken = Boolean(getSelectedToken(state))

  if (!getSendTo(state)) {
    return 'addRecipient'
  }

  if (isEditing) {
    return 'edit'
  } else if (isToken) {
    return 'sendTokens'
  } else {
    return 'sendETH'
  }
}

function getSubtitleParams (state) {
  const isEditing = Boolean(getSendEditingTransactionId(state))
  const token = getSelectedToken(state)

  if (isEditing) {
    return [ 'editingTransaction' ]
  } else if (token) {
    return [ 'onlySendTokensToAccountAddress', [ token.symbol ] ]
  } else {
    return [ 'onlySendToEtherAddress' ]
  }
}