Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleClickAdd = () => {
let name = this.refInputName.current.value;
// TODO: Name Validation
this.refInputName.current.value = '';
let sameNameKlasses = this.state.klasses.filter(function(klass) {
return klass.name == name;
});
let targetKlass = {};
if (sameNameKlasses.length > 0) {
alert('Already registered.');
} else {
targetKlass.name = name;
}
const defaultColors = TwitterPicker.defaultProps.colors;
const labelType = this.props.currentProject.label_type;
const defaultMinSize =
labelType === 'BB2D' ? { x: 10, y: 10 } :
labelType === 'BB2D3D' ? { x: 10, y: 10, z: 10 } :
{};
const idx = this.state.klasses.length;
targetKlass.color = defaultColors[idx % defaultColors.length];
targetKlass.minSize = defaultMinSize;
let clonedKlasses = JSON.parse(JSON.stringify(this.state.klasses));
clonedKlasses.push(targetKlass);
this.setState({ klasses: clonedKlasses });
};
handleSubmit = () => {