Merge branch 'main' of https://git.pelekan.org/Saeed0920/inogen into product-idea

This commit is contained in:
Saeed AB 2025-09-11 06:50:00 +03:30
commit 8525f2ff97
8 changed files with 174 additions and 149 deletions

View File

@ -1,10 +1,30 @@
import { useState, useEffect, useCallback, useRef, useMemo } from "react"; import {
import { DashboardLayout } from "../layout"; BrainCircuit,
import { Card, CardContent } from "~/components/ui/card"; ChevronDown,
import { Button } from "~/components/ui/button"; ChevronUp,
import { Badge } from "~/components/ui/badge"; Database,
import { Checkbox } from "~/components/ui/checkbox"; Key,
LoaderCircle,
RefreshCw,
Sprout,
TrendingDown,
TrendingUp,
Zap,
} from "lucide-react";
import moment from "moment-jalaali"; import moment from "moment-jalaali";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import toast from "react-hot-toast";
import { Badge } from "~/components/ui/badge";
import { Button } from "~/components/ui/button";
import { Card, CardContent } from "~/components/ui/card";
import { Checkbox } from "~/components/ui/checkbox";
import { CustomBarChart } from "~/components/ui/custom-bar-chart";
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
} from "~/components/ui/dialog";
import { import {
Table, Table,
TableBody, TableBody,
@ -13,26 +33,9 @@ import {
TableHeader, TableHeader,
TableRow, TableRow,
} from "~/components/ui/table"; } from "~/components/ui/table";
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
} from "~/components/ui/dialog";
import { ChevronUp, ChevronDown, RefreshCw } from "lucide-react";
import apiService from "~/lib/api"; import apiService from "~/lib/api";
import toast from "react-hot-toast"; import { formatCurrency } from "~/lib/utils";
import { import { DashboardLayout } from "../layout";
Database,
Zap,
TrendingDown,
TrendingUp,
Key,
Sprout,
BrainCircuit,
LoaderCircle,
} from "lucide-react";
import { CustomBarChart } from "~/components/ui/custom-bar-chart";
moment.loadPersian({ usePersianDigits: true }); moment.loadPersian({ usePersianDigits: true });
@ -492,16 +495,6 @@ export function DigitalInnovationPage() {
// fetchStats(); // fetchStats();
// }; // };
const formatCurrency = (amount: string | number) => {
if (!amount) return "0 ریال";
const numericAmount =
typeof amount === "string"
? parseFloat(amount.replace(/,/g, ""))
: amount;
if (isNaN(numericAmount)) return "0 ریال";
return new Intl.NumberFormat("fa-IR").format(numericAmount) + " ریال";
};
const renderProgress = useMemo(() => { const renderProgress = useMemo(() => {
const total = 10; const total = 10;
for (let i = 0; i < rating.length; i++) { for (let i = 0; i < rating.length; i++) {
@ -625,18 +618,18 @@ export function DigitalInnovationPage() {
return ( return (
<DashboardLayout title="نوآوری دیجیتال"> <DashboardLayout title="نوآوری دیجیتال">
<div className="grid grid-cols-2 gap-8 justify-between p-6 space-y-4 h-full"> <div className="p-6 space-y-4 grid justify-between gap-8 sm:grid-cols-1 xl:grid-cols-[40%_60%]">
{/* Stats Cards */} {/* Stats Cards */}
<div className="flex flex-col gap-6 w-full mb-0"> <div className="flex flex-col gap-6 w-full mb-0">
<div className="space-y-6 w-full"> <div className="space-y-6 w-full">
{/* Stats Grid */} {/* Stats Grid */}
<div className="grid grid-cols-2 gap-5"> <div className="grid grid-cols-2 gap-5">
{loading || statsLoading {loading
? // Loading skeleton for stats cards - matching new design ? // Loading skeleton for stats cards - matching new design
Array.from({ length: 4 }).map((_, index) => ( Array.from({ length: 4 }).map((_, index) => (
<Card <Card
key={`skeleton-${index}`} key={`skeleton-${index}`}
className="bg-[linear-gradient(to_bottom_left,#464861,50%,#111628)] backdrop-blur-sm rounded-2xl overflow-hidden" className="bg-[linear-gradient(to_bottom_left,#464861,50%,#111628)] backdrop-blur-sm rounded-2xl overflow-hidden !h-full"
> >
<CardContent className="p-0"> <CardContent className="p-0">
<div className="flex flex-col justify-between gap-2"> <div className="flex flex-col justify-between gap-2">
@ -698,7 +691,7 @@ export function DigitalInnovationPage() {
</div> </div>
{/* Process Impacts Chart */} {/* Process Impacts Chart */}
<Card className="bg-[linear-gradient(to_bottom_left,#464861,50%,#111628)] backdrop-blur-sm rounded-lg w-full overflow-hidden"> <Card className="bg-[linear-gradient(to_bottom_left,#464861,50%,#111628)] backdrop-blur-sm rounded-lg w-full overflow-hidden h-full ">
{/* <CardContent > */} {/* <CardContent > */}
<CustomBarChart <CustomBarChart
title="تاثیرات نوآوری دیجیتال به صورت درصد مقایسه ای" title="تاثیرات نوآوری دیجیتال به صورت درصد مقایسه ای"
@ -854,7 +847,40 @@ export function DigitalInnovationPage() {
</CardContent> </CardContent>
{/* Footer */} {/* Footer */}
<div className="p-2 px-4 bg-gray-700/50"> <div className="p-2 px-4 bg-gray-700/50">
<div className="grid grid-cols-[minmax(100px,0fr)_minmax(80px,1fr)_minmax(100px,2fr)_minmax(10px,1fr)_minmax(100px,1fr)] text-sm text-gray-300 font-persian items-center ">
<div></div>
<div className="text-center text-gray-400 ">
کل پروژهها:{" "}
<span className="font-bold">
{formatNumber(actualTotalCount)}
</span>
</div>
<div className="flex flex-row-reverse">
<span className="block w-7 h-2.5 bg-violet-500 rounded-tl-xl rounded-bl-xl"></span>
<span className="block w-7 h-2.5 bg-purple-500 "></span>
<span className="block w-7 h-2.5 bg-cyan-300 "></span>
<span className="block w-7 h-2.5 bg-pink-400 rounded-tr-xl rounded-br-xl"></span>
</div>
<div className="text-center text-gray-400 py-2">
میانگین:{" "}
<span className="font-bold">
{formatNumber(
((stats.avarageProjectScore ?? 0) as number).toFixed?.(1) ??
0
)}
</span>
</div>
<div></div>
</div>
</div>
{/* <div className="p-2 px-4 bg-gray-700/50">
<div className="flex flex-row gap-4 text-sm text-gray-300 font-persian justify-between"> <div className="flex flex-row gap-4 text-sm text-gray-300 font-persian justify-between">
<div className="text-center gap-2 items-center w-1/3 pr-16"> <div className="text-center gap-2 items-center w-1/3 pr-16">
<div className="text-base text-gray-401 mb-1"> <div className="text-base text-gray-401 mb-1">
@ -881,7 +907,7 @@ export function DigitalInnovationPage() {
</div> </div>
</div> </div>
</div> </div>
</div> </div> */}
</Card> </Card>
</div> </div>

View File

@ -1,4 +1,4 @@
import moment from "moment-jalaali"; // import moment from "moment-jalaali";
import { useCallback, useEffect, useRef, useState } from "react"; import { useCallback, useEffect, useRef, useState } from "react";
import { import {
Bar, Bar,
@ -44,9 +44,10 @@ import {
} from "lucide-react"; } from "lucide-react";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import apiService from "~/lib/api"; import apiService from "~/lib/api";
import { formatCurrency } from "~/lib/utils";
import DashboardLayout from "../layout"; import DashboardLayout from "../layout";
moment.loadPersian({ usePersianDigits: true }); // moment.loadPersian({ usePersianDigits: true });
interface GreenInnovationData { interface GreenInnovationData {
WorkflowID: string; WorkflowID: string;
approved_budget: string; approved_budget: string;
@ -690,8 +691,8 @@ export function GreenInnovationPage() {
<DashboardLayout title="نوآوری سبز"> <DashboardLayout title="نوآوری سبز">
<div className="p-6 space-y-4 h-[23.5rem]"> <div className="p-6 space-y-4 h-[23.5rem]">
{/* Stats Cards */} {/* Stats Cards */}
<div className="flex gap-6 mb-5"> <div className="flex gap-6 mb-5 md:flex-col xl:flex-row">
<div className="flex flex-col justify-between w-1/2"> <div className="flex flex-col justify-between xl:w-1/2 sm:w-full sm:gap-2">
{loading || statsLoading {loading || statsLoading
? // Loading skeleton for stats cards - matching new design ? // Loading skeleton for stats cards - matching new design
Array.from({ length: 2 }).map((_, index) => ( Array.from({ length: 2 }).map((_, index) => (
@ -948,7 +949,7 @@ export function GreenInnovationPage() {
<Card className="bg-transparent backdrop-blur-sm rounded-lg overflow-hidden"> <Card className="bg-transparent backdrop-blur-sm rounded-lg overflow-hidden">
<CardContent className="p-0"> <CardContent className="p-0">
<div className="relative"> <div className="relative">
<Table containerClassName="overflow-auto custom-scrollbar max-h-[calc(90vh-400px)]"> <Table containerClassName="overflow-auto custom-scrollbar h-[25rem]">
<TableHeader> <TableHeader>
<TableRow className="bg-[#3F415A]"> <TableRow className="bg-[#3F415A]">
{columns.map((column) => ( {columns.map((column) => (
@ -1050,14 +1051,14 @@ export function GreenInnovationPage() {
</CardContent> </CardContent>
<div className="p-2 px-4 bg-gray-700/50"> <div className="p-2 px-4 bg-gray-700/50">
<div className="flex flex-row gap-4 text-sm text-gray-300 font-persian justify-between"> <div className="grid grid-cols-[41%_41%] text-sm text-gray-300 font-persian justify-between">
<div className="text-center gap-2 items-center w-1/3 pr-36"> <div className="text-center gap-2 items-center">
<div className="text-base text-gray-401 mb-1"> <div className="text-base text-gray-401 mr-10">
کل پروژه ها :{formatNumber(actualTotalCount)} کل پروژه ها :{formatNumber(actualTotalCount)}
</div> </div>
</div> </div>
<div className="flex items-center flex-row gap-20 status justify-center w-2/3"> <div className="flex items-center flex-row status justify-between w-[calc(40%-5px)]">
<div className="flex flex-row-reverse"> <div className="flex flex-row-reverse">
<span className="block w-7 h-2.5 bg-violet-500 rounded-tl-xl rounded-bl-xl"></span> <span className="block w-7 h-2.5 bg-violet-500 rounded-tl-xl rounded-bl-xl"></span>
<span className="block w-7 h-2.5 bg-purple-500 "></span> <span className="block w-7 h-2.5 bg-purple-500 "></span>

View File

@ -1,4 +1,3 @@
import moment from "moment-jalaali";
import { useCallback, useEffect, useRef, useState } from "react"; import { useCallback, useEffect, useRef, useState } from "react";
import { Badge } from "~/components/ui/badge"; import { Badge } from "~/components/ui/badge";
import { Button } from "~/components/ui/button"; import { Button } from "~/components/ui/button";
@ -40,10 +39,9 @@ import {
XAxis, XAxis,
} from "recharts"; } from "recharts";
import apiService from "~/lib/api"; import apiService from "~/lib/api";
import { formatCurrency } from "~/lib/utils";
import DashboardLayout from "../layout"; import DashboardLayout from "../layout";
moment.loadPersian({ usePersianDigits: true });
interface innovationBuiltInDate { interface innovationBuiltInDate {
WorkflowID: number; WorkflowID: number;
approved_budget: string; approved_budget: string;
@ -193,9 +191,8 @@ export function InnovationBuiltInsidePage() {
direction: "asc", direction: "asc",
}); });
const [tblAvarage, setTblAvarage] = useState<number>(0); const [tblAvarage, setTblAvarage] = useState<number>(0);
const [selectedProjects, setSelectedProjects] = useState< const [selectedProjects, setSelectedProjects] =
Set<string | number> useState<Set<string | number>>();
>(new Set());
const [detailsDialogOpen, setDetailsDialogOpen] = useState(false); const [detailsDialogOpen, setDetailsDialogOpen] = useState(false);
const [selectedProjectDetails, setSelectedProjectDetails] = const [selectedProjectDetails, setSelectedProjectDetails] =
useState<DialogInfo>(); useState<DialogInfo>();
@ -425,7 +422,6 @@ export function InnovationBuiltInsidePage() {
useEffect(() => { useEffect(() => {
fetchProjects(true); fetchProjects(true);
fetchStats();
}, [sortConfig]); }, [sortConfig]);
useEffect(() => { useEffect(() => {
@ -485,7 +481,7 @@ export function InnovationBuiltInsidePage() {
const raw = await apiService.call<any>({ const raw = await apiService.call<any>({
innovation_construction_inside_function: { innovation_construction_inside_function: {
project_ids: project_ids:
selectedProjects.size > 0 selectedProjects && selectedProjects?.size > 0
? Array.from(selectedProjects).join(" , ") ? Array.from(selectedProjects).join(" , ")
: "", : "",
}, },
@ -621,7 +617,7 @@ export function InnovationBuiltInsidePage() {
case "select": case "select":
return ( return (
<Checkbox <Checkbox
checked={selectedProjects.has(item?.project_id!)} checked={selectedProjects?.has(item?.project_id!)}
onCheckedChange={() => handleSelectProject(item?.project_id)} onCheckedChange={() => handleSelectProject(item?.project_id)}
className="data-[state=checked]:bg-emerald-600 data-[state=checked]:border-emerald-600 cursor-pointer" className="data-[state=checked]:bg-emerald-600 data-[state=checked]:border-emerald-600 cursor-pointer"
/> />
@ -709,9 +705,9 @@ export function InnovationBuiltInsidePage() {
return ( return (
<DashboardLayout title="نوآوری ساخت داخل"> <DashboardLayout title="نوآوری ساخت داخل">
<div className="p-6 space-y-4 flex justify-between gap-8 sm:flex-col xl:flex-row"> <div className="p-6 space-y-4 justify-between gap-8 grid sm:grid-cols-1 xl:grid-cols-[40%_60%]">
{/* Stats Cards */} {/* Stats Cards */}
<div className="flex gap-6 w-full"> <div className="flex gap-6 w-full mb-0">
<div className="flex flex-col justify-between w-full gap-6"> <div className="flex flex-col justify-between w-full gap-6">
{statsLoading {statsLoading
? // Loading skeleton for stats cards - matching new design ? // Loading skeleton for stats cards - matching new design
@ -977,6 +973,37 @@ export function InnovationBuiltInsidePage() {
</CardContent> </CardContent>
<div className="p-2 px-4 bg-gray-700/50"> <div className="p-2 px-4 bg-gray-700/50">
<div className="grid grid-cols-[minmax(100px,1fr)_minmax(80px,1fr)_minmax(100px,2fr)_minmax(10px,1fr)_minmax(100px,1fr)] text-sm text-gray-300 font-persian items-center ">
<div></div>
<div className="text-right text-gray-400 mr-6">
کل پروژهها:{" "}
<span className="font-bold">
{formatNumber(actualTotalCount)}
</span>
</div>
<div className="flex flex-row-reverse">
<span className="block w-7 h-2.5 bg-violet-500 rounded-tl-xl rounded-bl-xl"></span>
<span className="block w-7 h-2.5 bg-purple-500 "></span>
<span className="block w-7 h-2.5 bg-cyan-300 "></span>
<span className="block w-7 h-2.5 bg-pink-400 rounded-tr-xl rounded-br-xl"></span>
</div>
<div className="text-center text-gray-400 py-2">
میانگین:{" "}
<span className="font-bold">
{formatNumber(
((tblAvarage ?? 0) as number).toFixed?.(1) ?? 0
)}
</span>
</div>
<div></div>
</div>
</div>
{/* <div className="p-2 px-4 bg-gray-700/50">
<div className="flex gap-4 text-sm text-gray-300 font-persian justify-between sm:flex-col xl:flex-row"> <div className="flex gap-4 text-sm text-gray-300 font-persian justify-between sm:flex-col xl:flex-row">
<div className="text-center items-center xl:w-full pr-6 sm:w-full"> <div className="text-center items-center xl:w-full pr-6 sm:w-full">
<div className="text-base text-gray-401 mb-1"> <div className="text-base text-gray-401 mb-1">
@ -1001,13 +1028,13 @@ export function InnovationBuiltInsidePage() {
</div> </div>
</div> </div>
</div> </div>
</div> </div> */}
</Card> </Card>
</div> </div>
{/* Project Details Dialog */} {/* Project Details Dialog */}
<Dialog open={detailsDialogOpen} onOpenChange={setDetailsDialogOpen}> <Dialog open={detailsDialogOpen} onOpenChange={setDetailsDialogOpen}>
<DialogContent className="bg-[linear-gradient(to_bottom_left,#464861,50%,#111628)] max-w-5xl overflow-y-auto"> <DialogContent className="bg-[linear-gradient(to_bottom_left,#464861,50%,#111628)] max-w-6xl overflow-y-auto">
<DialogHeader> <DialogHeader>
<DialogTitle className="text-white mr-4 border-b-2 border-gray-600 pb-4 font-persian text-right"> <DialogTitle className="text-white mr-4 border-b-2 border-gray-600 pb-4 font-persian text-right">
شرح پروژه شرح پروژه
@ -1160,12 +1187,12 @@ export function InnovationBuiltInsidePage() {
</div> </div>
) : ( ) : (
<div className="tbl rounded-xl overflow-hidden"> <div className="tbl rounded-xl overflow-hidden">
<div className="grid grid-cols-3 bg-[#3F415A] text-white"> <div className="grid grid-cols-3 bg-[#3F415A] text-white p-3 items-center">
<span className="text-md text-center p-3"> <span className="text-md text-center">
شاخص مقایسه با نمونه خارجی شاخص مقایسه با نمونه خارجی
</span> </span>
<span className="text-md text-center p-3">نمونه داخلی</span> <span className="text-md text-center">نمونه داخلی</span>
<span className="text-md text-center p-3">نمونه خارجی</span> <span className="text-md text-center">نمونه خارجی</span>
</div> </div>
<div className="flex flex-col divide-y divide-gray-600 overflow-auto max-h-[6rem]"> <div className="flex flex-col divide-y divide-gray-600 overflow-auto max-h-[6rem]">
{selectedProjectDetails?.technology_params?.map( {selectedProjectDetails?.technology_params?.map(
@ -1236,7 +1263,7 @@ export function InnovationBuiltInsidePage() {
<ResponsiveContainer width="100%" height={420}> <ResponsiveContainer width="100%" height={420}>
<LineChart <LineChart
data={dialogChartData} data={dialogChartData}
margin={{ top: 20, right: 20, left: 20, bottom: 80 }} margin={{ top: 20, right: 70, left: 30, bottom: 80 }}
> >
<XAxis <XAxis
dataKey="name" dataKey="name"
@ -1291,7 +1318,7 @@ export function InnovationBuiltInsidePage() {
axisOffsetX - axisOffsetX -
15; 15;
const rectWidth = 140; const rectWidth = 130;
const rectHeight = 28; const rectHeight = 28;
const rectX = x - rectWidth / 2; const rectX = x - rectWidth / 2;
const axisHeight = xAxis?.height ?? 40; const axisHeight = xAxis?.height ?? 40;

View File

@ -12,7 +12,7 @@ import {
TableRow, TableRow,
} from "~/components/ui/table"; } from "~/components/ui/table";
import apiService from "~/lib/api"; import apiService from "~/lib/api";
import { formatNumber } from "~/lib/utils"; import { formatCurrency, formatNumber } from "~/lib/utils";
import { DashboardLayout } from "../layout"; import { DashboardLayout } from "../layout";
interface ProjectData { interface ProjectData {
@ -152,6 +152,12 @@ type ColumnDef = {
const columns: ColumnDef[] = [ const columns: ColumnDef[] = [
{ key: "idea_title", label: "عنوان ایده", sortable: true, width: "200px" }, { key: "idea_title", label: "عنوان ایده", sortable: true, width: "200px" },
{
key: "idea_status",
label: "وضعیت ایده",
sortable: true,
width: "260px",
},
{ key: "idea_axis", label: "محور ایده", sortable: true, width: "160px" }, { key: "idea_axis", label: "محور ایده", sortable: true, width: "160px" },
{ {
key: "idea_current_status_description", key: "idea_current_status_description",
@ -171,12 +177,6 @@ const columns: ColumnDef[] = [
sortable: true, sortable: true,
width: "160px", width: "160px",
}, },
{
key: "idea_status",
label: "وضعیت ایده",
sortable: true,
width: "260px",
},
{ {
key: "personnel_number", key: "personnel_number",
label: "شماره پرسنلی", label: "شماره پرسنلی",
@ -229,8 +229,6 @@ const columns: ColumnDef[] = [
}, },
]; ];
// idea_income , idea_registration_date , idea_originality , personnel_number
export function ManageIdeasTechPage() { export function ManageIdeasTechPage() {
const [projects, setProjects] = useState<ProjectData[]>([]); const [projects, setProjects] = useState<ProjectData[]>([]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@ -402,7 +400,7 @@ export function ManageIdeasTechPage() {
try { try {
const response = await apiService.select({ const response = await apiService.select({
ProcessName: "idea", ProcessName: "idea",
OutputFields: ["count(idea_no)"], OutputFields: ["count(idea_title)"],
Conditions: [], Conditions: [],
}); });
@ -412,7 +410,7 @@ export function ManageIdeasTechPage() {
try { try {
const parsedData = JSON.parse(dataString); const parsedData = JSON.parse(dataString);
if (Array.isArray(parsedData) && parsedData[0]) { if (Array.isArray(parsedData) && parsedData[0]) {
setActualTotalCount(parsedData[0].project_no_count || 0); setActualTotalCount(parsedData[0].idea_title_count || 0);
} }
} catch (parseError) { } catch (parseError) {
console.error("Error parsing count data:", parseError); console.error("Error parsing count data:", parseError);
@ -424,24 +422,6 @@ export function ManageIdeasTechPage() {
} }
}; };
const formatCurrency = (amount: string | number) => {
if (!amount) return "0 ریال";
// Remove commas and convert to number
const numericAmount =
typeof amount === "string"
? parseFloat(amount.replace(/,/g, ""))
: amount;
if (isNaN(numericAmount)) return "0 ریال";
return new Intl.NumberFormat("fa-IR").format(numericAmount) + " ریال";
};
// const formatNumber = (value: string | number) => {
// if (value === undefined || value === null || value === "") return "0";
// const numericValue = typeof value === "string" ? Number(value) : value;
// if (Number.isNaN(numericValue)) return "0";
// return new Intl.NumberFormat("fa-IR").format(numericValue as number);
// };
const toPersianDigits = (input: string | number): string => { const toPersianDigits = (input: string | number): string => {
const str = String(input); const str = String(input);
const map: Record<string, string> = { const map: Record<string, string> = {
@ -607,21 +587,6 @@ export function ManageIdeasTechPage() {
</span> </span>
); );
} }
// case "strategic_theme":
// case "value_technology_and_innovation":
// case "type_of_innovation":
// case "innovation":
// return (
// <span className="inline-flex items-center justify-end flex-row-reverse gap-2 w-full">
// <span className="text-gray-300">{String(value) || "-"}</span>
// <span
// style={{
// backgroundColor: `${column.key === "strategic_theme" ? "#6D53FB" : column.key === "value_technology_and_innovation" ? "#A757FF" : column.key === "type_of_innovation" ? "#E884CE" : "#C3BF8B"}`,
// }}
// className="inline-block w-2 h-2 rounded-full bg-emerald-400"
// />
// </span>
// );
case "idea_income": case "idea_income":
return ( return (
<span className="font-medium text-emerald-400"> <span className="font-medium text-emerald-400">
@ -631,7 +596,9 @@ export function ManageIdeasTechPage() {
case "personnel_number": case "personnel_number":
// case "idea_originality": // case "idea_originality":
return ( return (
<span className="text-gray-300">{formatNumber(value as any)} </span> <span className="text-gray-300">
{toPersianDigits(value as any)}{" "}
</span>
); );
case "idea_registration_date": case "idea_registration_date":
return ( return (

View File

@ -439,7 +439,7 @@ export function ProcessInnovationPage() {
const stats = data[0]; const stats = data[0];
const normalized: InnovationStats = { const normalized: InnovationStats = {
totalProjects: parseNum(stats?.count_innovation_process_projects), totalProjects: parseNum(stats?.count_innovation_process_projects),
averageScore: parseNum(stats?.average_project_score), averageScore: parseFloat(data[0].average_project_score),
productionStopsPreventionSum: parseNum(stats?.sum_stopping_production), productionStopsPreventionSum: parseNum(stats?.sum_stopping_production),
bottleneckRemovalCount: parseNum(stats?.count_throat_removal), bottleneckRemovalCount: parseNum(stats?.count_throat_removal),
currencyReductionSum: parseNum(stats?.sum_reduction_value_currency), currencyReductionSum: parseNum(stats?.sum_reduction_value_currency),
@ -828,9 +828,7 @@ export function ProcessInnovationPage() {
<div className="flex justify-center items-center gap-2"> <div className="flex justify-center items-center gap-2">
<div className="text-base text-gray-400 mb-1">میانگین :</div> <div className="text-base text-gray-400 mb-1">میانگین :</div>
<div className="font-bold"> <div className="font-bold">
{formatNumber( {formatNumber(((stats.averageScore ?? 0) as number) ?? 0)}
((stats.averageScore ?? 0) as number).toFixed?.(1) ?? 0
)}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,7 +1,8 @@
import { useState, useEffect, useCallback, useRef } from "react"; import { ChevronDown, ChevronUp, RefreshCw } from "lucide-react";
import { DashboardLayout } from "../layout"; import { useCallback, useEffect, useRef, useState } from "react";
import { Card, CardContent } from "~/components/ui/card"; import toast from "react-hot-toast";
import { Badge } from "~/components/ui/badge"; import { Badge } from "~/components/ui/badge";
import { Card, CardContent } from "~/components/ui/card";
import { import {
Table, Table,
TableBody, TableBody,
@ -10,9 +11,9 @@ import {
TableHeader, TableHeader,
TableRow, TableRow,
} from "~/components/ui/table"; } from "~/components/ui/table";
import { ChevronUp, ChevronDown, RefreshCw } from "lucide-react";
import apiService from "~/lib/api"; import apiService from "~/lib/api";
import toast from "react-hot-toast"; import { formatCurrency } from "~/lib/utils";
import { DashboardLayout } from "../layout";
interface ProjectData { interface ProjectData {
WorkflowID: number; WorkflowID: number;
@ -351,17 +352,6 @@ export function ProjectManagementPage() {
fetchTotalCount(); fetchTotalCount();
}; };
const formatCurrency = (amount: string | number) => {
if (!amount) return "0 ریال";
// Remove commas and convert to number
const numericAmount =
typeof amount === "string"
? parseFloat(amount.replace(/,/g, ""))
: amount;
if (isNaN(numericAmount)) return "0 ریال";
return new Intl.NumberFormat("fa-IR").format(numericAmount) + " ریال";
};
const formatNumber = (value: string | number) => { const formatNumber = (value: string | number) => {
if (value === undefined || value === null || value === "") return "0"; if (value === undefined || value === null || value === "") return "0";
const numericValue = typeof value === "string" ? Number(value) : value; const numericValue = typeof value === "string" ? Number(value) : value;

View File

@ -1,6 +1,6 @@
import * as React from "react" import * as React from "react";
import { cn } from "~/lib/utils" import { cn } from "~/lib/utils";
const Card = React.forwardRef< const Card = React.forwardRef<
HTMLDivElement, HTMLDivElement,
@ -9,13 +9,13 @@ const Card = React.forwardRef<
<div <div
ref={ref} ref={ref}
className={cn( className={cn(
"rounded-lg border bg-card text-card-foreground shadow-sm", "rounded-lg border bg-card text-card-foreground shadow-sm ",
className className
)} )}
{...props} {...props}
/> />
)) ));
Card.displayName = "Card" Card.displayName = "Card";
const CardHeader = React.forwardRef< const CardHeader = React.forwardRef<
HTMLDivElement, HTMLDivElement,
@ -26,8 +26,8 @@ const CardHeader = React.forwardRef<
className={cn("flex flex-col space-y-1.5 p-6", className)} className={cn("flex flex-col space-y-1.5 p-6", className)}
{...props} {...props}
/> />
)) ));
CardHeader.displayName = "CardHeader" CardHeader.displayName = "CardHeader";
const CardTitle = React.forwardRef< const CardTitle = React.forwardRef<
HTMLParagraphElement, HTMLParagraphElement,
@ -41,8 +41,8 @@ const CardTitle = React.forwardRef<
)} )}
{...props} {...props}
/> />
)) ));
CardTitle.displayName = "CardTitle" CardTitle.displayName = "CardTitle";
const CardDescription = React.forwardRef< const CardDescription = React.forwardRef<
HTMLParagraphElement, HTMLParagraphElement,
@ -53,16 +53,16 @@ const CardDescription = React.forwardRef<
className={cn("text-sm text-muted-foreground", className)} className={cn("text-sm text-muted-foreground", className)}
{...props} {...props}
/> />
)) ));
CardDescription.displayName = "CardDescription" CardDescription.displayName = "CardDescription";
const CardContent = React.forwardRef< const CardContent = React.forwardRef<
HTMLDivElement, HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} /> <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
)) ));
CardContent.displayName = "CardContent" CardContent.displayName = "CardContent";
const CardFooter = React.forwardRef< const CardFooter = React.forwardRef<
HTMLDivElement, HTMLDivElement,
@ -73,7 +73,14 @@ const CardFooter = React.forwardRef<
className={cn("flex items-center p-6 pt-0", className)} className={cn("flex items-center p-6 pt-0", className)}
{...props} {...props}
/> />
)) ));
CardFooter.displayName = "CardFooter" CardFooter.displayName = "CardFooter";
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } export {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
};

View File

@ -11,3 +11,12 @@ export const formatNumber = (value: string | number) => {
if (isNaN(numericValue)) return "0"; if (isNaN(numericValue)) return "0";
return new Intl.NumberFormat("fa-IR").format(numericValue); return new Intl.NumberFormat("fa-IR").format(numericValue);
}; };
export const formatCurrency = (amount: string | number) => {
if (!amount) return "0 ریال";
// Remove commas and convert to number
const numericAmount =
typeof amount === "string" ? parseFloat(amount.replace(/,/g, "")) : amount;
if (isNaN(numericAmount)) return "0 ریال";
return new Intl.NumberFormat("fa-IR").format(numericAmount) + " ریال";
};