diff --git a/lib/new-admin/graphql/resolvers/transaction.resolver.js b/lib/new-admin/graphql/resolvers/transaction.resolver.js index fae3eac3..3dc5a399 100644 --- a/lib/new-admin/graphql/resolvers/transaction.resolver.js +++ b/lib/new-admin/graphql/resolvers/transaction.resolver.js @@ -4,6 +4,7 @@ const _ = require('lodash/fp') const filters = require('../../filters') const cashOutTx = require('../../../cash-out/cash-out-tx') +const cashInTx = require('../../../cash-in/cash-in-tx') const transactions = require('../../services/transactions') const anonymous = require('../../../constants').anonymousCustomer const logDateFormat = require('../../../logs').logDateFormat @@ -45,7 +46,8 @@ const resolvers = { transactionFilters: () => filters.transaction() }, Mutation: { - cancelCashOutTransaction: (...[, { id }]) => cashOutTx.cancel(id) + cancelCashOutTransaction: (...[, { id }]) => cashOutTx.cancel(id), + cancelCashInTransaction: (...[, { id }]) => cashInTx.cancel(id) } } diff --git a/lib/new-admin/graphql/types/transaction.type.js b/lib/new-admin/graphql/types/transaction.type.js index 82d1c16c..f4c86e3e 100644 --- a/lib/new-admin/graphql/types/transaction.type.js +++ b/lib/new-admin/graphql/types/transaction.type.js @@ -62,6 +62,7 @@ const typeDef = gql` type Mutation { cancelCashOutTransaction(id: ID): Transaction @auth + cancelCashInTransaction(id: ID): Transaction @auth } ` diff --git a/new-lamassu-admin/src/pages/Transactions/DetailsCard.js b/new-lamassu-admin/src/pages/Transactions/DetailsCard.js index a339d421..cb436fb8 100644 --- a/new-lamassu-admin/src/pages/Transactions/DetailsCard.js +++ b/new-lamassu-admin/src/pages/Transactions/DetailsCard.js @@ -62,7 +62,7 @@ const TX_SUMMARY = gql` } ` -const CANCEL_TRANSACTION = gql` +const CANCEL_CASH_OUT_TRANSACTION = gql` mutation cancelCashOutTransaction($id: ID!) { cancelCashOutTransaction(id: $id) { id @@ -70,6 +70,14 @@ const CANCEL_TRANSACTION = gql` } ` +const CANCEL_CASH_IN_TRANSACTION = gql` + mutation cancelCashInTransaction($id: ID!) { + cancelCashInTransaction(id: $id) { + id + } + } +` + const formatAddress = (cryptoCode = '', address = '') => coinUtils.formatCryptoAddress(cryptoCode, address).replace(/(.{5})/g, '$1 ') @@ -83,16 +91,22 @@ const DetailsRow = ({ it: tx, timezone }) => { const [action, setAction] = useState({ command: null }) const [errorMessage, setErrorMessage] = useState('') + const isCashIn = tx.txClass === 'cashIn' + const zip = new JSZip() const [fetchSummary] = useLazyQuery(TX_SUMMARY, { onCompleted: data => createCsv(data) }) - const [cancelCashOutTransaction] = useMutation(CANCEL_TRANSACTION, { - onError: ({ message }) => setErrorMessage(message ?? 'An error occurred.'), - refetchQueries: () => ['transactions'] - }) + const [cancelTransaction] = useMutation( + isCashIn ? CANCEL_CASH_IN_TRANSACTION : CANCEL_CASH_OUT_TRANSACTION, + { + onError: ({ message }) => + setErrorMessage(message ?? 'An error occurred.'), + refetchQueries: () => ['transactions'] + } + ) const fiat = Number.parseFloat(tx.fiat) const crypto = coinUtils.toUnit(new BigNumber(tx.cryptoAtoms), tx.cryptoCode) @@ -142,6 +156,13 @@ const DetailsRow = ({ it: tx, timezone }) => { > ) + const getCancelMessage = () => { + const cashInMessage = `The user will not be able to redeem the inserted bills, even if they subsequently confirm the transaction. If they've already deposited bills, you'll need to reconcile this transaction with them manually.` + const cashOutMessage = `The user will not be able to redeem the cash, even if they subsequently send the required coins. If they've already sent you coins, you'll need to reconcile this transaction with them manually.` + + return isCashIn ? cashInMessage : cashOutMessage + } + return (