fix:refactor code

This commit is contained in:
mehrdad_adabi 2025-09-10 17:59:10 +03:30
parent d240fb39fa
commit 5917c53b1e
2 changed files with 13 additions and 18 deletions

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,
@ -47,7 +47,7 @@ import apiService from "~/lib/api";
import { formatCurrency } from "~/lib/utils"; 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;

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";
@ -43,8 +42,6 @@ import apiService from "~/lib/api";
import { formatCurrency } from "~/lib/utils"; 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;
@ -194,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>();
@ -426,7 +422,6 @@ export function InnovationBuiltInsidePage() {
useEffect(() => { useEffect(() => {
fetchProjects(true); fetchProjects(true);
fetchStats();
}, [sortConfig]); }, [sortConfig]);
useEffect(() => { useEffect(() => {
@ -486,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(" , ")
: "", : "",
}, },
@ -622,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"
/> />
@ -1039,7 +1034,7 @@ export function InnovationBuiltInsidePage() {
{/* 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">
شرح پروژه شرح پروژه
@ -1192,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(
@ -1268,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"
@ -1323,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;