lamassu-server/lib/new-admin/graphql/resolvers/transaction.resolver.js
Liordino Neto 852bf7b089 feat: created the search component
style: added spec styles

fix: fixed font color on search input

style: added box-shadow to the search component

feat: added local search functionality to the search component

feat: integrated search component into the transactions page

feat: allow multiple filter selection on the search component

fix: let the user select only one filter for each type

feat: added chips for the selected filters on the transactions page

feat: added the remove function on the filter chips

style: styled items according to spec

refactor: simplified search component (moved logic to the outside)

feat: added transaction filters to the gql query

feat: added a 'clear all filters' button

feat: added a filters query

feat: added a gql query for the transaction filters

fix: fixed the transactions gql query so it haves the same options as
the transaction filters

feat: added a 'loading' feature to the search box (shown while loading
the filters)

fix: fetch transactions and filters separately in the transactions page

fix: style export

fix: packages

fix: transaction conflicts
2021-06-23 15:29:41 +01:00

42 lines
2.2 KiB
JavaScript

const DataLoader = require('dataloader')
const { parseAsync } = require('json2csv')
const filters = require('../../filters')
const transactions = require('../../services/transactions')
const anonymous = require('../../../constants').anonymousCustomer
const transactionsLoader = new DataLoader(ids => transactions.getCustomerTransactionsBatch(ids))
const txLogFields = ['txClass', 'id', 'deviceId', 'toAddress', 'cryptoAtoms',
'cryptoCode', 'fiat', 'fiatCode', 'fee', 'status',
'dispense', 'notified', 'redeem', 'phone', 'error',
'created', 'confirmedAt', 'hdIndex', 'swept', 'timedout',
'dispenseConfirmed', 'provisioned1', 'provisioned2',
'denomination1', 'denomination2', 'errorCode', 'customerId',
'txVersion', 'publishedAt', 'termsAccepted', 'layer2Address',
'commissionPercentage', 'rawTickerPrice', 'receivedCryptoAtoms',
'discount', 'txHash', 'customerPhone', 'customerIdCardDataNumber',
'customerIdCardDataExpiration', 'customerIdCardData', 'customerName',
'customerFrontCameraPath', 'customerIdCardPhotoPath', 'expired', 'machineName']
const resolvers = {
Customer: {
transactions: parent => transactionsLoader.load(parent.id)
},
Transaction: {
isAnonymous: parent => (parent.customerId === anonymous.uuid)
},
Query: {
transactions: (...[, { from, until, limit, offset, deviceId, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status }]) =>
transactions.batch(from, until, limit, offset, deviceId, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status),
transactionsCsv: (...[, { from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status }]) =>
transactions.batch(from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status)
.then(data => parseAsync(data, {fields: tx_logFields})),
transactionCsv: (...[, { id, txClass }]) =>
transactions.getTx(id, txClass).then(parseAsync),
txAssociatedDataCsv: (...[, { id, txClass }]) =>
transactions.getTxAssociatedData(id, txClass).then(parseAsync),
transactionFilters: () => filters.transaction()
}
}
module.exports = resolvers