diff --git a/lib/new-admin/graphql/resolvers/customer.resolver.js b/lib/new-admin/graphql/resolvers/customer.resolver.js index 93695b7e..d8bcac55 100644 --- a/lib/new-admin/graphql/resolvers/customer.resolver.js +++ b/lib/new-admin/graphql/resolvers/customer.resolver.js @@ -3,15 +3,22 @@ const anonymous = require('../../../constants').anonymousCustomer const customers = require('../../../customers') const filters = require('../../filters') const customerNotes = require('../../../customer-notes') +const machineLoader = require('../../../machine-loader') + +const getCustomerById = customerId => + customers.getCustomerById(customerId) + .then(customer => + machineLoader.getMachineName(customer.lastUsedMachine) + .then(lastUsedMachineName => Object.assign(customer, { lastUsedMachineName })) + ) const resolvers = { - Customer: { isAnonymous: parent => (parent.customerId === anonymous.uuid) }, Query: { customers: (...[, { phone, email, name, address, id }]) => customers.getCustomersList(phone, name, address, id, email), - customer: (...[, { customerId }]) => customers.getCustomerById(customerId), + customer: (...[, { customerId }]) => getCustomerById(customerId), customerFilters: () => filters.customer() }, Mutation: { diff --git a/lib/new-admin/graphql/types/customer.type.js b/lib/new-admin/graphql/types/customer.type.js index b33cb785..80b5e2eb 100644 --- a/lib/new-admin/graphql/types/customer.type.js +++ b/lib/new-admin/graphql/types/customer.type.js @@ -34,6 +34,7 @@ const typeDef = gql` lastTxFiatCode: String lastTxClass: String lastUsedMachine: String + lastUsedMachineName: String transactions: [Transaction] subscriberInfo: JSONObject phoneOverride: String