fix: bugs reports

This commit is contained in:
mehrdad_adabi 2025-09-09 18:16:19 +03:30
parent a51d904b13
commit 17b738dbf3
7 changed files with 59 additions and 100 deletions

View File

@ -1,10 +1,30 @@
import { useState, useEffect, useCallback, useRef, useMemo } from "react";
import { DashboardLayout } from "../layout";
import { Card, CardContent } from "~/components/ui/card";
import { Button } from "~/components/ui/button";
import { Badge } from "~/components/ui/badge";
import { Checkbox } from "~/components/ui/checkbox";
import {
BrainCircuit,
ChevronDown,
ChevronUp,
Database,
Key,
LoaderCircle,
RefreshCw,
Sprout,
TrendingDown,
TrendingUp,
Zap,
} from "lucide-react";
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 {
Table,
TableBody,
@ -13,26 +33,9 @@ import {
TableHeader,
TableRow,
} 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 toast from "react-hot-toast";
import {
Database,
Zap,
TrendingDown,
TrendingUp,
Key,
Sprout,
BrainCircuit,
LoaderCircle,
} from "lucide-react";
import { CustomBarChart } from "~/components/ui/custom-bar-chart";
import { formatCurrency } from "~/lib/utils";
import { DashboardLayout } from "../layout";
moment.loadPersian({ usePersianDigits: true });
@ -492,16 +495,6 @@ export function DigitalInnovationPage() {
// 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 total = 10;
for (let i = 0; i < rating.length; i++) {

View File

@ -44,6 +44,7 @@ import {
} from "lucide-react";
import toast from "react-hot-toast";
import apiService from "~/lib/api";
import { formatCurrency } from "~/lib/utils";
import DashboardLayout from "../layout";
moment.loadPersian({ usePersianDigits: true });

View File

@ -40,6 +40,7 @@ import {
XAxis,
} from "recharts";
import apiService from "~/lib/api";
import { formatCurrency } from "~/lib/utils";
import DashboardLayout from "../layout";
moment.loadPersian({ usePersianDigits: true });

View File

@ -12,7 +12,7 @@ import {
TableRow,
} from "~/components/ui/table";
import apiService from "~/lib/api";
import { formatNumber } from "~/lib/utils";
import { formatCurrency, formatNumber } from "~/lib/utils";
import { DashboardLayout } from "../layout";
interface ProjectData {
@ -152,6 +152,12 @@ type ColumnDef = {
const columns: ColumnDef[] = [
{ 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_current_status_description",
@ -171,12 +177,6 @@ const columns: ColumnDef[] = [
sortable: true,
width: "160px",
},
{
key: "idea_status",
label: "وضعیت ایده",
sortable: true,
width: "260px",
},
{
key: "personnel_number",
label: "شماره پرسنلی",
@ -229,8 +229,6 @@ const columns: ColumnDef[] = [
},
];
// idea_income , idea_registration_date , idea_originality , personnel_number
export function ManageIdeasTechPage() {
const [projects, setProjects] = useState<ProjectData[]>([]);
const [loading, setLoading] = useState(false);
@ -402,7 +400,7 @@ export function ManageIdeasTechPage() {
try {
const response = await apiService.select({
ProcessName: "idea",
OutputFields: ["count(idea_no)"],
OutputFields: ["count(idea_title)"],
Conditions: [],
});
@ -412,7 +410,7 @@ export function ManageIdeasTechPage() {
try {
const parsedData = JSON.parse(dataString);
if (Array.isArray(parsedData) && parsedData[0]) {
setActualTotalCount(parsedData[0].project_no_count || 0);
setActualTotalCount(parsedData[0].idea_title_count || 0);
}
} catch (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 str = String(input);
const map: Record<string, string> = {
@ -607,21 +587,6 @@ export function ManageIdeasTechPage() {
</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":
return (
<span className="font-medium text-emerald-400">
@ -631,7 +596,9 @@ export function ManageIdeasTechPage() {
case "personnel_number":
// case "idea_originality":
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":
return (

View File

@ -439,7 +439,7 @@ export function ProcessInnovationPage() {
const stats = data[0];
const normalized: InnovationStats = {
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),
bottleneckRemovalCount: parseNum(stats?.count_throat_removal),
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="text-base text-gray-400 mb-1">میانگین :</div>
<div className="font-bold">
{formatNumber(
((stats.averageScore ?? 0) as number).toFixed?.(1) ?? 0
)}
{formatNumber(((stats.averageScore ?? 0) as number) ?? 0)}
</div>
</div>
</div>

View File

@ -1,7 +1,8 @@
import { useState, useEffect, useCallback, useRef } from "react";
import { DashboardLayout } from "../layout";
import { Card, CardContent } from "~/components/ui/card";
import { ChevronDown, ChevronUp, RefreshCw } from "lucide-react";
import { useCallback, useEffect, useRef, useState } from "react";
import toast from "react-hot-toast";
import { Badge } from "~/components/ui/badge";
import { Card, CardContent } from "~/components/ui/card";
import {
Table,
TableBody,
@ -10,9 +11,9 @@ import {
TableHeader,
TableRow,
} from "~/components/ui/table";
import { ChevronUp, ChevronDown, RefreshCw } from "lucide-react";
import apiService from "~/lib/api";
import toast from "react-hot-toast";
import { formatCurrency } from "~/lib/utils";
import { DashboardLayout } from "../layout";
interface ProjectData {
WorkflowID: number;
@ -351,17 +352,6 @@ export function ProjectManagementPage() {
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) => {
if (value === undefined || value === null || value === "") return "0";
const numericValue = typeof value === "string" ? Number(value) : value;

View File

@ -11,3 +11,12 @@ export const formatNumber = (value: string | number) => {
if (isNaN(numericValue)) return "0";
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) + " ریال";
};