Browse Source

update number digit & alignment

tags/Baseline_30082024_FRONTEND_UAT
kelvinsuen 1 year ago
parent
commit
0f8f3bd5be
6 changed files with 96 additions and 95 deletions
  1. +29
    -10
      src/components/CreateProject/ResourceAllocation.tsx
  2. +28
    -7
      src/components/CreateTaskTemplate/ResourceAllocation.tsx
  3. +2
    -2
      src/components/ProgressByClient/ProgressByClient.tsx
  4. +4
    -4
      src/components/ProgressByTeam/ProgressByTeam.tsx
  5. +31
    -70
      src/components/ProjectFinancialSummary/ProjectFinancialCard.tsx
  6. +2
    -2
      src/components/ProjectResourceConsumptionRanking/ProjectResourceConsumptionRanking.tsx

+ 29
- 10
src/components/CreateProject/ResourceAllocation.tsx View File

@@ -63,10 +63,14 @@ const ResourceAllocationByGrade: React.FC<Props> = ({ grades }) => {


const manhourPercentageByGrade = watch("manhourPercentageByGrade"); const manhourPercentageByGrade = watch("manhourPercentageByGrade");
const totalManhour = watch("totalManhour"); const totalManhour = watch("totalManhour");
const totalPercentage = Math.round(Object.values(manhourPercentageByGrade).reduce(
const totalPercentage = Object.values(manhourPercentageByGrade).reduce(
(acc, percent) => acc + percent, (acc, percent) => acc + percent,
0, 0,
) * 100) / 100;
);
// const totalPercentage = Math.round(Object.values(manhourPercentageByGrade).reduce(
// (acc, percent) => acc + percent,
// 0,
// ) * 100) / 100;


const makeUpdatePercentage = useCallback( const makeUpdatePercentage = useCallback(
(gradeId: Grade["id"]) => (percentage?: number) => { (gradeId: Grade["id"]) => (percentage?: number) => {
@@ -152,7 +156,7 @@ const ResourceAllocationByGrade: React.FC<Props> = ({ grades }) => {
<TableCellEdit <TableCellEdit
key={`${column.id}${idx}`} key={`${column.id}${idx}`}
value={manhourPercentageByGrade[column.id]} value={manhourPercentageByGrade[column.id]}
renderValue={(val) => val + "%"}
renderValue={((val) => (val.toString().includes(".")? val.toString() : val.toFixed(1)) + "%")}
// renderValue={(val) => percentFormatter.format(val)} // renderValue={(val) => percentFormatter.format(val)}
onChange={makeUpdatePercentage(column.id)} onChange={makeUpdatePercentage(column.id)}
convertValue={(inputValue) => Number(inputValue)} convertValue={(inputValue) => Number(inputValue)}
@@ -162,7 +166,7 @@ const ResourceAllocationByGrade: React.FC<Props> = ({ grades }) => {
/> />
))} ))}
<TableCell sx={{ ...(totalPercentage === 100 && leftBorderCellSx), ...(totalPercentage !== 100 && { ...errorCellSx, borderRight: "1px solid", borderColor: "error.main" }) }}> <TableCell sx={{ ...(totalPercentage === 100 && leftBorderCellSx), ...(totalPercentage !== 100 && { ...errorCellSx, borderRight: "1px solid", borderColor: "error.main" }) }}>
{totalPercentage + "%"}
{((totalPercentage.toString().includes(".") && totalPercentage.toString() || totalPercentage.toFixed(1)) + "%")}
{/* {percentFormatter.format(totalPercentage)} */} {/* {percentFormatter.format(totalPercentage)} */}
</TableCell> </TableCell>
</TableRow> </TableRow>
@@ -271,7 +275,7 @@ const ResourceAllocationByStage: React.FC<Props> = ({ grades, allTasks }) => {
<TableCellEdit <TableCellEdit
value={currentTaskGroups[tg.id].percentAllocation} value={currentTaskGroups[tg.id].percentAllocation}
// renderValue={(val) => percentFormatter.format(val)} // renderValue={(val) => percentFormatter.format(val)}
renderValue={(val) => val + "%"}
renderValue={(val) => ((val.toString().includes(".")? val.toString() : val.toFixed(1)) + "%")}
onChange={makeUpdatePercentage(tg.id)} onChange={makeUpdatePercentage(tg.id)}
convertValue={(inputValue) => Number(inputValue)} convertValue={(inputValue) => Number(inputValue)}
cellSx={{ cellSx={{
@@ -311,12 +315,27 @@ const ResourceAllocationByStage: React.FC<Props> = ({ grades, allTasks }) => {
...(Object.values(currentTaskGroups).reduce((acc, tg) => acc + tg.percentAllocation, 0,) !== 100 && errorCellSx) ...(Object.values(currentTaskGroups).reduce((acc, tg) => acc + tg.percentAllocation, 0,) !== 100 && errorCellSx)
}} }}
> >
{percentFormatter.format(
Object.values(currentTaskGroups).reduce(
(acc, tg) => acc + tg.percentAllocation / 100,
{((Object.values(currentTaskGroups).reduce(
(acc, tg) => acc + tg.percentAllocation,
0, 0,
),
)}
).toString().includes(".") && Object.values(currentTaskGroups).reduce(
(acc, tg) => acc + tg.percentAllocation,
0,) || Object.values(currentTaskGroups).reduce(
(acc, tg) => (acc + tg.percentAllocation),
0,
).toFixed(1)) + "%" )}
{/* {percentFormatter.format(
Object.values(currentTaskGroups).reduce(
(acc, tg) => acc + tg.percentAllocation / 100,
0,
),
).includes(".") && percentFormatter.format(Object.values(currentTaskGroups).reduce(
(acc, tg) => acc + tg.percentAllocation / 100,
0,),
) || Object.values(currentTaskGroups).reduce(
(acc, tg) => (acc + tg.percentAllocation),
0,
).toFixed(1) + "%" } */}
</TableCell> </TableCell>
<TableCell sx={rightBorderCellSx}> <TableCell sx={rightBorderCellSx}>
{manhourFormatter.format( {manhourFormatter.format(


+ 28
- 7
src/components/CreateTaskTemplate/ResourceAllocation.tsx View File

@@ -53,10 +53,14 @@ const ResourceAllocationByGrade: React.FC<Props> = ({ grades }) => {
const { watch, register, setValue, formState: { errors }, setError, clearErrors } = useFormContext<NewTaskTemplateFormInputs>(); const { watch, register, setValue, formState: { errors }, setError, clearErrors } = useFormContext<NewTaskTemplateFormInputs>();


const manhourPercentageByGrade = watch("manhourPercentageByGrade"); const manhourPercentageByGrade = watch("manhourPercentageByGrade");
const totalPercentage = Math.round(Object.values(manhourPercentageByGrade).reduce(
const totalPercentage = Object.values(manhourPercentageByGrade).reduce(
(acc, percent) => acc + percent, (acc, percent) => acc + percent,
0, 0,
) * 100) / 100;
);
// const totalPercentage = Math.round(Object.values(manhourPercentageByGrade).reduce(
// (acc, percent) => acc + percent,
// 0,
// ) * 100) / 100;


const makeUpdatePercentage = useCallback( const makeUpdatePercentage = useCallback(
(gradeId: Grade["id"]) => (percentage?: number) => { (gradeId: Grade["id"]) => (percentage?: number) => {
@@ -114,7 +118,8 @@ const ResourceAllocationByGrade: React.FC<Props> = ({ grades }) => {
<TableCellEdit <TableCellEdit
key={`${column.id}${idx}`} key={`${column.id}${idx}`}
value={manhourPercentageByGrade[column.id]} value={manhourPercentageByGrade[column.id]}
renderValue={(val) => val + "%"}
renderValue={(val) => ((val.toString().includes(".")? val.toString() : val.toFixed(1)) + "%")}
// renderValue={(val) => val.toFixed(1) + "%"}
onChange={makeUpdatePercentage(column.id)} onChange={makeUpdatePercentage(column.id)}
convertValue={(inputValue) => Number(inputValue)} convertValue={(inputValue) => Number(inputValue)}
cellSx={{ backgroundColor: "primary.lightest" }} cellSx={{ backgroundColor: "primary.lightest" }}
@@ -123,7 +128,8 @@ const ResourceAllocationByGrade: React.FC<Props> = ({ grades }) => {
/> />
))} ))}
<TableCell sx={{ ...(totalPercentage === 100 && leftBorderCellSx), ...(totalPercentage !== 100 && { ...errorCellSx, borderRight: "1px solid", borderColor: "error.main" }) }}> <TableCell sx={{ ...(totalPercentage === 100 && leftBorderCellSx), ...(totalPercentage !== 100 && { ...errorCellSx, borderRight: "1px solid", borderColor: "error.main" }) }}>
{totalPercentage + "%"}
{((totalPercentage.toString().includes(".") && totalPercentage.toString() || totalPercentage.toFixed(1) )+ "%")}
{/* {totalPercentage.toFixed(1) + "%"} */}
</TableCell> </TableCell>
</TableRow> </TableRow>
</TableBody> </TableBody>
@@ -214,7 +220,7 @@ const ResourceAllocationByStage: React.FC<Props> = ({ grades, allTasks }) => {
<TableCellEdit <TableCellEdit
value={currentTaskGroups[tg.id].percentAllocation} value={currentTaskGroups[tg.id].percentAllocation}
// renderValue={(val) => percentFormatter.format(val)} // renderValue={(val) => percentFormatter.format(val)}
renderValue={(val) => val + "%"}
renderValue={(val) => ((val.toString().includes(".")? val.toString() : val.toFixed(1)) + "%")}
onChange={makeUpdatePercentage(tg.id)} onChange={makeUpdatePercentage(tg.id)}
convertValue={(inputValue) => Number(inputValue)} convertValue={(inputValue) => Number(inputValue)}
cellSx={{ cellSx={{
@@ -239,12 +245,27 @@ const ResourceAllocationByStage: React.FC<Props> = ({ grades, allTasks }) => {
...(Object.values(currentTaskGroups).reduce((acc, tg) => acc + tg.percentAllocation, 0,) !== 100 && { ...errorCellSx, borderRight: "1px solid", borderColor: "error.main"}) ...(Object.values(currentTaskGroups).reduce((acc, tg) => acc + tg.percentAllocation, 0,) !== 100 && { ...errorCellSx, borderRight: "1px solid", borderColor: "error.main"})
}} }}
> >
{percentFormatter.format(
{((Object.values(currentTaskGroups).reduce(
(acc, tg) => acc + tg.percentAllocation,
0,
).toString().includes(".") && Object.values(currentTaskGroups).reduce(
(acc, tg) => acc + tg.percentAllocation,
0,) || Object.values(currentTaskGroups).reduce(
(acc, tg) => (acc + tg.percentAllocation),
0,
).toFixed(1)) + "%" )}
{/* {percentFormatter.format(
Object.values(currentTaskGroups).reduce( Object.values(currentTaskGroups).reduce(
(acc, tg) => acc + tg.percentAllocation / 100, (acc, tg) => acc + tg.percentAllocation / 100,
0, 0,
), ),
)}
).includes(".") && percentFormatter.format(Object.values(currentTaskGroups).reduce(
(acc, tg) => acc + tg.percentAllocation / 100,
0,),
) || Object.values(currentTaskGroups).reduce(
(acc, tg) => (acc + tg.percentAllocation),
0,
).toFixed(1) + "%" } */}
</TableCell> </TableCell>
</TableRow> </TableRow>
</TableBody> </TableBody>


+ 2
- 2
src/components/ProgressByClient/ProgressByClient.tsx View File

@@ -385,7 +385,7 @@ const ProgressByClient: React.FC<Props> = () => {
enabled: true, enabled: true,
y: { y: {
formatter: function (val) { formatter: function (val) {
return val.toFixed(1) + "%";
return (val.toString().includes(".") ? val.toString() : val.toFixed(1)) + "%";
} }
} }
}, },
@@ -427,7 +427,7 @@ const ProgressByClient: React.FC<Props> = () => {
<br> <br>
${t("Spent Manhours")}: ${spentManhours.toFixed(2)} hours ${t("Spent Manhours")}: ${spentManhours.toFixed(2)} hours
<br> <br>
Percentage: ${value.toFixed(1)}%
Percentage: ${value.toString().includes(".") ? value.toString() : value.toFixed(1)}%
</div> </div>
`; `;




+ 4
- 4
src/components/ProgressByTeam/ProgressByTeam.tsx View File

@@ -468,7 +468,7 @@ const ProgressByTeam: React.FC = () => {
enabled: true, enabled: true,
y: { y: {
formatter: function (val) { formatter: function (val) {
return val.toFixed(1) + "%";
return (val.toString().includes(".") ? val.toString() : val.toFixed(1)) + "%";
} }
} }
}, },
@@ -505,9 +505,9 @@ const ProgressByTeam: React.FC = () => {
const tooltipContent = ` const tooltipContent = `
<div style="width: auto;"> <div style="width: auto;">
<span style="font-weight: bold;">${projectCode} - ${projectName}</span> <span style="font-weight: bold;">${projectCode} - ${projectName}</span>
<br>${t("Budget Manhours")}:${budgetManhours.toFixed(2)} hours
<br>${t("Spent Manhours")}:${spentManhours.toFixed(2)} hours
<br>Percentage:${value.toFixed(1)}%
<br>${t("Budget Manhours")}: ${budgetManhours.toFixed(2)} hours
<br>${t("Spent Manhours")}: ${spentManhours.toFixed(2)} hours
<br>Percentage: ${value.toString().includes(".") ? value.toString() : value.toFixed(1)}%
</div> </div>
`; `;




+ 31
- 70
src/components/ProjectFinancialSummary/ProjectFinancialCard.tsx View File

@@ -35,6 +35,10 @@ interface Props {
Index: number; Index: number;
} }


const dataBaseStyle:any = { color: "#6b87cf", textAlign: "right" }
const dataNegativeStyle:any = { color: "#f896aa", textAlign: "right" }
const dataPositiveStyle:any = { color: "#71d19e", textAlign: "right" }

const ProjectFinancialCard: React.FC<Props> = ({ const ProjectFinancialCard: React.FC<Props> = ({
Title, Title,
TotalActiveProjectNumber, TotalActiveProjectNumber,
@@ -77,74 +81,63 @@ const ProjectFinancialCard: React.FC<Props> = ({
{Title} {Title}
</div> </div>
<hr /> <hr />
<div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
<div className="text-sm font-medium mx-5" style={{ color: "#898d8d" }}>
{t("Total Active Project")} {t("Total Active Project")}
</div> </div>
<div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
<div className="text-lg font-medium mx-5" style={dataBaseStyle}>
{TotalActiveProjectNumber.toLocaleString()} {TotalActiveProjectNumber.toLocaleString()}
</div> </div>
<hr /> <hr />
<div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
<div className="text-sm font-medium mx-5" style={{ color: "#898d8d" }}>
{t("Total Fees")} {t("Total Fees")}
</div> </div>
<div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
<div className="text-lg font-medium mx-5" style={dataBaseStyle}>
{TotalFees.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} {TotalFees.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
</div> </div>
<hr /> <hr />
<div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
<div className="text-sm font-medium mx-5" style={{ color: "#898d8d" }}>
{t("Total Budget")} {t("Total Budget")}
</div> </div>
<div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
<div className="text-lg font-medium mx-5" style={dataBaseStyle}>
{TotalBudget.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} {TotalBudget.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
</div> </div>
<hr /> <hr />
<div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
<div className="text-sm font-medium mx-5" style={{ color: "#898d8d" }}>
{t("Total Cumulative Expenditure")} {t("Total Cumulative Expenditure")}
</div> </div>
<div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
<div className="text-lg font-medium mx-5" style={dataBaseStyle}>
{TotalCumulative.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} {TotalCumulative.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
</div> </div>
<hr /> <hr />
<div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
<div className="text-sm font-medium mx-5" style={{ color: "#898d8d" }}>
{t("Total Invoiced Amount")} {t("Total Invoiced Amount")}
</div> </div>
<div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
<div className="text-lg font-medium mx-5" style={dataBaseStyle}>
{TotalInvoicedAmount.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} {TotalInvoicedAmount.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
</div> </div>
<hr /> <hr />
<div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
<div className="text-sm font-medium mx-5" style={{ color: "#898d8d" }}>
{t("Total Un-Invoiced Amount")} {t("Total Un-Invoiced Amount")}
</div> </div>
<div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
<div className="text-lg font-medium mx-5" style={dataBaseStyle}>
{TotalUnInvoicedAmount.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} {TotalUnInvoicedAmount.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
</div> </div>
<hr /> <hr />
<div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
<div className="text-sm font-medium mx-5" style={{ color: "#898d8d" }}>
{t("Total Received Amount")} {t("Total Received Amount")}
</div> </div>
<div className="text-lg font-medium ml-5" style={{ color: "#6b87cf" }}>
<div className="text-lg font-medium mx-5" style={dataBaseStyle}>
{TotalReceivedAmount.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} {TotalReceivedAmount.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
</div> </div>
<hr /> <hr />
<div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
<div className="text-sm font-medium mx-5" style={{ color: "#898d8d" }}>
{t("Cash Flow Status")} {t("Cash Flow Status")}
</div> </div>
{CashFlowStatus === "Negative" && ( {CashFlowStatus === "Negative" && (
<> <>
<div <div
className="text-lg font-medium ml-5"
style={{ color: "#f896aa" }}
>
{t(CashFlowStatus)}
</div>
<hr />
</>
)}
{CashFlowStatus === "Positive" && (
<>
<div
className="text-lg font-medium ml-5"
style={{ color: "#71d19e" }}
className="text-lg font-medium mx-5"
style={CashFlowStatus === "Negative" && dataNegativeStyle || dataPositiveStyle}
> >
{t(CashFlowStatus)} {t(CashFlowStatus)}
</div> </div>
@@ -152,52 +145,30 @@ const ProjectFinancialCard: React.FC<Props> = ({
</> </>
)} )}
<div <div
className="text-sm mt-2 font-medium ml-5"
className="text-sm mt-2 font-medium mx-5"
style={{ color: "#898d8d" }} style={{ color: "#898d8d" }}
> >
{t("Cost Performance Index") + " (CPI)"} {t("Cost Performance Index") + " (CPI)"}
</div> </div>
{Number(CostPerformanceIndex) < 1 && (
<>
<div
className="text-lg font-medium ml-5 mb-2"
style={{ color: "#f896aa" }}
>
{CostPerformanceIndex}
</div>
<hr />
</>
)}
{Number(CostPerformanceIndex) >= 1 && (
{ (
<> <>
<div <div
className="text-lg font-medium ml-5 mb-2"
style={{ color: "#71d19e" }}
className="text-lg font-medium mx-5 mb-2"
style={Number(CostPerformanceIndex) < 1 && dataNegativeStyle || dataPositiveStyle}
> >
{CostPerformanceIndex} {CostPerformanceIndex}
</div> </div>
<hr /> <hr />
</> </>
)} )}
<div className="text-sm font-medium ml-5" style={{ color: "#898d8d" }}>
<div className="text-sm font-medium mx-5" style={{ color: "#898d8d" }}>
{t("Projected Cash Flow Status")} {t("Projected Cash Flow Status")}
</div> </div>
{ProjectedCashFlowStatus === "Negative" && ( {ProjectedCashFlowStatus === "Negative" && (
<> <>
<div <div
className="text-lg font-medium ml-5"
style={{ color: "#f896aa" }}
>
{t(ProjectedCashFlowStatus)}
</div>
<hr />
</>
)}
{ProjectedCashFlowStatus === "Positive" && (
<>
<div
className="text-lg font-medium ml-5"
style={{ color: "#71d19e" }}
className="text-lg font-medium mx-5"
style={ProjectedCashFlowStatus === "Negative" && dataNegativeStyle || dataPositiveStyle}
> >
{t(ProjectedCashFlowStatus)} {t(ProjectedCashFlowStatus)}
</div> </div>
@@ -205,7 +176,7 @@ const ProjectFinancialCard: React.FC<Props> = ({
</> </>
)} )}
<div <div
className="text-sm mt-2 font-medium ml-5"
className="text-sm mt-2 font-medium mx-5"
style={{ color: "#898d8d" }} style={{ color: "#898d8d" }}
> >
{t("Projected Cost Performance Index") + " (CPI)"} {t("Projected Cost Performance Index") + " (CPI)"}
@@ -213,18 +184,8 @@ const ProjectFinancialCard: React.FC<Props> = ({
{Number(ProjectedCPI) < 1 && ( {Number(ProjectedCPI) < 1 && (
<> <>
<div <div
className="text-lg font-medium ml-5 mb-2"
style={{ color: "#f896aa" }}
>
{ProjectedCPI}
</div>
</>
)}
{Number(ProjectedCPI) >= 1 && (
<>
<div
className="text-lg font-medium ml-5 mb-2"
style={{ color: "#71d19e" }}
className="text-lg font-medium mx-5 mb-2"
style={Number(ProjectedCPI) < 1 && dataNegativeStyle || dataPositiveStyle}
> >
{ProjectedCPI} {ProjectedCPI}
</div> </div>


+ 2
- 2
src/components/ProjectResourceConsumptionRanking/ProjectResourceConsumptionRanking.tsx View File

@@ -554,7 +554,7 @@ const ProjectResourceConsumptionRanking: React.FC = () => {
enabled: true, enabled: true,
y: { y: {
formatter: function (val) { formatter: function (val) {
return val.toFixed(1) + "%";
return (val.toString().includes(".") ? val.toString() : val.toFixed(1)) + "%";
} }
} }
}, },
@@ -596,7 +596,7 @@ const ProjectResourceConsumptionRanking: React.FC = () => {
<br> <br>
${t("Spent Manhours")}: ${spentManhours.toFixed(2)} ${t("hours")} ${t("Spent Manhours")}: ${spentManhours.toFixed(2)} ${t("hours")}
<br> <br>
Percentage: ${value.toFixed(1)}%
Percentage: ${value.toString().includes(".") ? value.toString() : value.toFixed(1)}%
</div> </div>
`; `;




Loading…
Cancel
Save