Commit a48f617d authored by Théophile BORNON's avatar Théophile BORNON

if coeff = 0 then hide

if type text coeff = 0
parent def607a2
......@@ -40,8 +40,12 @@ function SubCategory(props) {
else if (e.target.type === "number" && parseInt(e.target.value) >= 1)
setCoefficient({ id: subCategory.id, coeff: parseInt(e.target.value) });
else if (e.target.type === "checkbox")
if (e.target.id === "type")
if (e.target.id === "type") {
update = { ...subCategory, type: (e.target.checked ? "text" : "") };
if (e.target.checked) setCoefficient({ id: subCategory.id, coeff: 0 });
else setCoefficient({ id: subCategory.id, coeff: 1 });
}
else
update = { ...subCategory, [e.target.id]: e.target.checked };
......@@ -51,7 +55,7 @@ function SubCategory(props) {
const deleteSubCategory = () => {
if (window.confirm("Êtes vous sûr de vouloir supprimer cette sous catégorie ?")) {
setCoefficient({id: subCategory.id, coeff: 0})
setCoefficient({ id: subCategory.id, coeff: 0 })
deleteElement(subCategory.id)
}
}
......@@ -65,7 +69,13 @@ function SubCategory(props) {
aria-controls="panel1a-content"
id="panel1a-header"
>
<Typography className={classes.heading}>{subCategory.name} ({Math.round(subCategory.coeff / props.totalCoeff * 10000) / 100}%)</Typography>
<Typography className={classes.heading}>{subCategory.name}
{subCategory.coeff === 0 &&
<>
({Math.round(subCategory.coeff / props.totalCoeff * 10000) / 100} %)
</>
}
</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment