Open Gabriel637 opened 4 years ago
The Newsletter component executes a mutation, this one: https://github.com/vtex-apps/store-components/blob/master/react/components/Newsletter/mutations/subscribeNewsletter.graphql
Then, a GraphQL resolver handles the request, only getting the user's email info: https://github.com/vtex-apps/store-graphql/blob/78b965aa9c290227273cc887b75517dd0634af9a/node/resolvers/profile/index.ts#L45-L64
We should improve this resolver to receive the name as a parameter to send in the request to the API. But also, a thing to consider is that this operation, as it is, might it override data from a previously created user.
Example: if I type email "breno@vtex.com.br" and the name "Gabriel" it will change my name to "Gabriel", that's not ideal. We should first check if there isn't an account for the email, if there's not, send the name field and change the newsletter optin. If there's an account created for the email provided, just change the optin (avoiding changing the user's name)
In newsletter most of times we need to get the name of the client who is subscribing, and also, he must accept some terms
I have made a fork and improved some optional fields for those situations, but, when I register the newsletter, thus the network request return 200, I can't find the register on masterdata, anyone knows where is registered those infos?