From c23e82604e2e5aa56fa0d32cd4cea95107c06f26 Mon Sep 17 00:00:00 2001 From: MehrdadAdabi <126083584+mehrdadAdabi@users.noreply.github.com> Date: Tue, 26 Aug 2025 17:23:41 +0330 Subject: [PATCH] finish:digital-inovation page --- .../digital-innovation-page.tsx | 177 ++++++++++-------- app/components/ui/table.tsx | 2 +- 2 files changed, 105 insertions(+), 74 deletions(-) diff --git a/app/components/dashboard/project-management/digital-innovation-page.tsx b/app/components/dashboard/project-management/digital-innovation-page.tsx index 9a4364e..15a18df 100644 --- a/app/components/dashboard/project-management/digital-innovation-page.tsx +++ b/app/components/dashboard/project-management/digital-innovation-page.tsx @@ -91,14 +91,29 @@ enum DigitalCardLabel { decreaseEnergy = "کاهش مصرف انرژی", } +enum projectStatus { + propozal = "پروپوزال", + contract = "پیشنویس قرارداد", + inprogress = "در حال انجام", + stop = "متوقف شده", + mafasa = "مرحله مفاصا", + finish = "پایان یافته", +} interface ProcessInnovationData { - project_no: string; - title: string; - project_status: string; - project_rating: string; - project_description: string; - total_project: number; WorkflowID: number; + desired_strategy: string; + digital_capability: string; + digital_competence: string; + digital_puberty_elements: string; + innovation_cost_reduction: number | string; + operational_plan: string; + originality_digital_solution: string; + project_description: string; + project_no: string; + project_rating: number | string; + project_status: string; + reduce_costs_percent: number; + title: string; } interface HouseItem { @@ -162,8 +177,7 @@ export function DigitalInnovationPage() { new Set() ); const [detailsDialogOpen, setDetailsDialogOpen] = useState(false); - // const [selectedProjectDetails, setSelectedProjectDetails] = - // useState(null); + const [avarage, setAvarage] = useState(0); const observerRef = useRef(null); const fetchingRef = useRef(false); @@ -194,7 +208,6 @@ export function DigitalInnovationPage() { return new Intl.NumberFormat("fa-IR").format(numericValue); }; - // Stats cards data - computed from projects data const statsCards: StatsCard[] = [ { id: "production-stops-prevention", @@ -268,9 +281,9 @@ export function DigitalInnovationPage() { "operational_plan", "desired_strategy", "innovation_cost_reduction", - "reduce_costs_percent" + "reduce_costs_percent", ], - Sorts: [["start_date", "asc"]], + Sorts: [[sortConfig.field, sortConfig.direction]], Conditions: [["type_of_innovation", "=", "نوآوری دیجیتال"]], Pagination: { PageNumber: pageToFetch, PageSize: pageSize }, }); @@ -280,10 +293,11 @@ export function DigitalInnovationPage() { const dataString = response.data; if (dataString && typeof dataString === "string") { try { - const parsedData = JSON.parse(dataString); + const parsedData: ProcessInnovationData = JSON.parse(dataString); if (Array.isArray(parsedData)) { if (reset) { setProjects(parsedData); + calculateAverage(parsedData); setTotalCount(parsedData.length); } else { setProjects((prev) => [...prev, ...parsedData]); @@ -331,6 +345,7 @@ export function DigitalInnovationPage() { } finally { setLoading(false); setLoadingMore(false); + fetchingRef.current = false; } }; @@ -385,6 +400,8 @@ export function DigitalInnovationPage() { direction: prev.field === field && prev.direction === "asc" ? "desc" : "asc", })); + fetchTotalCount(); + fetchStats(); setCurrentPage(1); setProjects([]); setHasMore(true); @@ -515,6 +532,30 @@ export function DigitalInnovationPage() { } }, [rating]); + const ststusColor = (status: projectStatus): any => { + let el = null; + switch (status) { + case projectStatus.contract: + el = "teal"; + break; + case projectStatus.finish: + el = "info"; + break; + case projectStatus.stop: + el = "warning"; + break; + case projectStatus.inprogress: + el = "teal"; + break; + case projectStatus.mafasa: + el = "destructive"; + break; + case projectStatus.propozal: + el = "info"; + } + return el; + }; + const renderCellContent = (item: any, column: any) => { const value = item[column.key as keyof ProcessInnovationData]; @@ -533,7 +574,7 @@ export function DigitalInnovationPage() { variant="ghost" size="sm" onClick={() => handleProjectDetails(item)} - className="text-emerald-400 hover:text-emerald-300 hover:bg-emerald-500/20 p-2 h-auto" + className="text-emerald-400 hover:text-emerald-300 hover:bg-emerald-500/20 p-2 h-auto cursor-pointer" > جزئیات بیشتر @@ -554,15 +595,16 @@ export function DigitalInnovationPage() { return {String(value)}; case "project_status": return ( - +
+ {String(value)} - +
); case "project_rating": return ( @@ -583,6 +625,14 @@ export function DigitalInnovationPage() { } }; + const calculateAverage = (data: Array) => { + let number = 0; + data.map( + (item: ProcessInnovationData) => (number = number + +item.project_rating) + ); + setAvarage(number / data.length); + }; + return (
@@ -700,7 +750,7 @@ export function DigitalInnovationPage() {
- +
{columns.map((column) => ( @@ -837,11 +887,7 @@ export function DigitalInnovationPage() { میانگین امتیاز :‌
- {formatNumber( - ((stats.averageScore ?? 0) as number).toFixed?.(1) ?? - stats.averageScore ?? - 0 - )} + {formatNumber(((avarage ?? 0) as number).toFixed?.(1) ?? 0)}
@@ -876,7 +922,7 @@ export function DigitalInnovationPage() { - شایستگی­ های کلیدی محدود + {dialogInfo?.digital_capability}
@@ -887,7 +933,7 @@ export function DigitalInnovationPage() {
- بدون تغییر کپی شده + {dialogInfo?.digital_competence}
@@ -901,15 +947,15 @@ export function DigitalInnovationPage() {
- دیجیتال کردن ارائه اطلاعات + {dialogInfo?.digital_puberty_elements} -
+
- + توسعه قابلیت های دیجیتال:{" "}
@@ -918,28 +964,16 @@ export function DigitalInnovationPage() { size={"1.2rem"} className="text-emerald-400" /> - قابلیت شماره یک -
-
- - قابلیت شماره یک -
-
- - قابلیت شماره یک + + {dialogInfo?.digital_capability} +
- - توسعه قابلیت های دیجیتال:{" "} + + برنامه های عملیاتی مرتبط:
@@ -947,27 +981,15 @@ export function DigitalInnovationPage() { size={"1.2rem"} className="text-emerald-400" /> - قابلیت شماره یک -
-
- - قابلیت شماره یک -
-
- - قابلیت شماره یک + + {dialogInfo?.operational_plan} +
- - توسعه قابلیت های دیجیتال:{" "} + + استراتژی های مورد نظر:
@@ -975,22 +997,24 @@ export function DigitalInnovationPage() { size={"1.2rem"} className="text-emerald-400" /> - قابلیت شماره یک + + {dialogInfo?.desired_strategy} +
-
+ {/*
قابلیت شماره یک -
-
+
*/} + {/*
قابلیت شماره یک -
+
*/}
@@ -1004,7 +1028,14 @@ export function DigitalInnovationPage() {
- 10% + %{" "} + {formatNumber( + ( + Math.round( + dialogInfo?.reduce_costs_percent! * 100 + ) / 100 + ).toFixed(2) + )} درصد به کل هزینه ها @@ -1013,7 +1044,7 @@ export function DigitalInnovationPage() {
- ۱۰,۲۳۰ + {formatNumber(+dialogInfo?.innovation_cost_reduction!)} میلیون ریال diff --git a/app/components/ui/table.tsx b/app/components/ui/table.tsx index 6ba984a..d5eae2e 100644 --- a/app/components/ui/table.tsx +++ b/app/components/ui/table.tsx @@ -11,7 +11,7 @@ const Table = React.forwardRef(