feat: revamp customer notes feature

This commit is contained in:
Sérgio Salgado 2021-12-09 19:09:58 +00:00
parent dcd3259484
commit eb8737872d
20 changed files with 678 additions and 146 deletions

View file

@ -1,4 +1,4 @@
const authentication = require('../modules/authentication')
const authentication = require('../modules/userManagement')
const anonymous = require('../../../constants').anonymousCustomer
const customers = require('../../../customers')
const filters = require('../../filters')
@ -39,9 +39,16 @@ const resolvers = {
// TODO: NOT IMPLEMENTING THIS FEATURE FOR THE CURRENT VERSION
return customers.getCustomerById(customerId)
},
setCustomerNotes: (...[, { customerId, newContent }, context]) => {
createCustomerNote: (...[, { customerId, title, content }, context]) => {
const token = authentication.getToken(context)
return customerNotes.updateCustomerNotes(customerId, token, newContent)
return customerNotes.createCustomerNote(customerId, token, title, content)
},
editCustomerNote: (...[, { noteId, newContent }, context]) => {
const token = authentication.getToken(context)
return customerNotes.updateCustomerNote(noteId, token, newContent)
},
deleteCustomerNote: (...[, { noteId }]) => {
return customerNotes.deleteCustomerNote(noteId)
}
}
}

View file

@ -41,7 +41,7 @@ const typeDef = gql`
subscriberInfo: JSONObject
customFields: [CustomerCustomField]
customInfoRequests: [CustomRequestData]
notes: String
notes: [CustomerNote]
}
input CustomerInput {
@ -76,6 +76,16 @@ const typeDef = gql`
usSsn: String
}
type CustomerNote {
id: ID
customerId: ID
created: Date
lastEditedAt: Date
lastEditedBy: ID
title: String
content: String
}
type Query {
customers(phone: String, name: String, address: String, id: String): [Customer] @auth
customer(customerId: ID!): Customer @auth
@ -90,7 +100,9 @@ const typeDef = gql`
editCustomer(customerId: ID!, customerEdit: CustomerEdit): Customer @auth
deleteEditedData(customerId: ID!, customerEdit: CustomerEdit): Customer @auth
replacePhoto(customerId: ID!, photoType: String, newPhoto: UploadGQL): Customer @auth
setCustomerNotes(customerId: ID!, newContent: String!): Customer @auth
createCustomerNote(customerId: ID!, title: String!, content: String!): Boolean @auth
editCustomerNote(noteId: ID!, newContent: String!): Boolean @auth
deleteCustomerNote(noteId: ID!): Boolean @auth
}
`