fix: bugs reports
This commit is contained in:
parent
a51d904b13
commit
17b738dbf3
|
|
@ -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++) {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ 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 });
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ 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 });
|
moment.loadPersian({ usePersianDigits: true });
|
||||||
|
|
|
||||||
|
|
@ -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 (
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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) + " ریال";
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user