Skip to content

Issue #5802 #5812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 31 additions & 33 deletions src/shared/components/Settings/Tools/Devices/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,46 +84,44 @@ export default class Devices extends ConsentComponent {
*/
onHandleAddDevice(e) {
e.preventDefault();
const { newDevice, deviceTrait, isEdit } = this.state;
const { newDevice, deviceTrait } = this.state;
const { clearDeviceState } = this.props;
this.setState({ isSubmit: true });
if (this.onCheckFormValue(newDevice)) {
return;
}
if (!isEdit) {
const deviceItems = deviceTrait.traits
? deviceTrait.traits.data.slice() : [];
let exist = false;
// eslint-disable-next-line no-restricted-syntax
for (const item of deviceItems) {
if (item.deviceType === newDevice.deviceType
&& item.manufacturer === newDevice.manufacturer
&& item.model === newDevice.model
&& item.operatingSystem === newDevice.operatingSystem) {
exist = true;
break;
}
}
if (exist === true) {
const empty = {
deviceType: '',
manufacturer: '',
model: '',
operatingSystem: '',
};
this.setState({
newDevice: empty,
isEdit: false,
indexNo: null,
isSubmit: false,
});
clearDeviceState();
setImmediate(() => {
toastr.error('Looks like you\'ve already entered this device.');
});
return;
const deviceItems = deviceTrait.traits
? deviceTrait.traits.data.slice() : [];
let exist = false;
// eslint-disable-next-line no-restricted-syntax
for (const item of deviceItems) {
if (item.deviceType === newDevice.deviceType
&& item.manufacturer === newDevice.manufacturer
&& item.model === newDevice.model
&& item.operatingSystem === newDevice.operatingSystem) {
exist = true;
break;
}
}
if (exist === true) {
const empty = {
deviceType: '',
manufacturer: '',
model: '',
operatingSystem: '',
};
this.setState({
newDevice: empty,
isEdit: false,
indexNo: null,
isSubmit: false,
});
clearDeviceState();
setImmediate(() => {
toastr.error('Looks like you\'ve already entered this device.');
});
return;
}
this.showConsent(this.onAddDevice.bind(this));
}

Expand Down