Revert "feat: Custom fields in pre-chat form (#4135)" (#4182)

This reverts commit e730804b48.
This commit is contained in:
Muhsin Keloth
2022-03-15 16:54:33 +05:30
committed by GitHub
parent 25876993ff
commit f405572e5c
16 changed files with 138 additions and 329 deletions

View File

@@ -1,28 +0,0 @@
class AddCustomFieldsToPreChatForm < ActiveRecord::Migration[6.1]
def change
Channel::WebWidget.find_in_batches do |channels_batch|
channels_batch.each do |channel|
pre_chat_message = channel[:pre_chat_form_options]['pre_chat_message'] || 'Share your queries or comments here.'
pre_chat_fields = pre_chat_fields?(channel)
channel[:pre_chat_form_options] = {
'pre_chat_message': pre_chat_message,
'pre_chat_fields': pre_chat_fields
}
channel.save!
end
end
end
def pre_chat_fields?(channel)
email_enabled = channel[:pre_chat_form_options]['require_email'] || false
[
{
'label': 'Email Id', 'name': 'emailAddress', 'type': 'email', 'required': true, 'enabled': email_enabled
}, {
'label': 'Full name', 'name': 'fullName', 'type': 'text', 'required': true, 'enabled': email_enabled
}, {
'label': 'Phone number', 'name': 'phoneNumber', 'type': 'number', 'required': true, 'enabled': false
}
]
end
end