upgraded progress

This commit is contained in:
pramod.mahajan 2025-10-10 10:55:51 +05:30
parent 6280abf95e
commit f8095ac9bf
4 changed files with 92 additions and 19 deletions

View File

@ -179,7 +179,7 @@ const ListViewContact = ({ data, Pagination }) => {
<tr style={{ height: "200px" }}> <tr style={{ height: "200px" }}>
<td <td
colSpan={contactList.length + 1} colSpan={contactList.length + 1}
className="text-center align-middle" className="text-center border-0 align-middle"
> >
No contacts found No contacts found
</td> </td>

View File

@ -108,7 +108,7 @@ const WorkArea = ({ workArea, floor, forBuilding }) => {
<ProgressBar <ProgressBar
completedWork={formatNumber(workArea?.completedWork)} completedWork={formatNumber(workArea?.completedWork)}
plannedWork={formatNumber(workArea?.plannedWork)} plannedWork={formatNumber(workArea?.plannedWork)}
className="m-0 my-2 me-6 text-info" className="m-0 my-2 " height="6px"rounded showLabel={true}
/> />
</div> </div>
</div> </div>

View File

@ -3,35 +3,65 @@ import React from "react";
const ProgressBar = ({ const ProgressBar = ({
plannedWork = 100, plannedWork = 100,
completedWork = 0, completedWork = 0,
height = "8px", height = "6px",
className = "mb-4", className = "mb-4",
rounded = true, rounded = true,
showLabel = true,
}) => { }) => {
const getProgress = (planned, completed) => { const getProgress = (planned, completed) => {
if (!planned || planned === 0) return "0%"; if (!planned || planned === 0) return 0;
return `${Math.min((completed / planned) * 100, 100).toFixed(2)}%`; return Math.min((completed / planned) * 100, 100);
}; };
const progressStyle = { const percentage = getProgress(plannedWork, completedWork);
width: getProgress(plannedWork, completedWork),
const progressBarStyle = {
width: ` ${percentage.toFixed(2)}%`,
transition: "width 0.4s ease",
};
const containerStyle = {
height,
display: "flex",
alignItems: "center",
gap: "8px",
}; };
return ( return (
<div <div
className={`progress ${className} ${rounded ? "rounded" : ""}`} className={`d-flex align-items-center ${className}`}
style={{ height }} style={containerStyle}
> >
<div <div className="flex-grow-1">
className={`progress-bar ${rounded ? "rounded" : ""}`} <div
role="progressbar" className={`progress ${rounded ? "rounded" : ""}`}
style={progressStyle} style={{ height, backgroundColor: "#f0f0f0" }}
aria-valuenow={completedWork} >
aria-valuemin="0" <div
aria-valuemax={plannedWork} className={`progress-bar ${rounded ? "rounded" : ""}`}
></div> role="progressbar"
style={progressBarStyle}
aria-valuenow={completedWork}
aria-valuemin="0"
aria-valuemax={plannedWork}
/>
</div>
</div>
{showLabel && (
<span
className="fw-semibold text-secondary"
style={{
minWidth: "45px",
textAlign: "right",
fontSize: "0.8rem",
}}
>
{percentage.toFixed(2)}%
</span>
)}
</div> </div>
); );
}; };
export default ProgressBar; export default ProgressBar;

View File

@ -91,4 +91,47 @@ const date = new Date(
Date.UTC(Number(year), Number(month) - 1, Number(day), 0, 0, 0) Date.UTC(Number(year), Number(month) - 1, Number(day), 0, 0, 0)
); );
return isNaN(date.getTime()) ? null : date.toISOString(); return isNaN(date.getTime()) ? null : date.toISOString();
} }
/**
* Flexible number formatter for currency, numbers, or percentages.
*
* @param {number} amount - The value to format.
* @param {Object} options - Formatting options.
* @param {"currency"|"number"|"percent"} [options.type="number"] - Type of format.
* @param {string} [options.currency="INR"] - Currency code (only used when type="currency").
* @param {string} [options.locale="en-US"] - Locale for formatting.
* @param {"short"|"long"|"standard"} [options.notation="compact"] - Display style for large numbers.
* @param {number} [options.minimumFractionDigits=0] - Minimum decimal places.
* @param {number} [options.maximumFractionDigits=2] - Maximum decimal places.
* @returns {string} Formatted number string.
*/
export const formatFigure = (
amount,
{
type = "number",
currency = "INR",
locale = "en-US",
notation = "compact",
compactDisplay = "short",
minimumFractionDigits = 0,
maximumFractionDigits = 2,
} = {}
) => {
if (amount == null || isNaN(amount)) return "-";
const formatterOptions = {
style: type === "currency" ? "currency" : type === "percent" ? "percent" : "decimal",
notation: notation,
compactDisplay,
minimumFractionDigits,
maximumFractionDigits,
};
if (type === "currency") {
formatterOptions.currency = currency;
}
return new Intl.NumberFormat(locale, formatterOptions).format(amount);
};