fix: UI stuff and mailgun typos

This commit is contained in:
Rafael Taranto 2023-12-15 11:59:38 +00:00
parent 142f86c85c
commit 3221a7a828
13 changed files with 75 additions and 13 deletions

View file

@ -488,7 +488,7 @@ function batch () {
* @returns {array} Array of customers with it's transactions aggregations * @returns {array} Array of customers with it's transactions aggregations
*/ */
function getCustomersList (phone = null, name = null, address = null, id = null) { function getCustomersList (phone = null, name = null, address = null, id = null, email = null) {
const passableErrorCodes = _.map(Pgp.as.text, TX_PASSTHROUGH_ERROR_CODES).join(',') const passableErrorCodes = _.map(Pgp.as.text, TX_PASSTHROUGH_ERROR_CODES).join(',')
const sql = `SELECT id, authorized_override, days_suspended, is_suspended, front_camera_path, front_camera_override, const sql = `SELECT id, authorized_override, days_suspended, is_suspended, front_camera_path, front_camera_override,
@ -529,8 +529,10 @@ function getCustomersList (phone = null, name = null, address = null, id = null)
AND ($5 IS NULL OR CONCAT(id_card_data::json->>'firstName', ' ', id_card_data::json->>'lastName') = $5 OR id_card_data::json->>'firstName' = $5 OR id_card_data::json->>'lastName' = $5) AND ($5 IS NULL OR CONCAT(id_card_data::json->>'firstName', ' ', id_card_data::json->>'lastName') = $5 OR id_card_data::json->>'firstName' = $5 OR id_card_data::json->>'lastName' = $5)
AND ($6 IS NULL OR id_card_data::json->>'address' = $6) AND ($6 IS NULL OR id_card_data::json->>'address' = $6)
AND ($7 IS NULL OR id_card_data::json->>'documentNumber' = $7) AND ($7 IS NULL OR id_card_data::json->>'documentNumber' = $7)
AND ($8 IS NULL OR email = $8)
limit $3` limit $3`
return db.any(sql, [ passableErrorCodes, anonymous.uuid, NUM_RESULTS, phone, name, address, id ]) console.log(email)
return db.any(sql, [ passableErrorCodes, anonymous.uuid, NUM_RESULTS, phone, name, address, id, email ])
.then(customers => Promise.all(_.map(customer => .then(customers => Promise.all(_.map(customer =>
getCustomInfoRequestsData(customer) getCustomInfoRequestsData(customer)
.then(camelizeDeep), customers) .then(camelizeDeep), customers)

View file

@ -31,6 +31,7 @@ function transaction () {
function customer () { function customer () {
const sql = `SELECT DISTINCT * FROM ( const sql = `SELECT DISTINCT * FROM (
SELECT 'phone' AS type, phone AS value FROM customers WHERE phone IS NOT NULL UNION SELECT 'phone' AS type, phone AS value FROM customers WHERE phone IS NOT NULL UNION
SELECT 'email' AS type, email AS value FROM customers WHERE email IS NOT NULL UNION
SELECT 'name' AS type, id_card_data::json->>'firstName' AS value FROM customers WHERE id_card_data::json->>'firstName' IS NOT NULL AND id_card_data::json->>'lastName' IS NULL UNION SELECT 'name' AS type, id_card_data::json->>'firstName' AS value FROM customers WHERE id_card_data::json->>'firstName' IS NOT NULL AND id_card_data::json->>'lastName' IS NULL UNION
SELECT 'name' AS type, id_card_data::json->>'lastName' AS value FROM customers WHERE id_card_data::json->>'firstName' IS NULL AND id_card_data::json->>'lastName' IS NOT NULL UNION SELECT 'name' AS type, id_card_data::json->>'lastName' AS value FROM customers WHERE id_card_data::json->>'firstName' IS NULL AND id_card_data::json->>'lastName' IS NOT NULL UNION
SELECT 'name' AS type, concat(id_card_data::json->>'firstName', ' ', id_card_data::json->>'lastName') AS value FROM customers WHERE id_card_data::json->>'firstName' IS NOT NULL AND id_card_data::json->>'lastName' IS NOT NULL UNION SELECT 'name' AS type, concat(id_card_data::json->>'firstName', ' ', id_card_data::json->>'lastName') AS value FROM customers WHERE id_card_data::json->>'firstName' IS NOT NULL AND id_card_data::json->>'lastName' IS NOT NULL UNION

View file

@ -10,7 +10,7 @@ const resolvers = {
isAnonymous: parent => (parent.customerId === anonymous.uuid) isAnonymous: parent => (parent.customerId === anonymous.uuid)
}, },
Query: { Query: {
customers: (...[, { phone, name, address, id }]) => customers.getCustomersList(phone, name, address, id), customers: (...[, { phone, email, name, address, id }]) => customers.getCustomersList(phone, name, address, id, email),
customer: (...[, { customerId }]) => customers.getCustomerById(customerId), customer: (...[, { customerId }]) => customers.getCustomerById(customerId),
customerFilters: () => filters.customer() customerFilters: () => filters.customer()
}, },

View file

@ -93,7 +93,7 @@ const typeDef = gql`
} }
type Query { type Query {
customers(phone: String, name: String, address: String, id: String): [Customer] @auth customers(phone: String, name: String, email: String, address: String, id: String): [Customer] @auth
customer(customerId: ID!): Customer @auth customer(customerId: ID!): Customer @auth
customerFilters: [Filter] @auth customerFilters: [Filter] @auth
} }

View file

@ -33,6 +33,7 @@ const typeDef = gql`
rawTickerPrice: String rawTickerPrice: String
isPaperWallet: Boolean isPaperWallet: Boolean
customerPhone: String customerPhone: String
customerEmail: String
customerIdCardDataNumber: String customerIdCardDataNumber: String
customerIdCardDataExpiration: Date customerIdCardDataExpiration: Date
customerIdCardData: JSONObject customerIdCardData: JSONObject

View file

@ -54,6 +54,7 @@ function batch (
const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*, const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*,
c.phone AS customer_phone, c.phone AS customer_phone,
c.email AS customer_email,
c.id_card_data_number AS customer_id_card_data_number, c.id_card_data_number AS customer_id_card_data_number,
c.id_card_data_expiration AS customer_id_card_data_expiration, c.id_card_data_expiration AS customer_id_card_data_expiration,
c.id_card_data AS customer_id_card_data, c.id_card_data AS customer_id_card_data,
@ -86,6 +87,7 @@ function batch (
txs.*, txs.*,
actions.tx_hash, actions.tx_hash,
c.phone AS customer_phone, c.phone AS customer_phone,
c.email AS customer_email,
c.id_card_data_number AS customer_id_card_data_number, c.id_card_data_number AS customer_id_card_data_number,
c.id_card_data_expiration AS customer_id_card_data_expiration, c.id_card_data_expiration AS customer_id_card_data_expiration,
c.id_card_data AS customer_id_card_data, c.id_card_data AS customer_id_card_data,
@ -157,7 +159,7 @@ function advancedBatch (data) {
'denomination1', 'denomination2', 'errorCode', 'customerId', 'denomination1', 'denomination2', 'errorCode', 'customerId',
'txVersion', 'publishedAt', 'termsAccepted', 'layer2Address', 'txVersion', 'publishedAt', 'termsAccepted', 'layer2Address',
'commissionPercentage', 'rawTickerPrice', 'receivedCryptoAtoms', 'commissionPercentage', 'rawTickerPrice', 'receivedCryptoAtoms',
'discount', 'txHash', 'customerPhone', 'customerIdCardDataNumber', 'discount', 'txHash', 'customerPhone', 'customerEmail', 'customerIdCardDataNumber',
'customerIdCardDataExpiration', 'customerIdCardData', 'customerName', 'sendTime', 'customerIdCardDataExpiration', 'customerIdCardData', 'customerName', 'sendTime',
'customerFrontCameraPath', 'customerIdCardPhotoPath', 'expired', 'machineName', 'walletScore'] 'customerFrontCameraPath', 'customerIdCardPhotoPath', 'expired', 'machineName', 'walletScore']
@ -173,7 +175,7 @@ function advancedBatch (data) {
function simplifiedBatch (data) { function simplifiedBatch (data) {
const fields = ['txClass', 'id', 'created', 'machineName', const fields = ['txClass', 'id', 'created', 'machineName',
'cryptoCode', 'cryptoAtoms', 'fiat', 'fiatCode', 'phone', 'toAddress', 'cryptoCode', 'cryptoAtoms', 'fiat', 'fiatCode', 'phone', 'email', 'toAddress',
'txHash', 'dispense', 'error', 'status', 'fiatProfit', 'cryptoAmount'] 'txHash', 'dispense', 'error', 'status', 'fiatProfit', 'cryptoAmount']
const addSimplifiedFields = _.map(it => ({ const addSimplifiedFields = _.map(it => ({
@ -234,6 +236,7 @@ function getCustomerTransactionsBatch (ids) {
const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*, const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*,
c.phone AS customer_phone, c.phone AS customer_phone,
c.email AS customer_email,
c.id_card_data_number AS customer_id_card_data_number, c.id_card_data_number AS customer_id_card_data_number,
c.id_card_data_expiration AS customer_id_card_data_expiration, c.id_card_data_expiration AS customer_id_card_data_expiration,
c.id_card_data AS customer_id_card_data, c.id_card_data AS customer_id_card_data,
@ -252,6 +255,7 @@ function getCustomerTransactionsBatch (ids) {
txs.*, txs.*,
actions.tx_hash, actions.tx_hash,
c.phone AS customer_phone, c.phone AS customer_phone,
c.email AS customer_email,
c.id_card_data_number AS customer_id_card_data_number, c.id_card_data_number AS customer_id_card_data_number,
c.id_card_data_expiration AS customer_id_card_data_expiration, c.id_card_data_expiration AS customer_id_card_data_expiration,
c.id_card_data AS customer_id_card_data, c.id_card_data AS customer_id_card_data,
@ -280,6 +284,7 @@ function single (txId) {
const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*, const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*,
c.phone AS customer_phone, c.phone AS customer_phone,
c.email AS customer_email,
c.id_card_data_number AS customer_id_card_data_number, c.id_card_data_number AS customer_id_card_data_number,
c.id_card_data_expiration AS customer_id_card_data_expiration, c.id_card_data_expiration AS customer_id_card_data_expiration,
c.id_card_data AS customer_id_card_data, c.id_card_data AS customer_id_card_data,
@ -297,6 +302,7 @@ function single (txId) {
txs.*, txs.*,
actions.tx_hash, actions.tx_hash,
c.phone AS customer_phone, c.phone AS customer_phone,
c.email AS customer_email,
c.id_card_data_number AS customer_id_card_data_number, c.id_card_data_number AS customer_id_card_data_number,
c.id_card_data_expiration AS customer_id_card_data_expiration, c.id_card_data_expiration AS customer_id_card_data_expiration,
c.id_card_data AS customer_id_card_data, c.id_card_data AS customer_id_card_data,

View file

@ -4,7 +4,7 @@ const NAME = 'Mailgun'
function sendMessage ({apiKey, domain, fromEmail, toEmail}, rec) { function sendMessage ({apiKey, domain, fromEmail, toEmail}, rec) {
const mailgun = Mailgun({apiKey, domain}) const mailgun = Mailgun({apiKey, domain})
const to = req.email.toEmail ?? toEmail const to = rec.email.toEmail ?? toEmail
const emailData = { const emailData = {
from: `Lamassu Server ${fromEmail}`, from: `Lamassu Server ${fromEmail}`,
@ -18,7 +18,7 @@ function sendMessage ({apiKey, domain, fromEmail, toEmail}, rec) {
function sendCustomerMessage ({apiKey, domain, fromEmail}, rec) { function sendCustomerMessage ({apiKey, domain, fromEmail}, rec) {
const mailgun = Mailgun({apiKey, domain}) const mailgun = Mailgun({apiKey, domain})
const to = req.email.toEmail const to = rec.email.toEmail
const emailData = { const emailData = {
from: fromEmail, from: fromEmail,

View file

@ -101,6 +101,7 @@ const CustomerData = ({
) )
const phone = R.path(['phone'])(customer) const phone = R.path(['phone'])(customer)
const email = R.path(['email'])(customer)
const smsData = R.path(['subscriberInfo'])(customer) const smsData = R.path(['subscriberInfo'])(customer)
const isEven = elem => elem % 2 === 0 const isEven = elem => elem % 2 === 0
@ -134,6 +135,9 @@ const CustomerData = ({
idCardPhoto: { idCardPhoto: {
idCardPhoto: null idCardPhoto: null
}, },
email: {
email
},
smsData: { smsData: {
phoneNumber: getFormattedPhone(phone, locale.country) phoneNumber: getFormattedPhone(phone, locale.country)
} }
@ -201,6 +205,19 @@ const CustomerData = ({
hasAdditionalData: !R.isNil(smsData) && !R.isEmpty(smsData), hasAdditionalData: !R.isNil(smsData) && !R.isEmpty(smsData),
editable: false editable: false
}, },
{
title: 'Email',
fields: customerDataElements.email,
titleIcon: <CardIcon className={classes.cardIcon} />,
// state: R.path(['emailOverride'])(customer),
// authorize: () => updateCustomer({ emailOverride: OVERRIDE_AUTHORIZED }),
// reject: () => updateCustomer({ emailOverride: OVERRIDE_REJECTED }),
save: values => editCustomer(values),
deleteEditedData: () => deleteEditedData({ email: null }),
initialValues: initialValues.email,
isAvailable: !R.isNil(customer.email),
editable: false
},
{ {
title: 'Name', title: 'Name',
titleIcon: <EditIcon className={classes.editIcon} />, titleIcon: <EditIcon className={classes.editIcon} />,

View file

@ -31,11 +31,18 @@ const GET_CUSTOMERS = gql`
query configAndCustomers( query configAndCustomers(
$phone: String $phone: String
$name: String $name: String
$email: String
$address: String $address: String
$id: String $id: String
) { ) {
config config
customers(phone: $phone, name: $name, address: $address, id: $id) { customers(
phone: $phone
email: $email
name: $name
address: $address
id: $id
) {
id id
idCardData idCardData
phone phone
@ -155,6 +162,7 @@ const Customers = () => {
setVariables({ setVariables({
phone: filtersObject.phone, phone: filtersObject.phone,
name: filtersObject.name, name: filtersObject.name,
email: filtersObject.email,
address: filtersObject.address, address: filtersObject.address,
id: filtersObject.id id: filtersObject.id
}) })
@ -174,6 +182,7 @@ const Customers = () => {
setVariables({ setVariables({
phone: filtersObject.phone, phone: filtersObject.phone,
name: filtersObject.name, name: filtersObject.name,
email: filtersObject.email,
address: filtersObject.address, address: filtersObject.address,
id: filtersObject.id id: filtersObject.id
}) })
@ -188,6 +197,7 @@ const Customers = () => {
setVariables({ setVariables({
phone: filtersObject.phone, phone: filtersObject.phone,
name: filtersObject.name, name: filtersObject.name,
email: filtersObject.email,
address: filtersObject.address, address: filtersObject.address,
id: filtersObject.id id: filtersObject.id
}) })

View file

@ -27,7 +27,8 @@ const CustomersList = ({
{ {
header: 'Phone/email', header: 'Phone/email',
width: 199, width: 199,
view: it => `${getFormattedPhone(it.phone, locale.country)} ${it.email}` view: it => `${getFormattedPhone(it.phone, locale.country) || ''}
${it.email || ''}`
}, },
{ {
header: 'Name', header: 'Name',

View file

@ -59,7 +59,7 @@ const ID_CARD_DATA = 'idCardData'
const getAuthorizedStatus = (it, triggers, customRequests) => { const getAuthorizedStatus = (it, triggers, customRequests) => {
const fields = R.concat( const fields = R.concat(
['frontCamera', 'idCardData', 'idCardPhoto', 'usSsn', 'sanctions'], ['frontCamera', 'idCardData', 'idCardPhoto', 'email', 'usSsn', 'sanctions'],
R.map(ite => ite.id, customRequests) R.map(ite => ite.id, customRequests)
) )
const fieldsWithPathSuffix = ['frontCamera', 'idCardPhoto'] const fieldsWithPathSuffix = ['frontCamera', 'idCardPhoto']
@ -165,6 +165,7 @@ const requirementOptions = [
{ display: 'ID card image', code: 'idCardPhoto' }, { display: 'ID card image', code: 'idCardPhoto' },
{ display: 'ID data', code: 'idCardData' }, { display: 'ID data', code: 'idCardData' },
{ display: 'US SSN', code: 'usSsn' }, { display: 'US SSN', code: 'usSsn' },
{ display: 'Email', code: 'email' },
{ display: 'Customer camera', code: 'frontCamera' } { display: 'Customer camera', code: 'frontCamera' }
] ]
@ -430,6 +431,15 @@ const customerDataElements = {
editable: true editable: true
} }
], ],
email: [
{
name: 'email',
label: 'Email',
component: TextInput,
size: 190,
editable: false
}
],
idCardPhoto: [{ name: 'idCardPhoto' }], idCardPhoto: [{ name: 'idCardPhoto' }],
frontCamera: [{ name: 'frontCamera' }] frontCamera: [{ name: 'frontCamera' }]
} }
@ -460,6 +470,9 @@ const customerDataSchemas = {
}), }),
frontCamera: Yup.object().shape({ frontCamera: Yup.object().shape({
frontCamera: Yup.mixed().required() frontCamera: Yup.mixed().required()
}),
email: Yup.object().shape({
email: Yup.string().required()
}) })
} }
@ -486,6 +499,13 @@ const requirementElements = {
initialValues: { usSsn: '' }, initialValues: { usSsn: '' },
saveType: 'customerData' saveType: 'customerData'
}, },
email: {
schema: customerDataSchemas.email,
options: customerDataElements.email,
Component: ManualDataEntry,
initialValues: { email: '' },
saveType: 'customerData'
},
idCardPhoto: { idCardPhoto: {
schema: customerDataSchemas.idCardPhoto, schema: customerDataSchemas.idCardPhoto,
options: customerDataElements.idCardPhoto, options: customerDataElements.idCardPhoto,

View file

@ -116,6 +116,7 @@ const GET_TRANSACTIONS = gql`
customerFrontCameraPath customerFrontCameraPath
txCustomerPhotoPath txCustomerPhotoPath
customerPhone customerPhone
customerEmail
discount discount
customerId customerId
isAnonymous isAnonymous

View file

@ -28,10 +28,13 @@ const displayName = ({
isAnonymous, isAnonymous,
customerName, customerName,
customerIdCardData, customerIdCardData,
customerPhone customerPhone,
customerEmail
}) => }) =>
isAnonymous isAnonymous
? 'Anonymous' ? 'Anonymous'
: customerName || R.defaultTo(customerPhone, formatName(customerIdCardData)) : customerName ||
customerEmail ||
R.defaultTo(customerPhone, formatName(customerIdCardData))
export { displayName, formatFullName, formatName } export { displayName, formatFullName, formatName }