diff --git a/src/components/CreateProject/ResourceAllocation.tsx b/src/components/CreateProject/ResourceAllocation.tsx index c342ab5..05cb459 100644 --- a/src/components/CreateProject/ResourceAllocation.tsx +++ b/src/components/CreateProject/ResourceAllocation.tsx @@ -30,6 +30,10 @@ interface Props { grades: Grade[]; } +const baseCellSx: SxProps = { + textAlign: "right", +}; + const leftBorderCellSx: SxProps = { borderLeft: "1px solid", borderColor: "divider", @@ -142,11 +146,11 @@ const ResourceAllocationByGrade: React.FC = ({ grades }) => { {t("Allocation Type")} {grades.map((column, idx) => ( - + {column.name} ))} - {t("Total")} + {t("Total")} @@ -160,12 +164,12 @@ const ResourceAllocationByGrade: React.FC = ({ grades }) => { // renderValue={(val) => percentFormatter.format(val)} onChange={makeUpdatePercentage(column.id)} convertValue={(inputValue) => Number(inputValue)} - cellSx={{ backgroundColor: "primary.lightest" }} - inputSx={{ width: "3rem" }} + cellSx={{ ...baseCellSx, backgroundColor: "primary.lightest" }} + inputSx={{ ...baseCellSx, width: "3rem" }} error={manhourPercentageByGrade[column.id] < 0} /> ))} - + {((totalPercentage.toString().includes(".") && totalPercentage.toString() || totalPercentage.toFixed(1)) + "%")} {/* {percentFormatter.format(totalPercentage)} */} @@ -173,13 +177,13 @@ const ResourceAllocationByGrade: React.FC = ({ grades }) => { {t("Manhour")} {grades.map((column, idx) => ( - + {manhourFormatter.format( manhourPercentageByGrade[column.id] / 100 * totalManhour, )} ))} - + {manhourFormatter.format(totalManhour)} @@ -255,7 +259,7 @@ const ResourceAllocationByStage: React.FC = ({ grades, allTasks }) => { {t("Stage")} {t("Task Count")} - + {t("Total Manhour")} {grades.map((column, idx) => ( @@ -269,7 +273,7 @@ const ResourceAllocationByStage: React.FC = ({ grades, allTasks }) => { {taskGroups.map((tg, idx) => ( {tg.name} - + {currentTaskGroups[tg.id].taskIds.length} = ({ grades, allTasks }) => { onChange={makeUpdatePercentage(tg.id)} convertValue={(inputValue) => Number(inputValue)} cellSx={{ + ...baseCellSx, backgroundColor: "primary.lightest", }} - inputSx={{ width: "3rem" }} + inputSx={{ ...baseCellSx, width: "3rem" }} error={currentTaskGroups[tg.id].percentAllocation < 0} /> - + {manhourFormatter.format( currentTaskGroups[tg.id].percentAllocation / 100 * totalManhour, )} @@ -293,7 +298,7 @@ const ResourceAllocationByStage: React.FC = ({ grades, allTasks }) => { const stageHours = currentTaskGroups[tg.id].percentAllocation / 100 * totalManhour; return ( - + {manhourFormatter.format( manhourPercentageByGrade[column.id] / 100 * stageHours, )} @@ -304,13 +309,13 @@ const ResourceAllocationByStage: React.FC = ({ grades, allTasks }) => { ))} {t("Total")} - + {Object.values(currentTaskGroups).reduce( (acc, tg) => acc + tg.taskIds.length, 0, )} - acc + tg.percentAllocation, 0,) === 100 && leftBorderCellSx), ...(Object.values(currentTaskGroups).reduce((acc, tg) => acc + tg.percentAllocation, 0,) !== 100 && errorCellSx) }} @@ -337,7 +342,7 @@ const ResourceAllocationByStage: React.FC = ({ grades, allTasks }) => { 0, ).toFixed(1) + "%" } */} - + {manhourFormatter.format( Object.values(currentTaskGroups).reduce( (acc, tg) => acc + tg.percentAllocation / 100 * totalManhour, @@ -355,7 +360,7 @@ const ResourceAllocationByStage: React.FC = ({ grades, allTasks }) => { 0, ); return ( - + {manhourFormatter.format(hours)} ); diff --git a/src/components/CreateTaskTemplate/ResourceAllocation.tsx b/src/components/CreateTaskTemplate/ResourceAllocation.tsx index ddc0594..b2c2b3e 100644 --- a/src/components/CreateTaskTemplate/ResourceAllocation.tsx +++ b/src/components/CreateTaskTemplate/ResourceAllocation.tsx @@ -27,6 +27,10 @@ interface Props { grades: Grade[]; } +const baseCellSx: SxProps = { + textAlign: "right", +}; + const leftBorderCellSx: SxProps = { borderLeft: "1px solid", borderColor: "divider", @@ -104,11 +108,11 @@ const ResourceAllocationByGrade: React.FC = ({ grades }) => { {t("Allocation Type")} {grades.map((column, idx) => ( - + {column.name} ))} - {t("Total")} + {t("Total")} @@ -122,12 +126,12 @@ const ResourceAllocationByGrade: React.FC = ({ grades }) => { // renderValue={(val) => val.toFixed(1) + "%"} onChange={makeUpdatePercentage(column.id)} convertValue={(inputValue) => Number(inputValue)} - cellSx={{ backgroundColor: "primary.lightest" }} - inputSx={{ width: "3rem" }} + cellSx={{ ...baseCellSx, backgroundColor: "primary.lightest" }} + inputSx={{ ...baseCellSx, width: "3rem" }} error={manhourPercentageByGrade[column.id] < 0} /> ))} - + {((totalPercentage.toString().includes(".") && totalPercentage.toString() || totalPercentage.toFixed(1) )+ "%")} {/* {totalPercentage.toFixed(1) + "%"} */} @@ -204,8 +208,8 @@ const ResourceAllocationByStage: React.FC = ({ grades, allTasks }) => { {t("Stage")} - {t("Task Count")} - + {t("Task Count")} + {t("Total Manhour")} @@ -214,7 +218,7 @@ const ResourceAllocationByStage: React.FC = ({ grades, allTasks }) => { {taskGroups.map((tg, idx) => ( {tg.name} - + {currentTaskGroups[tg.id].taskIds.length} = ({ grades, allTasks }) => { onChange={makeUpdatePercentage(tg.id)} convertValue={(inputValue) => Number(inputValue)} cellSx={{ + ...baseCellSx, backgroundColor: "primary.lightest", ...(currentTaskGroups[tg.id].percentAllocation < 0 && { ...errorCellSx, borderBottom: "0px", borderRight: "1px solid", borderColor: "error.main"}) }} - inputSx={{ width: "3rem" }} + inputSx={{ ...baseCellSx, width: "3rem" }} error={currentTaskGroups[tg.id].percentAllocation < 0} /> ))} {t("Total")} - + {Object.values(currentTaskGroups).reduce( (acc, tg) => acc + tg.taskIds.length, 0, )} acc + tg.percentAllocation, 0,) === 100 && leftBorderCellSx), ...(Object.values(currentTaskGroups).reduce((acc, tg) => acc + tg.percentAllocation, 0,) !== 100 && { ...errorCellSx, borderRight: "1px solid", borderColor: "error.main"}) }}