PageSourceSearch

https://printarex.com/assets/HubInventoryPage-BbYxSpqJ.js

js printarex.com collected 2026-10-02 06:29:22 UTC 11,569 bytes, 1 lines download raw bytes

1import{W as F,j as e,cF as $,a as R,a6 as q,h as E,B as j,a0 as c,a3 as K,a4 as W,aF as n,a1 as L,t as T,S as u,Y as C,b2 as X,n as H,aV as G,ax as Z,$ as J,b5 as ee}from"./index-COb3BWG8.js";import{A as k,a as U,b as D}from"./alert-BcZXKgYj.js";import{B as se}from"./badge-BtMzbs5Q.js";import{P as ae}from"./progress-B1h2wEL6.js";import{a as te,b as re}from"./hub-queries-md-FJiyf.js";import{W as ie}from"./warehouse-fcMEA1Ar.js";import{R as le}from"./refresh-cw-CoRVSjNV.js";import{P as I}from"./package-check-DVUPGXZC.js";import{T as ne}from"./tag-CrwCp0XH.js";import{E as ce}from"./external-link-BFGzlI4f.js";import{C as oe}from"./clock-3-CMAc593Q.js";const h=20,A=new Set(["EXPECTED","HELD","RESERVED","QUARANTINED"]),P=(s,t)=>{const a=new Map(s.myHubStockPage.items.map(i=>[i.unitId,i]));return t.myHubStockPage.items.forEach(i=>a.set(i.unitId,i)),{myHubStockPage:{...t.myHubStockPage,items:Array.from(a.values())}}},de={EXPECTED:"Expected",HELD:"Held at Hub",RESERVED:"Reserved",SHIPPED:"Shipped",QUARANTINED:"Quarantined",DISPOSED:"Disposed",CANCELLED:"Cancelled"},me=s=>s==="HELD"?"success":s==="EXPECTED"||s==="RESERVED"?"pending":s==="QUARANTINED"?"warning":s==="DISPOSED"||s==="CANCELLED"?"destructive":"outline",_=(s,t)=>s?ee(s,t,{month:"short",day:"numeric",year:"numeric"}):"—",xe=()=>{const{locale:s}=R();return e.jsxs("div",{className:"space-y-4","aria-busy":"true","aria-live":"polite",children:[e.jsx("span",{className:"sr-only",children:T("Loading Hub inventory",s)}),e.jsx("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:[1,2,3,4].map(t=>e.jsxs(c,{className:"p-5",children:[e.jsx(u,{className:"h-3 w-20"}),e.jsx(u,{className:"mt-3 h-8 w-16"})]},`hub-summary-skeleton-${t}`))}),e.jsxs(c,{className:"p-6",children:[e.jsx(u,{className:"h-6 w-48"}),e.jsx("div",{className:"mt-5 space-y-3",children:[1,2,3].map(t=>e.jsx(u,{className:"h-20 w-full rounded-[14px]"},`hub-row-skeleton-${t}`))})]})]})},pe=({summary:s,copy:t,locale:a})=>{const i=s.capacityLimit>0,d=i?s.capacityUsed:0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:[e.jsxs(c,{className:"border-emerald-100 bg-emerald-50/50 p-5",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-emerald-700",children:t("Held units")}),e.jsx("p",{className:"mt-2 text-3xl font-semibold text-slate-900",children:n(s.heldUnits,a)})]}),e.jsxs(c,{className:"border-blue-100 bg-blue-50/50 p-5",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-blue-700",children:t("Reserved")}),e.jsx("p",{className:"mt-2 text-3xl font-semibold text-slate-900",children:n(s.reservedUnits,a)})]}),e.jsxs(c,{className:"border-amber-100 bg-amber-50/50 p-5",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-amber-700",children:t("Expected")}),e.jsx("p",{className:"mt-2 text-3xl font-semibold text-slate-900",children:n(s.expectedUnits,a)})]}),e.jsxs(c,{className:"border-slate-200 bg-white p-5",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-slate-500",children:t("Quarantined")}),e.jsx("p",{className:"mt-2 text-3xl font-semibold text-slate-900",children:n(s.quarantinedUnits,a)})]})]}),e.jsx(c,{className:"border-slate-200",children:e.jsxs(L,{className:"grid gap-4 p-5 md:grid-cols-[1fr_auto] md:items-center",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:t("Hub capacity")}),i&&e.jsxs("p",{className:"text-sm text-slate-500",children:[n(s.capacityUsed,a)," / ",n(s.capacityLimit,a)]})]}),i?e.jsx(ae,{value:d,max:s.capacityLimit,className:"mt-3","aria-label":t("Hub capacity used")}):e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:t("Capacity information is not available yet.")})]}),e.jsxs("div",{className:"rounded-[14px] bg-slate-50 px-4 py-3 md:min-w-52",children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.14em] text-slate-500",children:t("Accrued storage charge")}
1),e.jsx("p",{className:"mt-1 text-lg font-semibold text-slate-900",children:s.accruedCharge==null?"—":X(s.accruedCharge,s.currency,a,{maximumFractionDigits:2})}),s.nextBillingDate&&e.jsxs("p",{className:"mt-1 text-xs text-slate-500",children:[t("Next billing"),": ",_(s.nextBillingDate,a)]})]})]})})]})},ue=({unit:s,copy:t,locale:a})=>e.jsxs("article",{className:"group grid gap-4 rounded-[14px] border border-slate-200 bg-white p-5 transition-[border-color,background-color,transform] hover:-translate-y-0.5 hover:border-primary/40 hover:bg-primary/[0.025] sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center","data-testid":`hub-stock-row-${s.unitId}`,children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 rounded-xl bg-primary/10 p-2.5 text-primary","aria-hidden":"true",children:e.jsx(I,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(H,{to:`/account/hub/${encodeURIComponent(s.unitId)}`,className:"block truncate text-base font-semibold text-slate-950 hover:text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2",children:s.productName?a==="ar"?G(s.productName,t):s.productName:t("Hub product")}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-slate-600",children:[e.jsx("span",{className:"rounded-full bg-slate-100 px-2.5 py-1",children:s.colorName?Z(s.colorName,a):t("Colour not set")}),e.jsxs("span",{className:"rounded-full bg-slate-100 px-2.5 py-1",children:[t("Size")," ",s.size||t("One size")]}),s.variantSku&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-slate-100 px-2.5 py-1",children:[e.jsx(ne,{className:"h-3 w-3","aria-hidden":"true"}),s.variantSku]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-slate-500",children:[s.orderNumber&&e.jsxs("span",{children:[t("From order")," ",e.jsxs(H,{to:`/dashboard/orders/${encodeURIComponent(s.orderNumber)}`,className:"inline-flex items-center gap-1 font-medium text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2",children:[s.orderNumber,e.jsx(ce,{className:"h-3 w-3","aria-hidden":"true"})]})]}),s.providerName&&e.jsxs("span",{children:[t("Fulfilled by")," ",e.jsx("span",{className:"font-medium text-slate-700",children:s.providerName})]}),e.jsxs("span",{children:[s.quantity.toLocaleString(a)," ",t(s.quantity===1?"unit":"units")]}),s.receivedAt&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(oe,{className:"h-3.5 w-3.5","aria-hidden":"true"}),_(s.receivedAt,a)]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-slate-100 pt-3 sm:border-0 sm:pt-0",children:[e.jsx(se,{variant:me(s.status),children:t(de[s.status]??"Unknown")}),e.jsx("span",{className:"rounded-full p-2 text-slate-400","aria-hidden":"true",children:e.jsx(J,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5 rtl:rotate-180"})})]})]}),he=({inventoryList:s})=>{const{locale:t}=R(),a=l=>T(l,t),[i,d]=q.useState(!1),{data:b,loading:B,error:N,refetch:z,fetchMore:v}=E(te,{variables:{page:0,size:h},fetchPolicy:"cache-and-network"}),{data:f,loading:M,error:Q,refetch:O}=E(re,{fetchPolicy:"cache-and-network"}),r=b==null?void 0:b.myHubStockPage,m=(r==null?void 0:r.items)??[],x=m.filter(l=>s==="active"?A.has(l.status):!A.has(l.status)),y=f==null?void 0:f.myHubStockSummary,V=async()=>{if(!r){await z({page:0,size:h});return}const l=r.page;let o;for(let p=0;p<=l;p+=1)await v({variables:{page:p,size:h},updateQuery:(S,{fetchMoreResult:g})=>g?(o=o?P(o,g):g,p===l?o:S):S})},w=()=>{Promise.all([V(),O()]).catch(()=>{C.error(a("Unable to refresh Hub inventory."))})},Y=async()=>{if(!(!(r!=null&&r.hasNextPage)||i)){d(!0);try{await v({variables:{page:r.page+1,size:h},updateQuery:(l,{fetchMoreResult:o})=>o?P(l,o):l})}catch{C.error(a("Unable to load more Hub inventory."))}finally{d(!1)}}};return B||M?e.jsx(xe,{}):e.jsxs("div",{className:"mx-auto w-full max-w-6xl space-y-6 px-4 py-8 md:px-8","data-testid":"hub-inventory-page",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 inline-flex items-center gap-2 rounded-full bg-primary/10 px-3 py-1.5 text-xs font-semibold uppercase tracking-[0.14em] text-primary",children:[e.jsx(ie,{className:"h-3.5 w-3.5","aria-hidden":"true"}),a("PrintaRex Hub")]}),e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-slate-900",children:a("Hub Inventory")}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-slate-500",children:a("View products held for you at PrintaRex and request a UAE shipment when a unit is ready.")})]}),e.jsxs(j,{variant:"outline",size:"sm",onClick:w,className:"self-start sm:self-auto",children:[e.jsx(le,{className:"h-4 w-4","aria-hidden":"true"}),a("Refresh")]})]}),N&&e.jsxs(k,{variant:"destructive",children:[e.jsx(U,{children:a("Hub inventory could not be loaded")}),e.jsxs(D,{className:"mt-2 flex flex-wrap items-center gap-3",children:[e.jsx("span",{children:a("The server did not return your Hub inventory. Please try again.")}),e.jsx(j,{size:"sm",variant:"outline",onClick:w,children:a("Try again")})]})]}),Q&&!N&&e.jsxs(k,{variant:"warning",children:[e.jsx(U,{children:a("Hub totals are temporarily unavailable")}),e.jsx(D,{children:a("Your inventory list is still available. Totals will appear when the server responds.")})]}),y&&e.jsx(pe,{summary:y,copy:a,locale:t}),e.jsxs(c,{className:"border-slate-200",children:[e.jsx(K,{className:"flex-row flex-wrap items-center justify-between gap-3 pb-4",children:e.jsxs("div",{children:[e.jsx(W,{className:"text-xl",children:a(s==="active"?"Stored units":"Unit history")}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:!r||r.totalCount===0?a("No units are currently shown for your account."):e.jsxs(e.Fragment,{children:[n(x.length,t)," ",a(x.length===1?"unit":"units")," · ",a("Loaded {loaded} of {total} units").replace("{loaded}",n(m.length,t)).replace("{total}",n(r.totalCount,t))]})})]})}),e.jsxs(L,{className:"space-y-3",children:[x.length===0?e.jsxs("div",{className:"rounded-[14px] border border-dashed border-slate-300 bg-slate-50 px-5 py-10 text-center",children:[e.jsx(I,{className:"mx-auto h-8 w-8 text-slate-400","aria-hidden":"true"}),e.jsx("p",{className:"mt-3 font-medium text-slate-800",children:a(m.length===0?"Your Hub inventory is empty":s==="active"?"No active Hub units":"No Hub history yet")}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:a(m.length===0?"Units appear here after PrintaRex confirms physical receipt.":s==="active"?"Load more to check for active units, or open History to view completed units.":"Shipped, disposed, and cancelled units appear here.")})]}):e.jsx("div",{className:"space-y-3","data-testid":"hub-stock-list",children:x.map(l
1=>e.jsx(ue,{unit:l,copy:a,locale:t},l.unitId))}),(r==null?void 0:r.hasNextPage)&&e.jsx("div",{className:"flex justify-center pt-3",children:e.jsx(j,{type:"button",variant:"outline",onClick:()=>void Y(),disabled:i,"data-testid":"hub-stock-load-more",children:a(i?"Loading more…":"Load more")})})]})]})]})},He=({inventoryList:s="active"})=>F.enabled()?e.jsx(he,{inventoryList:s}):e.jsx($,{to:"/dashboard",replace:!0});export{He as HubInventoryPage};

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.