fix: Disable name in pre-chat form if the name is already provided in setUser (#5466)

This commit is contained in:
Muhsin Keloth 2022-10-17 20:59:17 +05:30 committed by GitHub
parent 252eda14c6
commit 706ab872f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View file

@ -117,11 +117,23 @@ export default {
filteredPreChatFields() {
const isUserEmailAvailable = !!this.currentUser.email;
const isUserPhoneNumberAvailable = !!this.currentUser.phone_number;
const isUserIdentifierAvailable = !!this.currentUser.identifier;
const isUserNameAvailable = !!(
isUserIdentifierAvailable ||
isUserEmailAvailable ||
isUserPhoneNumberAvailable
);
return this.preChatFields.filter(field => {
return !(
(isUserEmailAvailable && field.name === 'emailAddress') ||
(isUserPhoneNumberAvailable && field.name === 'phoneNumber')
);
if (isUserEmailAvailable && field.name === 'emailAddress') {
return false;
}
if (isUserPhoneNumberAvailable && field.name === 'phoneNumber') {
return false;
}
if (isUserNameAvailable && field.name === 'fullName') {
return false;
}
return true;
});
},
enabledPreChatFields() {

View file

@ -2,3 +2,4 @@ json.id @contact.id
json.name @contact.name
json.email @contact.email
json.phone_number @contact.phone_number
json.identifier @contact.identifier