[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot]
2022-09-22 11:02:27 +00:00
parent 0a1811e86c
commit f9b3ff58f9

View File

@@ -2,25 +2,22 @@ import React, { useState, useEffect } from "react";
import "./table-select.css";
import PropTypes from "prop-types";
const DynamicTable = (props) => {
var [message, setMessage] = useState(""),
[message2, setMessage2] = useState("");
var {current_propobject} = props;
var { current_propobject } = props;
var propobject = current_propobject;
var [propkeys, setOwnKeys] = useState(Object.keys(current_propobject));
var [propvalues, setOwnValues] = useState(Object.values(current_propobject));
var updateMessageKey = (event) => {
setMessage(event.target.value);
}
};
var updateMessageValue = (event) => {
setMessage2(event.target.value);
}
};
const handleRefresh = () => {
var propobject = {};
propkeys.forEach((key, i) => (propobject[key] = propvalues[i]));
props.setProp(propobject);
@@ -28,9 +25,8 @@ const DynamicTable = (props) => {
props.setPropValues(propvalues);
setMessage("");
setMessage2("");
};
}
const handleClick = () => {
if (message != "") {
if (message2 != "") {
@@ -54,8 +50,7 @@ const DynamicTable = (props) => {
console.log(propkeys);
console.log(propvalues);
console.log(propobject);
}
};
const renderKeyRows = () => {
return propkeys.map(function (o, i) {
@@ -67,26 +62,25 @@ const DynamicTable = (props) => {
type="text"
value={propkeys[i]}
id={o}
onChange= {(e) => {
onChange={(e) => {
if (e.target.value != "") {
propkeys[i] = e.target.value ;
} else{
propkeys[i] = e.target.value;
} else {
propvalues.splice(i, 1);
propkeys.splice(i, 1);
}
setOwnKeys(propkeys);
props.setPropKeys(propkeys);
props.setProp(propobject)
props.setProp(propobject);
handleRefresh();
}}
}}
/>
</td>
</tr>
);
});
}
};
const renderValueRows = () => {
return propvalues.map(function (o, i) {
//console.log("ValRows" +i)
//console.log("ValRows" +o)
@@ -108,9 +102,8 @@ const DynamicTable = (props) => {
</tr>
);
});
}
};
const renderDelete = () => {
return propvalues.map(function (o, i) {
return (
<tr key={"item-" + i}>
@@ -136,9 +129,7 @@ const DynamicTable = (props) => {
</tr>
);
});
}
};
return (
<div>
@@ -168,13 +159,13 @@ const DynamicTable = (props) => {
/>
</td>
<td>
<input
className="form-control"
type="text"
value={message2}
onChange={(e) => updateMessageValue(e)}
/>
</td>
<input
className="form-control"
type="text"
value={message2}
onChange={(e) => updateMessageValue(e)}
/>
</td>
<td>
<button
id="add-item"
@@ -191,7 +182,7 @@ const DynamicTable = (props) => {
<hr />
</div>
);
}
};
DynamicTable.propTypes = {
current_keys: PropTypes.array,
current_values: PropTypes.array,
@@ -199,4 +190,4 @@ DynamicTable.propTypes = {
setPropValues: PropTypes.array,
setProp: PropTypes.func,
};
export default DynamicTable;
export default DynamicTable;