From 2a2a0a8a8b582659ef54dfce1bb1df212ec7e0db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Mon, 31 May 2021 15:58:24 +0100 Subject: [PATCH] feat: add search functionality to customer page --- lib/customers.js | 1 + lib/new-admin/filters.js | 4 ++-- lib/new-admin/graphql/resolvers/customer.resolver.js | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/customers.js b/lib/customers.js index 3757ad7a..b2e913b9 100644 --- a/lib/customers.js +++ b/lib/customers.js @@ -451,6 +451,7 @@ function batch () { * @returns {array} Array of customers with it's transactions aggregations */ function getCustomersList (phone = null, name = null, address = null, id = null) { + const sql = `SELECT id, authorized_override, days_suspended, is_suspended, front_camera_path, front_camera_override, phone, sms_override, id_card_data, id_card_data_override, id_card_data_expiration, id_card_photo_path, id_card_photo_override, us_ssn, us_ssn_override, sanctions, sanctions_at, diff --git a/lib/new-admin/filters.js b/lib/new-admin/filters.js index fd9d8f79..d6a37922 100644 --- a/lib/new-admin/filters.js +++ b/lib/new-admin/filters.js @@ -2,7 +2,7 @@ const db = require('../db') const cashInTx = require('../cash-in/cash-in-tx') const { CASH_OUT_TRANSACTION_STATES } = require('../cash-out/cash-out-helper') -function transaction() { +function transaction () { const sql = `SELECT DISTINCT * FROM ( SELECT 'type' AS type, 'Cash In' AS value UNION SELECT 'type' AS type, 'Cash Out' AS value UNION @@ -27,7 +27,7 @@ function transaction() { return db.any(sql) } -function customer() { +function customer () { const sql = `SELECT DISTINCT * FROM ( SELECT 'phone' AS type, phone AS value FROM customers WHERE phone 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 diff --git a/lib/new-admin/graphql/resolvers/customer.resolver.js b/lib/new-admin/graphql/resolvers/customer.resolver.js index 795b85f8..f33c3276 100644 --- a/lib/new-admin/graphql/resolvers/customer.resolver.js +++ b/lib/new-admin/graphql/resolvers/customer.resolver.js @@ -1,7 +1,6 @@ const anonymous = require('../../../constants').anonymousCustomer const customers = require('../../../customers') const filters = require('../../filters') -const loyalty = require('../../../loyalty') const resolvers = { Customer: {