mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-31 19:17:48 +00:00
feat: Custom fields in pre-chat form (#4189)
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user