[FIX] Omnichannel custom fields are not rendered properly (#3295)

* [FIX] Permissions to edit livechat

* [FIX] Custom fields labels and values

* refactor field

* Added the permission to edit livechat room custom fields

* Fix the inputs.focus()

Co-authored-by: Levy Costa <levycosta471@gmail.com>
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Reinaldo Neto 2021-08-23 10:43:51 -03:00 committed by GitHub
parent bea88afca7
commit 77f2960dbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -55,12 +55,12 @@ const LivechatEditView = ({
const visitorCustomFields = result.customFields const visitorCustomFields = result.customFields
.filter(field => field.visibility !== 'hidden' && field.scope === 'visitor') .filter(field => field.visibility !== 'hidden' && field.scope === 'visitor')
.map(field => ({ [field._id]: (visitor.livechatData && visitor.livechatData[field._id]) || '' })) .map(field => ({ [field._id]: (visitor.livechatData && visitor.livechatData[field._id]) || '' }))
.reduce((ret, field) => ({ [field]: field, ...ret })); .reduce((ret, field) => ({ ...field, ...ret }));
const livechatCustomFields = result.customFields const livechatCustomFields = result.customFields
.filter(field => field.visibility !== 'hidden' && field.scope === 'room') .filter(field => field.visibility !== 'hidden' && field.scope === 'room')
.map(field => ({ [field._id]: (livechat.livechatData && livechat.livechatData[field._id]) || '' })) .map(field => ({ [field._id]: (livechat.livechatData && livechat.livechatData[field._id]) || '' }))
.reduce((ret, field) => ({ [field]: field, ...ret })); .reduce((ret, field) => ({ ...field, ...ret }));
return setCustomFields({ visitor: visitorCustomFields, livechat: livechatCustomFields }); return setCustomFields({ visitor: visitorCustomFields, livechat: livechatCustomFields });
} }
@ -188,7 +188,7 @@ const LivechatEditView = ({
onSubmitEditing={() => { onSubmitEditing={() => {
const keys = Object.keys(customFields?.visitor || {}); const keys = Object.keys(customFields?.visitor || {});
if (keys.length > 0) { if (keys.length > 0) {
const key = keys.pop(); const key = keys[0];
inputs[key].focus(); inputs[key].focus();
} else { } else {
inputs.topic.focus(); inputs.topic.focus();
@ -205,7 +205,7 @@ const LivechatEditView = ({
onChangeText={text => onChangeText(key, text)} onChangeText={text => onChangeText(key, text)}
onSubmitEditing={() => { onSubmitEditing={() => {
if (array.length - 1 > index) { if (array.length - 1 > index) {
return inputs[array[index + 1]].focus(); return inputs[array[index + 1][0]].focus();
} }
inputs.topic.focus(); inputs.topic.focus();
}} }}