import type { Route } from "./+types/ecosystem"; import React from "react"; import { ProtectedRoute } from "~/components/auth/protected-route"; import { DashboardLayout } from "~/components/dashboard/layout"; import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "~/components/ui/dialog"; import { NetworkGraph } from "~/components/ecosystem/network-graph"; import { InfoPanel } from "~/components/ecosystem/info-panel"; import { useAuth } from "~/contexts/auth-context"; import moment from "moment-jalaali"; // Get API base URL at module level to avoid process.env access in browser const API_BASE_URL = import.meta.env.VITE_API_URL || "https://inogen-back.pelekan.org/api"; // Import the CompanyDetails type import type { CompanyDetails } from "~/components/ecosystem/network-graph"; import { formatNumber } from "~/lib/utils"; import { Hexagon } from "lucide-react"; 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 { token } = useAuth(); const closeDialog = () => { setSelectedCompany(null); }; // Construct image URL const getImageUrl = (stageid: number) => { return `${API_BASE_URL}/getimage?stageID=${stageid}&nameOrID=image&token=${token?.accessToken}`; }; return (
{/* Node info dialog */} !open && closeDialog()} > معرفی {selectedCompany?.category}
{/* Right Column - Description */}
{/* Company Image */}
{selectedCompany?.label || ""} {selectedCompany?.stageid && token?.accessToken ? ( {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})}
))}
) : (
اطلاعات تکمیلی در دسترس نیست
)}
); }