From 065c9b56780ce7a0ef8516cb4477d703250ef0db Mon Sep 17 00:00:00 2001 From: MehrdadAdabi <126083584+mehrdadAdabi@users.noreply.github.com> Date: Sun, 24 Aug 2025 10:43:28 +0330 Subject: [PATCH] feat: create progressbar for dialog --- .../digital-innovation-page.tsx | 167 ++++++++++++++---- 1 file changed, 134 insertions(+), 33 deletions(-) diff --git a/app/components/dashboard/project-management/digital-innovation-page.tsx b/app/components/dashboard/project-management/digital-innovation-page.tsx index 10a6116..d7a4afe 100644 --- a/app/components/dashboard/project-management/digital-innovation-page.tsx +++ b/app/components/dashboard/project-management/digital-innovation-page.tsx @@ -41,6 +41,7 @@ import { LoaderCircle, } from "lucide-react"; import { CustomBarChart } from "~/components/ui/custom-bar-chart"; +import { color } from "d3"; moment.loadPersian({ usePersianDigits: true }); @@ -99,6 +100,18 @@ interface ProcessInnovationData { project_description: string; } +interface HouseItem { + index: number; + color?: string; + style?: string; +} + +interface ListItem { + label: string; + development: number; + house: HouseItem[]; +} + const columns = [ // { key: "select", label: "", sortable: false, width: "50px" }, { key: "project_no", label: "شماره پروژه", sortable: true, width: "140px" }, @@ -472,35 +485,94 @@ export function DigitalInnovationPage() { return new Intl.NumberFormat("fa-IR").format(numericAmount) + " ریال"; }; - const formatPercentage = (value: string | number) => { - if (!value) return "0%"; - const numericValue = typeof value === "string" ? parseFloat(value) : value; - if (isNaN(numericValue)) return "0%"; - return `${numericValue.toFixed(1)}%`; - }; + // const formatPercentage = (value: string | number) => { + // if (!value) return "0%"; + // const numericValue = typeof value === "string" ? parseFloat(value) : value; + // if (isNaN(numericValue)) return "0%"; + // return `${numericValue.toFixed(1)}%`; + // }; - const getStatusColor = (status: string) => { - switch (status?.toLowerCase()) { - case "فعال": - return "#3AEA83"; - case "متوقف": - return "#F76276"; - case "تکمیل شده": - return "#32CD32"; - default: - return "#6B7280"; + // const getStatusColor = (status: string) => { + // switch (status?.toLowerCase()) { + // case "فعال": + // return "#3AEA83"; + // case "متوقف": + // return "#F76276"; + // case "تکمیل شده": + // return "#32CD32"; + // default: + // return "#6B7280"; + // } + // }; + + // const getRatingColor = (rating: string) => { + // const ratingNum = parseFloat(rating); + // if (isNaN(ratingNum)) return "#6B7280"; + + // if (ratingNum >= 8) return "#3AEA83"; + // if (ratingNum >= 6) return "#69C8EA"; + // if (ratingNum >= 4) return "#FFD700"; + // return "#F76276"; + // }; + + const [list, setList] = useState([ + { + label: "فرآیند1", + development: 40, + house: [], + }, + { + label: "فرآیند2", + development: 30, + house: [], + }, + { + label: "فرآیند3", + development: 40, + house: [], + }, + { + label: "فرآیند4", + development: 50, + house: [], + }, + { + label: "فرآیند5", + development: 91.6, + house: [], + }, + ]); + const renderProgress = () => { + const total = 10; + for (let i = 0; i < list.length; i++) { + const currentElm = list[i]; + currentElm.house = []; + const greenBoxes = Math.floor((total * currentElm.development) / 100); + const partialPercent = + (total * currentElm.development) / 100 - greenBoxes; + for (let j = 0; j < greenBoxes; j++) { + currentElm.house.push({ + index: j, + color: "!bg-emerald-400", + }); + } + if (partialPercent != 0 && greenBoxes != 10) + currentElm.house.push({ + index: greenBoxes + 1, + style: `linear-gradient( + to right, + lch(87 118.17 147.55) 0%, + lch(87 118.17 147.55) ${partialPercent * 100}%, + oklch(55.1% 0.027 264.364) ${partialPercent * 100}%, + oklch(55.1% 0.027 264.364) 100% + )`, + }); } }; - const getRatingColor = (rating: string) => { - const ratingNum = parseFloat(rating); - if (isNaN(ratingNum)) return "#6B7280"; - - if (ratingNum >= 8) return "#3AEA83"; - if (ratingNum >= 6) return "#69C8EA"; - if (ratingNum >= 4) return "#FFD700"; - return "#F76276"; - }; + useEffect(() => { + renderProgress(); + }, []); const renderCellContent = (item: any, column: any) => { const value = item[column.key as keyof ProcessInnovationData]; @@ -841,14 +913,14 @@ export function DigitalInnovationPage() { {/* Project Details Dialog */} - + شرح پروژه -
-
+
+
توسعه فناوری جدید در تولید پلی‌اتیلن @@ -907,7 +979,7 @@ export function DigitalInnovationPage() {
-
+
توسعه قابلیت های دیجیتال:{" "} @@ -994,14 +1066,14 @@ export function DigitalInnovationPage() {
-
-
+
+
کاهش هزینه ها -
+
10% @@ -1022,7 +1094,36 @@ export function DigitalInnovationPage() {
-
+
+
+ عنوان فرآیند + درصد پیشرفت +
+
+ {list.map((el, index) => { + return ( +
+ {el.label} +
+ {Array.from({ length: 10 }, (_, i) => { + return ( + + ); + })} +
+
+ ); + })} +
+