PageSourceSearch

https://www.lifetimemovers.us/assets/Archives-C80H8ssh.js

js lifetimemovers.us collected 2026-10-09 23:03:47 UTC 12,138 bytes, 2 lines download raw bytes

1import{y as V,s as f,j as e,m as y,C as T,o as S}from"./index-Btwe7OM_.js";import{r as D}from"./carousel-Ywnn_L1b.js";import{u as J}from"./useQuery-XvkwiZrA.js";import{u as z}from"./useMutation-VvhcR3px.js";import{I as O}from"./input-BSdelcww.js";import{B as v}from"./badge-DZQL15lS.js";import{T as Y,a as G,b as A,c as B}from"./tabs-DzCyXoLI.js";import{T as L,a as $,b as d,c as t,d as q,e as r}from"./table-D0jRHYTT.js";import{toast as C}from"./index-B3iVyTQb.js";import{D as W,a as X,b as Z,c as ee,d as se,e as ae}from"./dialog-Dkcayg94.js";import{A as re,a as te}from"./alert-DfTzsRUZ.js";import{cz as E,r as H,H as ie,s as ce,b9 as I,Y as F}from"./icons-EWXH9Ucy.js";import{f as Q}from"./formatDistanceToNow-Bejb3pwS.js";import{P as ne}from"./PageBreadcrumb-ffWy9Xw8.js";import"./pdf-CGsjJpaq.js";import"./charts-B0JxqJjf.js";import"./mapbox-gl-B7jh3gon.js";import"./supabase-BSoIuNt1.js";import"./index-BWnZCI9Y.js";import"./index-DJnzKn2Q.js";import"./index-yhi_i3rm.js";import"./index-C8vZXRoo.js";import"./Combination-DlbveIUj.js";import"./index-BUtf7Ub_.js";import"./constructNow-Dgiim5Sr.js";import"./en-US-N0Vr6b0S.js";import"./differenceInCalendarMonths-X2iIndw0.js";import"./endOfDay-DbZTSzaO.js";import"./endOfMonth-D6LcxRly.js";import"./differenceInMilliseconds-DVMHSj_a.js";import"./breadcrumb-lxzhVvby.js";const oe=({open:i,onOpenChange:h,recordType:c,recordId:l,vbNumber:p,customerName:g})=>{const u=V(),j=z({mutationFn:async()=>{const n=c==="booking"?"online_bookings":c==="job"?"jobs":"leads",{error:b}=await f.from(n).update({archive_category:"dead_lead"}).eq("id",l);if(b)throw b},onSuccess:()=>{C.success("Record rescued successfully",{description:`${p||"Record"} moved to Dead Leads`}),u.invalidateQueries({queryKey:["archived-records"]}),h(!1)},onError:n=>{C.error("Failed to rescue record",{description:n.message})}}),k=()=>{j.mutate()};return e.jsx(W,{open:i,onOpenChange:h,children:e.jsxs(X,{className:"sm:max-w-[500px]",children:[e.jsxs(Z,{children:[e.jsxs(ee,{className:"flex items-center gap-2",children:[e.jsx(E,{className:"h-5 w-5 text-amber-500"}),"Rescue Record from Bad Data"]}),e.jsx(se,{children:"Move this record from Bad Data to Dead Leads to prevent automatic deletion"})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs(re,{children:[e.jsx(H,{className:"h-4 w-4"}),e.jsxs(te,{children:[p&&e.jsxs("div",{className:"font-medium mb-1",children:["VB Number: ",e.jsx("span",{className:"font-mono",children:p})]}),g&&e.jsxs("div",{className:"mb-2",children:["Customer: ",g]}),e.jsx("div",{className:"text-muted-foreground text-sm",children:"This record will be moved to Dead Leads and will no longer be scheduled for automatic deletion. It can still be used for marketing and analytics purposes."})]})]})}),e.jsxs(ae,{children:[e.jsx(y,{variant:"outline",onClick:()=>h(!1),disabled:j.isPending,children:"Cancel"}),e.jsx(y,{onClick:k,disabled:j.isPending,className:"bg-amber-600 hover:bg-amber-700",children:j.isPending?"Rescuing...":"Rescue Record"})]})]})})},M=(i,h)=>{const c=h?.toLowerCase()||"",l=i?.toLowerCase()||"";return c.includes("bad")||c.includes("spam")||c.includes("test")||c.includes("fake")||c.includes("duplicate")?"bad_data":l==="booked"||l==="job"||l==="converted"||l==="completed"||l==="closed"||l==="paid"||l==="accepted"?"booked_job":"dead_lead"};function de(){const[i,h]=D.useState(""),[c,l]=D.useState("booked_job"),[p,g]=D.useState(!1),[u,j]=D.useState(null),k=V(),{data:n,isLoading:b}=J({queryKey:["archived-records",c,i],queryFn:async()=>{const s=[];let o=f.from("online_bookings").select("*").eq("archived",!0).order("archived_at",{ascending:!1});i&&(o=o.or(`customer_name.ilike.%${i}%,vb_number.ilike.%${i}%`));const{data:m}=await o;m&&s.push(...m.map(a=>{const x=a.archive_category||M(a.status,a.archive_reason);return{id:a.id,vb_number:a.vb_number||void 0,customer_name:a.customer_name||void 0,status:a.status||void 0,archived_at:a.archived_at,archived_by:a.archived_by||void 0,archive_reason:a.archive_reason||void 0,archive_category:x,record_type:"booking"}}).filter(a=>a.archive_category===c));let _=f.from("jobs").select("*").eq("archived",!0).order("archived_at",{ascending:!1});i&&(_=_.or(`vb_number.ilike.%${i}%`));const{data:w}=await _;w&&s.push(...w.map(a=>{const x=a.archive_category||M(a.status,a.archive_reason);return{id:a.id,vb_number:a.vb_number||void 0,customer_name:a.vb_number||"Job",status:a.status||void 0,archived_at:a.archived_at,archived_by:a.archived_by||void 0,archive_reason:a.archive_reason||void 0,archive_category:x,record_type:"job"}}).filter(a=>a.archive_category===c));let R=f.from("leads").select("*").eq("archived",!0).order("archived_at",{ascending:!1});i&&(R=R.or(`contact_name.ilike.%${i}%,vb_number.ilike.%${i}%`));const{data:P}=await R;return P&&s.push(...P.map(a=>{const x=a.archive_category||M(a.status,a.archive_reason);return{id:a.id,vb_number:a.vb_number||void 0,customer_name:a.contact_name||void 0,status:a.status||void 0,archived_at:a.archived_at,archived_by:a.archived_by||void 0,archive_reason:a.archive_reason||void 0,archive_category:x,record_type:"lead"}}).filter(a=>a.archive_category===c)),s.sort((a,x)=>new Date(x.archived_at).getTime()-new Date(a.archived_at).getTime())}}),N=z({mutationFn:async s=>{const o=s.record_type==="booking"?"online_bookings":s.record_type==="job"?"jobs":s.record_type==="customer"?"customers":"leads",{error:m}=await f.from(o).update({archived:!1,archived_at:null,archived_by:null,archive_reason:null,archive_category:null}).eq("id",s.id);if(m)throw m},onSuccess:(s,o)=>{C.success("Record reactivated",{description:`${o.vb_number||o.customer_name} has been reactivated`}),k.invalidateQueries({queryKey:["archived-records"]})},onError:s=>{C.error("Failed to reactivate record",{description:s.message})}}),K=s=>{j(s),g(!0)},U=s=>{const o=new Date(s),m=new Date(o);m.setDate(m.getDate()+30);const _=new Date,w=Math.ceil((m.getTime()-_.getTime())/(1e3*60*60*24));return Math.max(0,w)};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(ie,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(O,{placeholder:"Search archives...",value:i,onChange:s=>h(s.target.value),onDoubleClick:()=>h(""),className:"pl-9"})]})}),e.jsxs(Y,{value:c,onValueChange:s=>l(s),children:[e.jsxs(G,{children:[e.jsxs(A,{value:"booked_job",className:"data-[state=active]:bg-green-500/20",children:[e.jsx(ce,{className:"h-4 w-4 mr-2"}),"Booked Jobs"]}),e.jsxs(A,{value:"dead_lead",className:"data-[state=active]:bg-amber-500/20",children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),"Dead Leads"]}),e.jsxs(A,{value:"bad_data",className:"data-[state=active]:bg-destructive/20",children:[e.jsx(I,{className:"h-4 w-4 mr-2"}),"Bad Data"]})]}),e.jsx(B,{value:"booked_job",children:e.jsx(T,{className:"border-green-500/20",children:e.jsx(S,{className:"p-6",children:e.jsxs(L,{children:[e.jsx($,{children:e.jsxs(d,{children:[e.jsx(t,{children:"VB Number"}),e.jsx(t,{children:"Customer"}),e.jsx(t,{children:"Type"}),e.jsx(t,{children:"Status"}),e.jsx(t,{children:"Archived"}),e.jsx(t,{children:"Reason"}),e.jsx(t,{className:"text-right",children:"Actions"})]})}),e.jsx(q,{children:b?e.jsx(d,{children:e.jsx(r,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):n&&n.length>0?n.map(s=>e.jsxs(d,{children:[e.jsx(r,{className:"font-mono",children:s.vb_number||"N/A"}),e.jsx(r,{children:s.customer_name}),e.jsx(r,{children:e.jsx(v,{variant:"outline",children:s.record_type})}),e.jsx(r,{children:e.jsx(v,{variant:"secondary",children:s.status})}),e.jsx(r,{className:"text-sm text-muted-foreground",children:Q(new Date(s.archived_at),{addSuffix:!0})}),e.jsx(r,{className:"text-sm text-muted-foreground max-w-xs truncate",children:s.archive_reason||"No reason provided"}),e.jsx(r,{className:"text-right",children:e.jsxs(y,{variant:"ghost",size:"sm",onClick:()=>N.mutate(s),disabled:N.isPending,children:[e.jsx(F,{className:"h-4 w-4 mr-2"}),"Reactivate"]})})]},`${s.record_type}-${s.id}`)):e.jsx(d,{children:e.jsx(r,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No booked jobs archived"})})})]})})})}),e.jsx(B,{value:"dead_lead",children:e.jsx(T,{className:"border-amber-500/20",children:e.jsx(S,{className:"p-6",children:e.jsxs(L,{children:[e.jsx($,{children:e.jsxs(d,{children:[e.jsx(t,{children:"VB Number"}),e.jsx(t,{children:"Customer"}),e.jsx(t,{children:"Type"}),e.jsx(t,{children:"Status"}),e.jsx(t,{children:"Archived"}),e.jsx(t,{children:"Reason"}),e.jsx(t,{className:"text-right",children:"Actions"})]})}),e.jsx(q,{children:b?e.jsx(d,{children:e.jsx(r,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):n&&n.length>0?n.map(s=>e.jsxs(d,{children:[e.jsx(r,{className:"font-mono",children:s.vb_number||"N/A"}),e.jsx(r,{children:s.customer_name}),e.jsx(r,{children:e.jsx(v,{variant:"outline",children:s.record_type})}),e.jsx(r,{children:e.jsx(v,{variant:"secondary",children:s.status})}),e.jsx(r,{className:"text-sm text-muted-foreground",children:Q(new Date(s.archived_at),{addSuffix:!0})}),e.jsx(r,{className:"text-sm text-muted-foreground max-w-xs truncate",children:s.archive_reason||"No reason provided"}),e.jsx(r,{className:"text-right",children:e.jsxs(y,{variant:"ghost",size:"sm",onClick:()=>N.mutate(s),disabled:N.isPending,children:[e.jsx(F,{className:"h-4 w-4 mr-2"}),"Reactivate"]})})]},`${s.record_type}-${s.id}`)):e.jsx(d,{children:e.jsx(r,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No dead leads archived"})})})]})})})}),e.jsx(B,{value:"bad_data",children:e.jsx(T,{className:"border-destructive/20",children:e.jsx(S,{className:"p-6",children:e.jsxs(L,{children:[e.jsx($,{children:e.jsxs(d,{children:[e.jsx(t,{children:"VB Number"}),e.jsx(t,{children:"Customer"}),e.jsx(t,{children:"Type"}),e.jsx(t,{children:"Status"}),e.jsx(t,{children:"Archived"}
1),e.jsx(t,{children:"Days Until Deletion"}),e.jsx(t,{children:"Reason"}),e.jsx(t,{className:"text-right",children:"Actions"})]})}),e.jsx(q,{children:b?e.jsx(d,{children:e.jsx(r,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):n&&n.length>0?n.map(s=>{const o=U(s.archived_at);return e.jsxs(d,{children:[e.jsx(r,{className:"font-mono",children:s.vb_number||"N/A"}),e.jsx(r,{children:s.customer_name}),e.jsx(r,{children:e.jsx(v,{variant:"outline",children:s.record_type})}),e.jsx(r,{children:e.jsx(v,{variant:"secondary",children:s.status})}),e.jsx(r,{className:"text-sm text-muted-foreground",children:Q(new Date(s.archived_at),{addSuffix:!0})}),e.jsx(r,{children:e.jsxs(v,{variant:o<=7?"destructive":"secondary",className:"font-mono",children:[o," days"]})}),e.jsx(r,{className:"text-sm text-muted-foreground max-w-xs truncate",children:s.archive_reason||"No reason provided"}),e.jsx(r,{className:"text-right",children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>K(s),className:"bg-amber-600 hover:bg-amber-700 text-white",children:[e.jsx(E,{className:"h-4 w-4 mr-2"}),"Rescue"]})})})]},`${s.record_type}-${s.id}`)}):e.jsx(d,{children:e.jsx(r,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No bad data archived"})})})]})})})})]}),u&&u.record_type!=="customer"&&e.jsx(oe,{open:p,onOpenChange:g,recordType:u.record_type,recordId:u.id,vbNumber:u.vb_number,customerName:u.customer_name})]})}function ze(){return e.jsxs("div",{className:"space-y-6",children:[e.jsx(ne,{items:[{label:"Settings",href:"/admin/settings"},{label:"Archives"}]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-8 w-8 text-orange-500"}),e.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Archives Management"})]}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"View and manage archived leads, customers, jobs, and bookings. Reactivate records or configure auto-archive policies."})]}),e.jsx(de,{})]})}export{ze as default};
2//# sourceMappingURL=Archives-C80H8ssh.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.