Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!doctype || !id) {
throw new Error('Invoice is malformed. invoice: ' + bill.invoice)
}
return [doctype, id]
}
const getBill = (transaction, actionProps) => {
if (actionProps.bill) {
return actionProps.bill
}
return get(transaction, 'bills.data[0]')
}
const transactionModalRowStyle = { color: palette.dodgerBlue }
export class BillComponent extends Component {
state = {
fileId: false
}
findFileId = async () => {
const { transaction, actionProps } = this.props
try {
const bill = await getBill(transaction, actionProps)
const [, fileId] = getBillInvoice(bill)
this.setState({ fileId })
} catch (e) {
// eslint-disable-next-line no-console
console.log(e)
}
}
* to show possible actions related to a transaction.
*
* The TransactionAction (the action the user is most susceptible
* to need) can also be shown in desktop mode, directly in the
* table.
*/
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import palette from 'cozy-ui/transpiled/react/palette'
import { findMatchingActions } from 'ducks/transactions/actions'
import { TransactionActionsContext } from 'ducks/transactions/TransactionActionsContext'
import withContext from 'components/withContext'
// TODO delete or rename this variable (see https://gitlab.cozycloud.cc/labs/cozy-bank/merge_requests/237)
const PRIMARY_ACTION_COLOR = palette.dodgerBlue
const MenuAction = ({
action,
transaction,
actionProps,
compact = false,
menuPosition,
isModalItem
}) => {
const { Component } = action
const color = action.disabled
? palette.charcoalGrey
: action.color || actionProps.color || PRIMARY_ACTION_COLOR
return (
const getAppName = (urls, transaction) => {
const filteredUrls = omit(urls, ['COLLECT', 'HOME'])
const label = transaction.label.toLowerCase()
return findKey(
filteredUrls,
(url, appName) => url && label.indexOf(appName.toLowerCase()) !== -1
)
}
const beautify = appName => {
return appName.toLowerCase() === 'edf' ? 'EDF' : capitalize(appName)
}
const transactionModalRowStyle = { color: palette.dodgerBlue }
const Component = ({
transaction,
actionProps: { urls },
compact,
isModalItem
}) => {
const { t } = useI18n()
const appName = getAppName(urls, transaction)
const label = t(`Transactions.actions.${name}`, {
appName: beautify(appName)
})
const url = urls[appName]
if (isModalItem) {
return (
import flag from 'cozy-flags'
import icon from 'assets/icons/actions/icon-link-out.svg'
import styles from 'ducks/transactions/TransactionActions.styl'
import TransactionModalRow from 'ducks/transactions/TransactionModalRow'
import palette from 'cozy-ui/transpiled/react/palette'
import { triggersConn } from 'doctypes'
import InformativeModal from 'ducks/transactions/actions/KonnectorAction/InformativeModal'
import ConfigurationModal from 'ducks/transactions/actions/KonnectorAction/ConfigurationModal'
import match from 'ducks/transactions/actions/KonnectorAction/match'
import { KonnectorChip } from 'components/KonnectorChip'
import { findMatchingBrandWithoutTrigger } from 'ducks/brandDictionary/selectors'
import { connect } from 'react-redux'
const name = 'konnector'
const transactionModalRowStyle = { color: palette.dodgerBlue }
class Component extends React.Component {
state = {
showInformativeModal: false,
showIntentModal: false
}
showInformativeModal = () =>
this.setState({
showInformativeModal: true
})
hideInformativeModal = () =>
this.setState({
showInformativeModal: false
})
const ActionLink = ({
href,
text,
target,
onClick,
icon,
color = palette.dodgerBlue
}) => (
<a color="" style="{{" href="{href}">
{icon && }
{text}
</a>
)
getIcon: ({ transaction }) => {
const color = isPending(transaction)
? palette.pomegranate
: palette.dodgerBlue
return
},
match: transaction => {
import React from 'react'
import icon from 'assets/icons/actions/icon-link-out.svg'
import ButtonAction from 'cozy-ui/transpiled/react/ButtonAction'
import Chip from 'cozy-ui/transpiled/react/Chip'
import Icon from 'cozy-ui/transpiled/react/Icon'
import flag from 'cozy-flags'
import styles from 'ducks/transactions/TransactionActions.styl'
import TransactionModalRow from 'ducks/transactions/TransactionModalRow'
import palette from 'cozy-ui/transpiled/react/palette'
const name = 'url'
const transactionModalRowStyle = { color: palette.dodgerBlue }
const Component = ({ transaction, compact, isModalItem }) => {
const action = transaction.action
if (isModalItem) {
return (
open(action.url, action.target)}
iconLeft="openwith"
style={transactionModalRowStyle}
>
{action.trad}
)
}
return flag('reimbursements.tag') ? (
import React from 'react'
import { useI18n } from 'cozy-ui/transpiled/react'
import ButtonAction from 'cozy-ui/transpiled/react/ButtonAction'
import Chip from 'cozy-ui/transpiled/react/Chip'
import Icon from 'cozy-ui/transpiled/react/Icon'
import flag from 'cozy-flags'
import icon from 'assets/icons/actions/icon-link-out.svg'
import { isHealth } from 'ducks/categories/helpers'
import palette from 'cozy-ui/transpiled/react/palette'
import styles from 'ducks/transactions/TransactionActions.styl'
import TransactionModalRow from 'ducks/transactions/TransactionModalRow'
const name = 'refund'
const transactionModalRowStyle = { color: palette.dodgerBlue }
const Component = ({ actionProps: { urls }, compact, isModalItem }) => {
const { t } = useI18n()
const url = `${urls['HEALTH']}#/remboursements`
const label = t(`Transactions.actions.${name}`)
if (isModalItem) {
return (
open(url, '_blank')}
iconLeft="openwith"
style={transactionModalRowStyle}
>
{label}
)
}
) : (
open(url)}
label={label}
rightIcon="openwith"
compact={compact}
className={styles.TransactionActionButton}
/>
)
}
const action = {
name,
icon,
color: palette.dodgerBlue,
match: (transaction, { urls }) => {
return isHealth(transaction) && urls['HEALTH']
},
Component: Component
}
export default action