From fcaa089ea298c9067a2b09a168cb4d90c88e8b54 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 21 May 2022 13:56:27 -0700 Subject: Remaining command attributes --- modern/src/settings/components/BaseCommandView.js | 46 ++++++++++++++++------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'modern/src/settings/components') diff --git a/modern/src/settings/components/BaseCommandView.js b/modern/src/settings/components/BaseCommandView.js index b422e153..836e8789 100644 --- a/modern/src/settings/components/BaseCommandView.js +++ b/modern/src/settings/components/BaseCommandView.js @@ -34,19 +34,39 @@ const BaseCommandView = ({ item, setItem }) => { label={t('sharedType')} variant="filled" /> - {attributes.map((attribute) => ( - { - const updateItem = { ...item, attributes: { ...item.attributes } }; - updateItem.attributes[attribute.key] = e.target.value; - setItem(updateItem); - }} - label={attribute.name} - variant="filled" - /> - ))} + {attributes.map(({ key, name, type }) => { + if (type === 'boolean') { + return ( + { + const updateItem = { ...item, attributes: { ...item.attributes } }; + updateItem.attributes[key] = e.target.checked; + setItem(updateItem); + }} + /> + )} + label={name} + /> + ); + } + return ( + { + const updateItem = { ...item, attributes: { ...item.attributes } }; + updateItem.attributes[key] = type === 'number' ? Number(e.target.value) : e.target.value; + setItem(updateItem); + }} + label={name} + variant="filled" + /> + ); + })} setItem({ ...item, textChannel: event.target.checked })} />} label={t('commandSendSms')} -- cgit v1.2.3