feat: Custom fields in pre-chat form (#4189)

This commit is contained in:
Muhsin Keloth
2022-04-19 12:47:29 +05:30
committed by GitHub
parent 1ccd29140d
commit 26f23a6e21
25 changed files with 824 additions and 160 deletions

View File

@@ -12,6 +12,7 @@ import { mapGetters } from 'vuex';
import PreChatForm from '../components/PreChat/Form';
import configMixin from '../mixins/configMixin';
import routerMixin from '../mixins/routerMixin';
import { isEmptyObject } from 'widget/helpers/utils';
export default {
components: {
@@ -35,13 +36,22 @@ export default {
},
},
methods: {
onSubmit({ fullName, emailAddress, message, activeCampaignId }) {
onSubmit({
fullName,
emailAddress,
message,
activeCampaignId,
phoneNumber,
contactCustomAttributes,
conversationCustomAttributes,
}) {
if (activeCampaignId) {
bus.$emit('execute-campaign', activeCampaignId);
this.$store.dispatch('contacts/update', {
user: {
email: emailAddress,
name: fullName,
phone_number: phoneNumber,
},
});
} else {
@@ -49,8 +59,16 @@ export default {
fullName: fullName,
emailAddress: emailAddress,
message: message,
phoneNumber: phoneNumber,
customAttributes: conversationCustomAttributes,
});
}
if (!isEmptyObject(contactCustomAttributes)) {
this.$store.dispatch(
'contacts/setCustomAttributes',
contactCustomAttributes
);
}
},
},
};