/* Shared components for Pelagia Portal */ const { useState, useEffect, useRef, useMemo } = React; /* ─────────── Icons (inline SVG, 14×14) ─────────── */ const Icon = ({ name, size = 14 }) => { const paths = { home: <>, file: <>, list: <>, check: <>, cart: <>, box: <>, truck: <>, users: <>, ship: <>, map: <>, chart: <>, user: <>, settings: <>, plus: <>, download: <>, upload: <>, search: <>, chevron: <>, star: <>, edit: <>, trash: <>, bell: <>, eye: <>, refresh: <>, paperclip: <>, arrowRight: <>, pkg: <>, }; return ( {paths[name] || null} ); }; /* ─────────── Status Badge ─────────── */ const STATUS_LABELS = { DRAFT: ["draft", "Draft"], SUBMITTED: ["submitted", "Submitted"], MGR_REVIEW: ["review", "Under Review"], VENDOR_ID_PENDING: ["vendor", "Vendor Needed"], EDITS_REQUESTED: ["edits", "Edits Requested"], MGR_APPROVED: ["approved", "Approved"], SENT_FOR_PAYMENT: ["sent", "Payment Sent"], PAID_DELIVERED: ["paid", "Paid · Awaiting Receipt"], CLOSED: ["closed", "Closed"], REJECTED: ["rejected", "Rejected"], }; const Badge = ({ status, children, className = "", noDot }) => { if (status) { const [cls, label] = STATUS_LABELS[status] || ["draft", status]; return {label}; } return {children}; }; /* ─────────── Format helpers ─────────── */ const inr = (n) => "₹" + Number(n).toLocaleString("en-IN", { maximumFractionDigits: 0 }); const inrFull = (n) => "₹" + Number(n).toLocaleString("en-IN", { minimumFractionDigits: 2, maximumFractionDigits: 2 }); /* ─────────── Card ─────────── */ const Card = ({ title, action, children, flush, className = "" }) => (
{(title || action) && (

{title}

{action}
)}
{children}
); /* ─────────── Stat tile ─────────── */ const Stat = ({ label, value, sub, onClick }) => (
{label}
{value}
{sub &&
{sub}
}
); /* ─────────── Crumbs ─────────── */ const Crumbs = ({ items }) => (
{items.map((it, i) => ( {i > 0 && /} {it} ))}
); Object.assign(window, { Icon, Badge, Card, Stat, Crumbs, inr, inrFull, STATUS_LABELS });