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) { ...@@ -40,8 +40,12 @@ function SubCategory(props) {
else if (e.target.type === "number" && parseInt(e.target.value) >= 1) else if (e.target.type === "number" && parseInt(e.target.value) >= 1)
setCoefficient({ id: subCategory.id, coeff: parseInt(e.target.value) }); setCoefficient({ id: subCategory.id, coeff: parseInt(e.target.value) });
else if (e.target.type === "checkbox") else if (e.target.type === "checkbox")
if (e.target.id === "type") if (e.target.id === "type") {
update = { ...subCategory, type: (e.target.checked ? "text" : "") }; 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 else
update = { ...subCategory, [e.target.id]: e.target.checked }; update = { ...subCategory, [e.target.id]: e.target.checked };
...@@ -51,7 +55,7 @@ function SubCategory(props) { ...@@ -51,7 +55,7 @@ function SubCategory(props) {
const deleteSubCategory = () => { const deleteSubCategory = () => {
if (window.confirm("Êtes vous sûr de vouloir supprimer cette sous catégorie ?")) { 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) deleteElement(subCategory.id)
} }
} }
...@@ -65,7 +69,13 @@ function SubCategory(props) { ...@@ -65,7 +69,13 @@ function SubCategory(props) {
aria-controls="panel1a-content" aria-controls="panel1a-content"
id="panel1a-header" 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> </ExpansionPanelSummary>
<ExpansionPanelDetails> <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