import moment from "moment-jalaali"; import React from "react"; import { ProtectedRoute } from "~/components/auth/protected-route"; import { DashboardLayout } from "~/components/dashboard/layout"; import { InfoPanel } from "~/components/ecosystem/info-panel"; import { NetworkGraph } from "~/components/ecosystem/network-graph"; import { Card, CardContent } from "~/components/ui/card"; import { Dialog, DialogContent, DialogHeader, DialogTitle, } from "~/components/ui/dialog"; import apiService from "~/lib/api"; import type { Route } from "./+types/ecosystem"; // Import the CompanyDetails type import { Hexagon } from "lucide-react"; import type { CompanyDetails } from "~/components/ecosystem/network-graph"; export function meta({}: Route.MetaArgs) { return [ { title: "زیست بوم فناوری" }, { name: "description", content: "نمایش زیست بوم فناوری با گراف شبکه‌ای شرکت‌ها", }, ]; } moment.loadPersian({ usePersianDigits: true }); function handleValue(val: any): any { if (val == null) return val; if ( typeof val === "string" && /^\d{4}[-/]\d{2}[-/]\d{2}( \d{2}:\d{2}(:\d{2})?)?$/.test(val) ) { return moment(val, "YYYY-MM-DD HH:mm:ss").format("YYYY/MM/DD"); } if ( typeof val === "number" || (typeof val === "string" && /^-?\d+$/.test(val)) ) { return val.toString().replace(/\d/g, (d) => "۰۱۲۳۴۵۶۷۸۹"[+d]); } return val; } export default function EcosystemPage() { const [selectedCompany, setSelectedCompany] = React.useState(null); const [isDialogLoading, setIsDialogLoading] = React.useState(false); const closeDialog = React.useCallback(() => { setSelectedCompany(null); setIsDialogLoading(false); }, []); const handleNodeClick = React.useCallback((company: CompanyDetails) => { setSelectedCompany(company); }, []); const handleLoadingChange = React.useCallback((loading: boolean) => { setIsDialogLoading(loading); }, []); // Construct image URL const getImageUrl = React.useCallback((attachmentId?: string) => attachmentId ? apiService.filePreviewUrl(attachmentId) : "", []); return (
{/* Node info dialog */} !open && closeDialog()} > معرفی {selectedCompany?.category} {isDialogLoading ? (
{/* Right Column - Loading Skeleton */}
{/* Company Image & Title Skeleton */}
{/* Description Skeleton */}
{/* Left Column - Loading Skeleton */}
{Array.from({ length: 6 }).map((_, index) => (
))}
) : (
{/* Right Column - Description */}
{/* Company Image */}
{selectedCompany?.label || ""} {selectedCompany?.imageAttachmentId ? ( {selectedCompany?.label { // Hide image and show fallback on error e.currentTarget.style.display = "none"; if (e.currentTarget.nextSibling) { ( e.currentTarget.nextSibling as HTMLElement ).style.display = "flex"; } }} /> ) : null}
{selectedCompany?.description ? (

{selectedCompany.description}

) : (
توضیحات در دسترس نیست
)}
{/* Left Column - Company Fields */}

اطلاعات {selectedCompany?.category}

{selectedCompany?.fields && selectedCompany.fields.length > 0 ? (
{selectedCompany.fields.map((field, index) => (
{field.N}: {handleValue(field.V)} {field.U && ( ({field.U}) )}
))}
) : (
اطلاعات تکمیلی در دسترس نیست
)}
)}
); }