PageSourceSearch

https://kyour.ai/assets/AssetsPage-BKNOof8s.js

js kyour.ai collected 2026-10-05 15:20:48 UTC 7,286 bytes, 1 lines download raw bytes

1import{r as x,j as e}from"./vendor-react-C4iIr9VY.js";import{d as j,s as w}from"./index-kHtHjOA-.js";import{u as v}from"./useTranslation-DR1iUt77.js";import{bC as h,bc as N,r as C,w as P,b as D,aq as k}from"./vendor-ui-BIa5-Y2I.js";import"./vite-helpers-DruY0qtP.js";import"./vendor-radix-CnhWmudt.js";import"./vendor-charts-aeXF43mk.js";import"./vendor-three-D9hZJzWX.js";const t={cream:"#FAF6F0",brown:"#3E3226",gold:"#A78D5F",line:"#E5DCCB",green:"#10B981",greenBg:"#ECFDF5",amber:"#F59E0B",amberBg:"#FEF3C7",red:"#EF4444",redBg:"#FEE2E2",muted:"#8A7A6A"},E={in_service:{fg:t.green,bg:t.greenBg,label:"In service"},out_of_service:{fg:t.red,bg:t.redBg,label:"Out"},maintenance:{fg:t.amber,bg:t.amberBg,label:"Maintenance"},retired:{fg:t.muted,bg:t.line,label:"Retired"}};function R(){const{t:a}=v(),{currentClinic:o}=j(),[r,c]=x.useState([]),[p,d]=x.useState(!0),[g,f]=x.useState(""),_=async()=>{if(!o?.id){d(!1);return}d(!0);const{data:s}=await w.from("clinic_assets").select("*").eq("clinic_id",o.id).order("name");c(s||[]),d(!1)};x.useEffect(()=>{_()},[o?.id]);const l=new Date,b=x.useMemo(()=>{const s=r.filter(n=>n.next_maintenance_date&&new Date(n.next_maintenance_date)<l||n.next_calibration_date&&new Date(n.next_calibration_date)<l||n.next_inspection_date&&new Date(n.next_inspection_date)<l).length,m=r.filter(n=>{const i=new Date(l.getTime()+2592e6);return n.next_maintenance_date&&new Date(n.next_maintenance_date)<=i&&new Date(n.next_maintenance_date)>=l||n.next_calibration_date&&new Date(n.next_calibration_date)<=i&&new Date(n.next_calibration_date)>=l}).length;return{overdue:s,upcoming30:m}},[r]),y=g?r.filter(s=>s.name?.toLowerCase().includes(g.toLowerCase())||s.serial_number?.toLowerCase().includes(g.toLowerCase())):r;return e.jsxs("div",{style:{padding:"24px 28px",backgroundColor:t.cream,minHeight:"100%",fontFamily:"Poppins, system-ui, sans-serif"},children:[e.jsxs("div",{className:"flex items-start justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold mb-1 flex items-center gap-2",style:{color:t.brown},children:[e.jsx(h,{size:20,style:{color:t.gold}})," ",a("adminPages.assets.title","Asset & Equipment Registry")]}),e.jsx("p",{className:"text-sm",style:{color:t.muted},children:a("adminPages.assets.subtitle","Track equipment, maintenance, calibration, and warranty.")})]}),e.jsxs("button",{disabled:!0,title:a("adminPages.common.coming_soon","Coming soon"),className:"px-4 py-2 text-sm font-bold text-white rounded-lg flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",style:{backgroundColor:t.brown},children:[e.jsx(N,{size:14})," ",a("adminPages.assets.add_asset","Add asset")]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-3 mb-5",children:[e.jsx(u,{icon:h,label:a("adminPages.assets.kpi_total","Total assets"),value:r.length,fg:t.brown,bg:t.cream}),e.jsx(u,{icon:C,label:a("adminPages.assets.kpi_in_service","In service"),value:r.filter(s=>s.status==="in_service").length,fg:t.green,bg:t.greenBg}),e.jsx(u,{icon:P,label:a("adminPages.assets.kpi_overdue","Service overdue"),value:b.overdue,fg:t.red,bg:t.redBg,alert:b.overdue>0}),e.jsx(u,{icon:D,label:a("adminPages.assets.kpi_due30","Due in 30 days"),value:b.upcoming30,fg:t.amber,bg:t.amberBg})]}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(k,{size:14,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:t.muted}}),e.jsx("input",{value:g,onChange:s=>f(s.target.value),placeholder:a("adminPages.assets.search_ph","Search by name or serial…"),className:"w-full pl-9 pr-3 py-2 text-sm rounded-lg border bg-white",style:{borderColor:t.line,color:t.brown}})]}),e.jsx("div",{className:"bg-white rounded-xl border overflow-hidden",style:{borderColor:t.line},children:p?e.jsx("div",{className:"p-8 text-center text-sm",style:{color:t.muted},children:a("adminPages.common.loading","Loading…")}):y.length===0?e.jsxs("div",{className:"p-12 text-center",children:[e.jsx(h,{size:32,style:{color:t.muted,margin:"0 auto 12px"}}),e.jsx("div",{className:"text-sm",style:{color:t.brown},children:a("adminPages.assets.empty","No assets registered yet")})]}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{style:{backgroundColor:t.cream+"80"},children:e.jsxs("tr",{style:{color:t.muted},children:[e.jsx("th",{className:"text-left text-[10px] uppercase tracking-wider font-semibold px-3 py-2.5",children:a("adminPages.assets.col_asset","Asset")}),e.jsx("th",{className:"text-left text-[10px] uppercase tracking-wider font-semibold px-3 py-2.5",children:a("adminPages.common.col_category","Category")}),e.jsx("th",{className:"text-left text-[10px] uppercase tracking-wider font-semibold px-3 py-2.5",children:a("adminPages.assets.col_serial","Serial")}),e.jsx("th",{className:"text-left text-[10px] uppercase tracking-wider font-semibold px-3 py-2.5",children:a("adminPages.common.col_status","Status")}),e.jsx("th",{className:"text-left text-[10px] uppercase tracking-wider font-semibold px-3 py-2.5",children:a("adminPages.assets.col_next_service","Next service")}),e.jsx("th",{className:"text-left text-[10px] uppercase tracking-wider font-semibold px-3 py-2.5",children:a("adminPages.assets.col_warranty","Warranty")})]})}),e.jsx("tbody",{className:"divide-y",style:{borderColor:t.line},children:y.map(s=>{const m=E[s.status],n=s.next_maintenance_date||s.next_calibration_date||s.next_inspection_date,i=n&&new Date(n)<l;return e.jsxs("tr",{className:"hover:bg-amber-50/30",children:[e.jsxs("td",{className:"px-3 py-2.5",children:[e.jsx("div",{className:"text-sm font-semibold",style:{color:t.brown},children:s.name}),s.manufacturer&&e.jsxs("div",{className:"text-[10px]",style:{color:t.muted},children:[s.manufacturer," ",s.model]})]}),e.jsx("td",{className:"px-3 py-2.5 text-xs",style:{color:t.muted},children:s.category||"—"}),e.jsx("td",{className:"px-3 py-2.5 text-xs font-mono",style:{color:t.muted},children:s.serial_number||"—"}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:"text-[9px] uppercase tracking-wider px-1.5 py-0.5 rounded font-bold",style:{backgroundColor:m.bg,color:m.fg},children:m.label})}),e.jsxs("td",{className:"px-3 py-2.5 text-xs",style:{color:i?t.red:t.muted,fontWeight:i?700:400},children:[n?new Date(n).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"—",i&&e.jsx("span",{className:"ml-1 text-[9px] font-bold",children:a("adminPages.assets.overdue_tag","OVERDUE")})]}),e.jsx("td",{className:"px-3 py-2.5 text-xs",style:{color:t.muted},children:s.warranty_until?new Date(s.warranty_until).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"—"})]},s.id)})})]})})]})}function u({icon:a,label:o,value:r,fg:c,bg:p,alert:d}){return e.jsxs("div",{className:"bg-white rounded-xl border p-3",style:{borderColor:d?c+"40":t.line},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:p},children:e.jsx(a,{size:13,style:{color:c}})}),e.jsx("span",{className:"text-[9px] uppercase tracking-wider font-semibold",style:{color:t.muted},children:o})]}),e.jsx("div",{className:"text-xl font-bold tabular-nums",style:{color:c},children:r})]})}
1export{R as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.