{formatMessage({ id: 'core.Device', defaultMessage: 'Device' })}: {record.name}
), content: ( {checked ? formatMessage({ id: 'core.switch_on', defaultMessage: 'Switch ON' }) : formatMessage({ id: 'core.switch_off', defaultMessage: 'Switch OFF' })} ), onOk() { kzDevice({ method: 'PATCH', account_id: account.data.id, device_id: record.id, data: { enabled: checked }, }) .then(() => { dispatch({ type: 'kz_full_devices/refresh', payload: { account_id: account.data.id, device_id: record.id }, }); dispatch({ type: 'kz_brief_devices/refresh', payload: { account_id: account.data.id }, timeout: 1000, }); }) .catch(() => console.log('Oops errors!', record)); }, onCancel() {}, }); } const handlePagination = e => { if (e) { setIsPaginated({ position: 'bottom' }); } else { setIsPaginated(false); } }; const onDrawerClose = () => { setIsEditDrawerVisible(false); }; const onCloseCancel = () => { if (formRef_sip_device.current) formRef_sip_device.current.resetFields(); if (formRef_sip_uri.current) formRef_sip_uri.current.resetFields(); if (formRef_cellphone.current) formRef_cellphone.current.resetFields(); setIsCreateDrawerVisible(false); }; const onCloseSubmit = () => { if (createDeviceType === 'sip_device') { formRef_sip_device.current.submit(); } else if (createDeviceType === 'cellphone') { formRef_cellphone.current.submit(); } else if (createDeviceType === 'sip_uri') { formRef_sip_uri.current.submit(); } }; let createDeviceButton = null; if (createDeviceType === 'sip_device') { createDeviceButton = ( ); } else if (createDeviceType === 'cellphone') { createDeviceButton = ( ); } else if (createDeviceType === 'sip_uri') { createDeviceButton = ( ); } else if (createDeviceType === 'sip_fmc') { createDeviceButton = ( ); } else { createDeviceButton = ( ); } const onDeviceCreateFinish = values => { console.log('Success:', values); const newDevice = {}; _.set(newDevice, 'device_type', values.device_type); _.set(newDevice, 'name', values.device_nickname); _.set(newDevice, 'accept_charges', true); _.set(newDevice, 'suppress_unregister_notifications', true); _.set(newDevice, 'register_overwrite_notify', true); _.set(newDevice, 'sip.username', values.device_username || `user_${cryptoRandomString({length: 7})}`); _.set(newDevice, 'sip.password', values.device_password || `${cryptoRandomString({length: 12})}`); if (isIp(values.sip_ip_auth)) { _.set(newDevice, 'sip.method', 'ip'); _.set(newDevice, 'sip.ip', values.sip_ip_auth); } else { _.set(newDevice, 'sip.method', 'password'); } if (values.sip_uri) { _.set(newDevice, 'sip.invite_format', 'route'); _.set(newDevice, 'sip.route', values.sip_uri); } else { _.set(newDevice, 'sip.invite_format', 'username'); } if (values.redirect_number) { _.set(newDevice, 'call_forward.enabled', true); _.set(newDevice, 'call_forward.keep_caller_id', false); _.set(newDevice, 'call_forward.require_keypress', false); _.set(newDevice, 'call_forward.number', values.redirect_number); } console.log('newDevice:', newDevice); kzDevices({ method: 'PUT', account_id: account.data.id, data: newDevice, }).then(uRes => { dispatch({ type: 'kz_brief_devices/refresh', payload: { account_id: account.data.id }, timeout: 500, }); setSelectedDevice(uRes.data.id); dispatch({ type: 'kz_full_devices/refresh', payload: { account_id: account.data.id, device_id: uRes.data.id }, }); setIsEditDrawerVisible(true); onCloseCancel(); }); }; const onSearchChange = value => { console.log('Value: ', value); if (value.length > 1) { const searchRes = _.filter(brief_devices.data, o => _.includes(_.toString(Object.values(o)).toLowerCase(), value.toLowerCase()), ); setDataSource(searchRes); } else { setDataSource(brief_devices.data); } }; return (
{!isSmallDevice
? `${formatMessage({
id: 'core.pagination',
defaultMessage: 'pagination',
})}: `
: null}