import React, { useState, useEffect } from "react"; import logo from './logo.png'; import { Card, Title, Text, AreaChart } from "@tremor/react"; import { ShoppingCart, Receipt, PackageSearch, Truck, CreditCard, Boxes, TrendingUp, Coins, LineChart, DollarSign, Newspaper, } from "lucide-react"; function SplashScreen() { return (
Logo
); } /* -------------------------- Communication Tryton -------------------------- */ function openInTryton(model, res_id, view_mode = "tree", domain) { window.parent.postMessage( { type: "open_tab", payload: { model, res_id, view_mode, domain }, }, "*" ); } /* -------------------------- Données -------------------------- */ const params = new URLSearchParams(window.location.search); const defaultSaleId = params.get("sale_id") || 249; const defaultPnlAmount = params.get("pnl_amount"); const exposure = params.get("exposure"); const topay = params.get("topay"); const toreceive = params.get("toreceive"); const data = [ { date: "2025-01-01", value: 12 }, { date: "2025-01-02", value: 14 }, { date: "2025-01-03", value: 10 }, { date: "2025-01-04", value: 18 }, { date: "2025-01-05", value: 22 }, ]; const statusData = [ { status: "Draft", count: 10, color: "bg-teal-500" }, { status: "Confirmed", count: 7, color: "bg-cyan-500" }, { status: "Shipped", count: 4, color: "bg-blue-500" }, ]; const kpis = [ { title: "PNL", value: defaultPnlAmount, trend: "+12% vs last month", icon: TrendingUp, action: () => openInTryton("pnl.bi", [1], "form") }, { title: "Exposure", value: exposure, trend: "+8% this month", icon: Coins, action: () => openInTryton("open.position.report", undefined, "tree") }, { title: "Amount to pay", value: topay, trend: "+5% this month", icon: LineChart, action: () => openInTryton("account.invoice", undefined, "tree") }, { title: "Amount to receive", value: toreceive, trend: "+3% this month", icon: DollarSign, action: () => openInTryton("account.invoice", undefined, "tree") }, ]; const news = [ { type: "Forex", label: "EUR/USD: 1.1400", trend: "+0.88%", color: "#1E3A8A", // bleu foncé date: "30-11-2025", icon: TrendingUp, // icône tendance boursière }, { type: "Logistic", label: "INTHIRA NAREE loaded", date: "08-10-2025", color: "#1E3A8A", icon: Newspaper, }, ]; const cards = [ { id: "purchases_not_confirmed", title: "Purchases Not Confirmed", value: 12, trend: "+8% this week", icon: ShoppingCart, }, { id: "sales_pending", title: "Sales Pending", value: 7, trend: "+3% this week", icon: Receipt, }, { id: "invoices_unpaid", title: "Invoices Unpaid", value: 15, trend: "-2% this week", icon: CreditCard, }, { id: "payments_to_validate", title: "Payments To Validate", value: 4, trend: "+12% this week", icon: PackageSearch, }, { id: "lots_to_produce", title: "Lots", value: 9, trend: "+5% this week", icon: Boxes, }, { id: "shipments_pending", title: "Shipments Pending", value: 6, trend: "-1% this week", icon: Truck, }, ]; /* -------------------------- Dashboard Component -------------------------- */ export default function App() { const [loading, setLoading] = useState(true); useEffect(() => { // durée du splash const timer = setTimeout(() => setLoading(false), 1500); return () => clearTimeout(timer); }, []); if (loading) return ; const saleId = defaultSaleId; const total = statusData.reduce((sum, item) => sum + item.count, 0); return (
{/* KPIs en tête */}
{kpis.map((kpi) => { const Icon = kpi.icon; return (
{kpi.title}
{kpi.value} {kpi.trend}
); })}
{/* Card Last News (taille standard card) */} Last News
{news.map((n, idx) => { const Icon = n.icon; return (
{n.type}
{n.label} {n.trend && ( {n.trend} )}
{n.date}
); })}
{/* Status Distribution */} Status Distribution {total} Across all statuses
{statusData.map((item, i) => (
))}
{statusData.map((item) => (
{item.status} ({item.count} / {((item.count / total) * 100).toFixed(1)}%)
))}
{/* Cards KPI */} {cards.map((card) => { const Icon = card.icon; return (
{card.title}
{card.value} {card.trend}
); })}
); }