PageSourceSearch

https://cresla.ai/assets/MailStatus-DQPpKJ6T.js

js cresla.ai collected 2026-10-05 11:58:21 UTC 15,818 bytes, 7 lines download raw bytes

1import{u as Z,r as J,j as e}from"./vendor-query-J00DIBcE.js";import{c as X,as as z,a8 as ee,a5 as se,aS as te,Z as M,B as C,aa as m,U as F,Q as ae}from"./index-B3ZlzEWD.js";import{S as f}from"./skeleton-BGoMwMsw.js";import{a as re,c as ne,M as ie}from"./MailShell-Dht_46ZS.js";import{S as oe}from"./SectionShell-BgALUEFk.js";import{S as de}from"./SectionHeader-CwoSmyl8.js";import{o as le,T as c}from"./mailingFlow-DNnt1pS2.js";import{L as me}from"./LetterPdfLink-B48oPirZ.js";import{b as ce}from"./mailingApi-D0CBWLY8.js";import{D as ue}from"./featureFlags-D4a-q0-l.js";import{P as pe}from"./printer-CeY5EC2D.js";import{S as Y}from"./send-8r23B0TE.js";import{M as D}from"./mail-check-BVCm1ocK.js";import{T as xe}from"./truck-BiYzIeY4.js";import{C as U}from"./clock-CaV97cIf.js";import"./vendor-ui-CVP04gIJ.js";import"./AppSidebar-CT4tp3lH.js";import"./separator-Cj-nwL8i.js";import"./sheet-CPGi3j0-.js";import"./timeUtils-CpFfP7Pa.js";import"./format-Cjmg7hXF.js";import"./badge-DAUjQRt7.js";import"./collapsible-A-Y48tbE.js";import"./index-DfWEF0tj.js";import"./useUpgrade-D3QPxkAk.js";import"./useSupportAlertEngine-B2bgekHO.js";import"./star-CCdmtuFi.js";import"./chevron-right-QJOe4PqW.js";import"./dropdown-menu-DQHyBtjf.js";import"./user-DQbK8SAK.js";import"./moon-B3DpdQml.js";import"./sun-D5znQVk8.js";import"./settings-C4ycOjTG.js";import"./alert-dialog-CCUy2b_-.js";import"./search-1peXtAyN.js";import"./pencil-CPZ8HiTP.js";import"./plus-Cls1xk49.js";import"./users-ww9v9YAz.js";import"./layout-dashboard-C7KDJvrs.js";import"./wrench-BmmqG_uq.js";import"./trophy-CporpeMZ.js";import"./trash-2-939pZxih.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const $=X("PackageCheck",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]),_={equifax:"Equifax",experian:"Experian",transunion:"TransUnion"},E=24*60*60*1e3;function T(t){if(!t)return null;const r=new Date(t);return Number.isNaN(r.getTime())?null:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(r)}function p(t){if(!t)return null;const r=new Date(t);return Number.isNaN(r.getTime())?null:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(r)}function H(t){if(!(t!=null&&t.latestAt))return!1;const r=new Date(t.latestAt).getTime();return!Number.isNaN(r)&&Date.now()>r}function S(t){if(!t.responseDueAt)return{phase:"waiting",dayOfWindow:0,daysLeft:30};const r=new Date(t.responseDueAt).getTime(),g=t.windowClosesAt?new Date(t.windowClosesAt).getTime():r+15*E,o=Date.now();if(o>=g)return{phase:"closed",dayOfWindow:30,daysLeft:0};if(o>=r)return{phase:"open",dayOfWindow:30,daysLeft:0};
6const a=Math.max(1,Math.ceil((r-o)/E));return{phase:"counting",dayOfWindow:Math.min(30,Math.max(1,30-a+1)),daysLeft:a}}function he({letter:t,estimated:r,orderId:g}){const o=_[t.bureau]??t.bureau,a=!!t.deliveredAt||t.deliveryStatus==="delivered",l=S(t),x=r?"Estimated day":"Day",j=r&&!a&&H(t.estimatedDelivery),i=t.scans.length?t.scans[t.scans.length-1]:null,w=!a&&/out for delivery/i.test((i==null?void 0:i.status)??"");return e.jsxs("div",{className:"cresla-native-mail-bureau rounded-2xl border border-card-border bg-card p-5 shadow-sm","data-testid":`bureau-card-${t.bureau}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-base font-semibold",children:o}),a?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-emerald-500/10 px-3 py-1 text-xs font-semibold text-emerald-600 dark:text-emerald-400",children:[e.jsx(D,{className:"h-3.5 w-3.5"}),"Delivered",t.deliveredAt?` ${p(t.deliveredAt)}`:""]}):w?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-primary/10 px-3 py-1 text-xs font-semibold text-primary",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),"Out for delivery"]}):j?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-primary/10 px-3 py-1 text-xs font-semibold text-primary",children:[e.jsx(D,{className:"h-3.5 w-3.5"}),"Should have arrived"]}):t.deliveryStatus==="in_transit"?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-primary/10 px-3 py-1 text-xs font-semibold text-primary",children:[e.jsx(Y,{className:"h-3.5 w-3.5"}),"In transit"]}):e.jsx("span",{className:"rounded-full bg-muted px-3 py-1 text-xs font-medium text-muted-foreground",children:t.deliveryStatus==="mailed"?"On its way":t.deliveryStatus==="printing"?"Printing":"Preparing"})]}),t.scans.length>0&&e.jsx("ol",{className:"mt-3 space-y-1.5 border-l-2 border-border/60 pl-4",children:t.scans.map((d,n)=>e.jsxs("li",{className:"text-sm leading-snug",children:[e.jsx("span",{className:"text-foreground",children:d.status.toLowerCase()}),e.jsxs("span",{className:"text-muted-foreground",children:[d.facility?` at ${d.facility.toLowerCase()}`:"",p(d.at)?`, ${p(d.at)}`:""]})]},`${d.at}-${n}`))}),l.phase==="counting"&&e.jsxs("div",{className:"mt-3 flex items-center gap-2.5 rounded-xl bg-primary/5 px-4 py-3",children:[e.jsx(U,{className:"h-4 w-4 shrink-0 text-primary"}),e.jsxs("p",{className:"text-sm",children:[e.jsxs("span",{className:"font-semibold",children:[x," ",l.dayOfWindow," of 30."]})," ",e.jsxs("span",{className:"text-muted-foreground",children:[o," has ",l.daysLeft," ",l.daysLeft===1?"day":"days"," left",r?" (estimated)":"","."]})]})]}),l.phase==="open"&&e.jsxs("div",{className:"mt-3 flex items-center gap-2.5 rounded-xl bg-amber-500/10 px-4 py-3",children:[e.jsx(U,{className:"h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("p",{className:"text-sm",children:[e.jsxs("span",{className:"font-semibold",children:["Response window open",r?" (estimated)":"","."]})," ",e.jsx("span",{className:"text-muted-foreground",children:"Watch your mailbox and your report."})]})]}),l.phase==="closed"&&e.jsxs("div",{className:"mt-3 flex items-center gap-2.5 rounded-xl bg-muted px-4 py-3",children:[e.jsx(F,{className:"h-4 w-4 shrink-0 text-foreground"}),e.jsxs("p",{className:"text-sm",children:[e.jsx("span",{className:"font-semibold",children:"Window closed."})," ",e.jsx("span",{className:"text-muted-foreground",children:"Time for your next round."})]})]}),t.trackingNumber&&e.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:["USPS tracking: ",e.jsx("span",{className:"allow-select break-all font-mono",children:t.trackingNumber})]}),ue]})}function rs(){const[,t]=z("/mail/order/:orderId/status"),r=t==null?void 0:t.orderId,[,g]=ee(),{isNative:o}=se(),{data:a,isLoading:l,isError:x,error:j,isFetching:i,refetch:w,dataUpdatedAt:d}=Z({queryKey:[`/api/mailing/orders/${r}`],queryFn:()=>ce(r),enabled:!!r,staleTime:0,refetchOnMount:"always",refetchInterval:s=>{var h,N;const b=(N=(h=s.state.data)==null?void 0:h.order)==null?void 0:N.status;return b==="delivered"||b==="refunded"||b==="canceled"?6e4:1e4},refetchOnWindowFocus:!0,refetchOnReconnect:!0,retry:1}),n=j?te(j):null,q=(n==null?void 0:n.status)===401||(n==null?void 0:n.status)===403?"unauthorized":(n==null?void 0:n.status)===404?"not-found":(n==null?void 0:n.status)===0&&typeof navigator<"u"&&!navigator.onLine?"offline":n?"transient":null,G={unauthorized:["Sign in to view mailing status","Your session may have ended. Sign in again, then refresh this page."],"not-found":["Mailing status not found","We couldn't find this mailing order. It may have been removed or the link may be out of date."],offline:["You're offline","We couldn't check your mailing status. Reconnect, then try again."],transient:["Mailing status is temporarily unavailable","We couldn't check for new updates. Your letters have not been changed."]},K=J.useMemo(()=>le((a==null?void 0:a.letters)??[]),[a==null?void 0:a.letters]);function A(s){return o?e.jsx(ie,{onBack:()=>g("/chat"),backLabel:"Back to chat",children:s}):e.jsxs(oe,{children:[e.jsx(de,{icon:D,title:"Mailing status",subtitle:"We'll notify you as each letter moves",containerClass:"max-w-[1500px]"}),e.jsx("div",{className:"flex-1 overflow-y-auto pb-[max(2.5rem,env(safe-area-inset-bottom))]",children:s})]})}if(l||!r)return A(e.jsx("div",{className:"mx-auto w-full max-w-[1500px] px-5 py-6 sm:px-8 sm:py-8","aria-busy":"true","aria-label":"Loading your mailing status",children:e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2 lg:gap-4",children:[e.jsx("div",{className:"rounded-3xl border border-card-border bg-card p-5 shadow-sm sm:p-7",children:e.jsx("div",{className:"space-y-8",children:[0,1,2].map(s=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(f,{className:"h-12 w-12 shrink-0 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2.5",children:[e.jsx(f,{className:"h-4 w-36"}),s===0&&e.jsx(f,{className:"h-3 w-52 max-w-full"})]})]},s))})}),e.jsx("div",{className:"grid gap-3 lg:content-between",children:[0,1,2].map(s=>e.jsxs("div",{className:"rounded-2xl border border-card-border bg-card p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(f,{className:"h-5 w-28"}),e.jsx(f,{className:"h-6 w-24 rounded-full"})]}),e.jsx(f,{className:"mt-4 h-3 w-56 max-w-full"})]},s))})]})}));if(!a){const s=G[q??"transient"];return A(e.jsxs(re,{children:[e.jsx(M,{className:"h-12 w-12 text-primary"}),e.jsx("h1",{className:"mt-6 text-3xl font-semibold tracking-tight",children:s[0]}),e.jsx("p",{className:"mt-3 max-w-md text-base leading-relaxed text-muted-foreground",children:s[1]}),e.jsxs(C,{className:"mt-6 h-11 rounded-xl px-5",onClick:()=>void w(),disabled:i,"data-testid":"button-refresh-mail-status",children:[e.jsx(M,{className:m("mr-2 h-4 w-4",i&&"animate-spin")}),i?"Checking…":"Retry"]})]}))}const u=a.order.mailType==="certified",Q=c[K]??0,L=a.letters.map(s=>
6s.mailedAt).filter(Boolean),I=L.length?new Date(Math.max(...L.map(s=>new Date(s).getTime()))):null,v=u?null:a.letters.map(s=>s.estimatedDelivery).find(Boolean)??null,R=!u&&H(v),W=a.letters.map(s=>s.responseDueAt).filter(Boolean),B=W.length?new Date(Math.max(...W.map(s=>new Date(s).getTime()))):null,P=[{id:"confirmed",label:"Confirmed",rank:c.confirmed,Icon:$,date:a.order.released?T(a.order.releasedAt):null},{id:"printing",label:"Printing",rank:c.printing,Icon:pe},{id:"mailed",label:I?`Handed to USPS on ${p(I)}`:"Handed to USPS",rank:c.mailed,Icon:Y},...!u&&v?[{id:"estimated",label:`Estimated delivery ${p(v.earliestAt)} to ${p(v.latestAt)}`,rank:c.in_transit,Icon:D}]:[],...!u&&R&&B?[{id:"responses",label:`Bureau responses due by ${p(B)}`,rank:c.delivered,Icon:$}]:[]];let k=Math.max(Q,a.order.released?c.confirmed:0);!u&&R&&(k=Math.max(k,c.delivered));const O=a.letters.length>0&&!!(u||I);return A(e.jsxs("div",{className:"cresla-native-mail-status mx-auto w-full max-w-[1500px] px-5 py-6 sm:px-8 sm:py-8",children:[(i||x)&&e.jsxs("div",{className:m("mb-4 flex flex-wrap items-center justify-between gap-3 rounded-2xl border px-4 py-3 text-sm",x?"border-amber-500/30 bg-amber-500/10":"border-border bg-muted/50"),role:x?"alert":"status","data-testid":"mail-status-refresh-state",children:[e.jsx("span",{children:x?"We couldn't complete the latest check. The information below is from your last successful refresh.":"Checking for new mailing updates…"}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>void w(),disabled:i,"data-testid":"button-refresh-mail-status",children:[e.jsx(M,{className:m("mr-2 h-4 w-4",i&&"animate-spin")}),i?"Checking…":"Refresh"]})]}),!i&&d>0&&e.jsxs("p",{className:"mb-4 text-right text-xs text-muted-foreground","data-testid":"mail-status-last-refreshed",children:["Last successful refresh:"," ",new Intl.DateTimeFormat("en-US",{dateStyle:"medium",timeStyle:"short"}).format(d)]}),o&&e.jsx(ne,{title:"Mailing status",subtitle:"We'll notify you as each letter moves. No postal jargon to decode."}),e.jsxs("div",{className:m("space-y-4",o&&"mt-6"),children:[e.jsxs("div",{className:m("grid gap-4",O&&"lg:grid-cols-2 lg:gap-4"),children:[e.jsx("ol",{className:"rounded-3xl border border-card-border bg-card p-5 shadow-sm sm:p-7","aria-label":"Mailing progress",children:P.map((s,b)=>{const y=k>s.rank,h=k===s.rank,N=!y&&!h,V=s.Icon;return e.jsxs("li",{className:"relative flex gap-4 pb-7 last:pb-0",children:[b<P.length-1&&e.jsx("span",{"aria-hidden":"true",className:m("absolute left-[23px] top-12 h-[calc(100%-2.25rem)] w-0.5",y?"bg-primary":"bg-border")}),e.jsx("span",{className:m("relative z-10 flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full border-2",y&&"border-primary bg-primary text-primary-foreground",h&&"border-primary bg-primary/10 text-primary",N&&"border-border bg-muted text-muted-foreground"),children:y?e.jsx(F,{className:"h-5 w-5",strokeWidth:3}):e.jsx(V,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1 pt-2.5",children:[e.jsx("p",{className:m("text-base font-semibold",N&&"text-muted-foreground"),children:s.label}),h&&e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"This is where your letters are now."}),s.date&&e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.date})]})]},s.id)})}),O&&e.jsx("div",{className:"grid gap-3 lg:content-between",children:a.letters.map(s=>e.jsx(he,{letter:s,estimated:!u,orderId:a.order.id},s.bureau))})]}),a.order.released&&e.jsxs("div",{className:"rounded-2xl border border-card-border bg-card px-5 py-5 shadow-sm sm:px-6",children:[e.jsx("p",{className:"text-base font-semibold",children:a.letters.some(s=>S(s).phase==="closed")?"Their window is closed.":a.letters.some(s=>S(s).phase==="open")?"Responses should have arrived.":"Got your responses already?"}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-muted-foreground",children:a.letters.some(s=>S(s).phase!=="counting"&&s.responseDueAt)?"Import your updated report and we'll build round 2 from what changed.":"You can start round 2 as soon as the bureaus reply. Import your updated report and we'll build the next letters from what changed."}),e.jsx(C,{className:"mt-4 h-11 rounded-xl px-5",onClick:()=>g("/chat?import=true"),"data-testid":"button-start-round-2",children:"Start round 2"})]}),e.jsxs("details",{className:"group rounded-2xl border border-border/70 bg-muted/40 px-5 py-2",children:[e.jsxs("summary",{className:"flex min-h-11 cursor-pointer list-none items-center justify-between text-sm font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:["Details",e.jsx(ae,{className:"h-4 w-4 transition-transform duration-200 group-open:rotate-180"})]}),e.jsxs("div",{className:"border-t border-border/70 py-4 text-sm leading-relaxed text-muted-foreground",children:[e.jsxs("p",{children:["Started ",T(a.order.createdAt)??"recently"]}),a.order.releasedAt&&e.jsxs("p",{className:"mt-1",children:["Sent to our mailing partner ",T(a.order.releasedAt)]}),a.letters.length>0&&e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsx("p",{className:"font-medium text-foreground",children:"Your letters"}),a.letters.map(s=>e.jsxs(me,{orderId:r,bureau:s.bureau,className:"flex min-h-11 items-center gap-3 rounded-xl bg-background px-4 font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",testId:`letter-pdf-${s.bureau}`,children:[_[s.bureau]," letter (PDF)"]},s.bureau))]}),e.jsx("p",{className:"mt-3",children:"We'll start the next round when it's time. You don't need to save a tracking number."})]})]})]})]}))}export{rs as default};
7//# sourceMappingURL=MailStatus-DQPpKJ6T.js.map

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.