PageSourceSearch

https://app.sortly.com/scripts/speedboat_addresses-HD1a12T1_bundle.js

js sortly.com collected 2026-10-01 10:21:08 UTC 15,417 bytes, 3 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["scripts/useSageAttachmentsStore-8N-vMwgV_bundle.js","scripts/speedboat-vendor-DJ0pA_pR_bundle.js","scripts/vendor-BBNELK6W_bundle.js","assets/vendor-B0RIjS4H.css","scripts/registration-8fW6h2tH_bundle.js","scripts/moment-Dt2i7U-U_bundle.js","scripts/sentry-Bq-jBV13_bundle.js","scripts/datadog-DxmyjtSX_bundle.js","assets/registration-BldnB8HG.css","scripts/analytics-BM8fH6TW_bundle.js","scripts/index-yTdTJQbB_bundle.js","scripts/slackIntegration-CyZu6SDu_bundle.js","scripts/stripe-rL9tfl_U_bundle.js","assets/index-SuTVq08V.css","scripts/speedboat-sage-vendor-CFyq5UB-_bundle.js"])))=>i.map(i=>d[i]);
2import{cl as C,R as g,eu as L,et as se,j as e}from"./vendor-BBNELK6W_bundle.js";import{b as ae,t as M}from"./registration-8fW6h2tH_bundle.js";import"./moment-Dt2i7U-U_bundle.js";import{b as te,S as ne,u as re,c as oe}from"./index-yTdTJQbB_bundle.js";import{a as ie}from"./DataTable-qiMh01YL_bundle.js";import{I as de,a as le,b as ce}from"./InputGroup-CKhUTUOA_bundle.js";import{L as pe}from"./ListPagination-D1G_WWsP_bundle.js";import{P as ue}
2from"./PageHeader-BIoeV32J_bundle.js";import{P as F}from"./PageState-BrhynsDR_bundle.js";import{S as me}from"./SpeedboatPage-C2D8J3qH_bundle.js";import{T as p}from"./Text-DAosVweU_bundle.js";import{T as ge,a as he,b as fe,c as xe}from"./Tooltip-1L3LOk8b_bundle.js";import{c as be,u as je,d as ye,C as _e,f as Se,a as ve,D as k,A as Ce,b as De,e as Ee,g as Pe,h as Ae}from"./useCompanyAddressesQuery-j5mFw1rU_bundle.js";import{t as v}from"./analytics-BM8fH6TW_bundle.js";import{u as $}from"./useSageStore-JiiaGmK6_bundle.js";import{u as Ne}from"./useDebouncedValue-C0Vl8IVi_bundle.js";import"./slackIntegration-CyZu6SDu_bundle.js";import"./useSpeedboatLayoutStore-Dsavcg7f_bundle.js";import"./cacheInvalidation-CQnAes8q_bundle.js";import{ay as z,aE as U,ci as we,aH as Ie,az as Me,F as Fe,bx as Te,Y as Re}from"./speedboat-vendor-DJ0pA_pR_bundle.js";import{B as w}from"./Button-Bn0wcnb1_bundle.js";import{C as ke}from"./Checkbox-ChOjQBlm_bundle.js";import{D as ze,a as Le,b as Oe,c as Be,d as Ke,e as Qe,f as $e,g as He}from"./Dialog-BIzCqd-G_bundle.js";import{I as Ue}from"./Input-DeXVb1SV_bundle.js";import{L as Ge}from"./Label-CmnB7q7H_bundle.js";import{D as G,a as Y,b as q,c as I,d as Ye}from"./DropdownMenu-BryQJHOw_bundle.js";import{C as qe}from"./ConfirmDialog-DG2Wzx7H_bundle.js";import{_ as Ve}from"./datadog-DxmyjtSX_bundle.js";import{B as Xe}from"./Badge-CioskMTz_bundle.js";import"./sentry-Bq-jBV13_bundle.js";import"./stripe-rL9tfl_U_bundle.js";import"./Select-Dh6cC1Dr_bundle.js";import"./Table-KX9M8kc4_bundle.js";import"./Empty-hkKWpKlI_bundle.js";import"./Skeleton-D6cCpJ8C_bundle.js";import"./useLocationsTreeQuery-DOj6Hoa8_bundle.js";import"./locations.api-2KmF98fh_bundle.js";import"./useMasterItemsCatalogQuery-BI13UgOE_bundle.js";import"./activityHistory.api-BaSoadet_bundle.js";import"./AlertDialog-B0WRSvOY_bundle.js";import"./Callout-DAkVa6ZQ_bundle.js";const Ze=ae,Je=()=>Ze().mark?.base,We=s=>{const{t:r}=C(),t=$(u=>u.setPendingSeedPrompt),n=$(u=>u.openSage),a=g.useRef(null);return{fileInputRef:a,openFilePicker:()=>{a.current?.click()},handlePickFiles:async u=>{const h=Array.from(u.target.files??[]);if(u.target.value="",h.length===0)return;const{useSageAttachmentsStore:S}=await Ve(async()=>{const{useSageAttachmentsStore:f}=await import("./useSageAttachmentsStore-8N-vMwgV_bundle.js").then(x=>x.i);return{useSageAttachmentsStore:f}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]));S.getState().addFiles(h),t(r("speedboat.pages.addresses.import.seed_prompt")),v("open_sage",{trigger:"address_import_handoff"}),n()}}},O=()=>{const{id:s}=te();return s==null?void 0:String(s)},B=()=>{const s=se();return()=>s.invalidateQueries({queryKey:[_e]})},V=async(s,r,t)=>{const n=Object.keys(t);if(n.length===0)return;const a=await Se(s),i={...a.mappingIds};for(const l of n)i[l]=t[l]?Number(r):null;await ve(s,{mappingIds:i,version:a.version})},es=()=>{const s=O(),r=B();return L({mutationFn:async({input:t,defaults:n})=>{if(!s)throw new Error("Missing company id");const a=await be(s,t),i=Object.fromEntries(Object.entries(n).filter(([,l])=>l));return await V(s,a.id,i),a},onSuccess:t=>{v("create_address",{address_id:t.id}),r()}})},ss=()=>{const s=O(),r=B();return L({mutationFn:async({addressId:t,input:n,version:a,defaultsChanges:i})=>{if(!s)throw new Error("Missing company id");const l=await je(s,t,n,a);return await V(s,t,i),l},onSuccess:t=>{v("update_address",{address_id:t.id}),r()}})},as=()=>{const s=O(),r=B();return L({mutationFn:t=>{if(!s)throw new Error("Missing company id");return ye(s,t)},onSuccess:(t,n)=>{v("delete_address",{address_id:n}),r()}})},ts={name:"",line1:"",line2:"",city:"",state:"",zipCode:"",country:""},ns=["name","line1","city","state","zipCode","country"],rs=/^[\w\d\s-]*$/,H=s=>s?{name:s.name,line1:s.line1,line2:s.line2,city:s.city,state:s.state,zipCode:s.zipCode,country:s.country}:ts,T=(s,r)=>({primary:s!==void 0&&String(r.primary)===s.id,shipping:s!==void 0&&String(r.shipping)===s.id,billing:s!==void 0&&String(r.billing)===s.id}),os=(s,r)=>{const t=r.trim();if(ns.includes(s)&&t.length===0)return M("speedboat.pages.addresses.form.errors.required");const n=s==="zipCode"?Ce:De;return t.length>n?M("speedboat.pages.addresses.form.errors.too_long",{max:n}):s==="zipCode"&&!rs.test(t)?M("speedboat.pages.addresses.form.errors.invalid_zip"):null};function X({open:s,onOpenChange:r,address:t,defaultIds:n}){const{t:a}=C(),i=t!==void 0,[l,u]=g.useState(()=>H(t)),[h,S]=g.useState(()=>T(t,n)),[f,x]=g.useState(!1),_=es(),A=ss(),c=i?A:_;g.useEffect(()=>{s&&(u(H(t)),S(T(t,n)),x(!1))},[s,t?.id]);const D=Object.fromEntries(Object.keys(l).map(o=>[o,os(o,l[o])])),K=Object.values(D).some(o=>o!==null),E=o=>{r(o),o||c.reset()},y=o=>j=>{u(m=>({...m,[o]:j.target.value}))},N=()=>
2{if(!c.isPending){if(K){x(!0);return}if(i){const o=T(t,n),j=Object.fromEntries(k.filter(m=>h[m]!==o[m]).map(m=>[m,h[m]]));A.mutate({addressId:t.id,input:l,version:t.version,defaultsChanges:j},{onSuccess:()=>{z.success(a("speedboat.pages.addresses.form.update_success")),r(!1)}});return}_.mutate({input:l,defaults:h},{onSuccess:()=>{z.success(a("speedboat.pages.addresses.form.create_success")),r(!1)}})}},P=i?"speedboat.pages.addresses.form.edit":"speedboat.pages.addresses.form.create",b=(o,j=!1)=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(Ge,{htmlFor:`address-${o}`,children:a(`speedboat.pages.addresses.form.fields.${o}`)}),e.jsx(Ue,{id:`address-${o}`,autoFocus:j,value:l[o],"aria-invalid":f&&D[o]!==null,disabled:c.isPending,onChange:y(o)}),f&&D[o]&&e.jsx(p,{variant:"body-sm",tone:"danger",children:D[o]})]});return e.jsx(ze,{open:s,onOpenChange:E,children:e.jsxs(Le,{className:"max-w-[520px]",children:[e.jsxs(Oe,{children:[e.jsx(Be,{children:a(`${P}.title`)}),e.jsx(Ke,{children:a(`${P}.description`)})]}),e.jsxs(Qe,{className:"gap-4",children:[b("name",!0),b("line1"),b("line2"),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[b("city"),b("state")]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[b("zipCode"),b("country")]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(p,{variant:"body-sm",weight:"medium",children:a("speedboat.pages.addresses.form.defaults_label")}),e.jsx("div",{className:"flex flex-wrap gap-4",children:k.map(o=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx(ke,{checked:h[o],disabled:c.isPending,"aria-label":a(`speedboat.pages.addresses.defaults.${o}`),onCheckedChange:j=>S(m=>({...m,[o]:j===!0}))}),e.jsx(p,{as:"span",variant:"body-sm",children:a(`speedboat.pages.addresses.defaults.${o}`)})]},o))})]}),c.isError&&e.jsx(p,{variant:"body-sm",tone:"danger",children:a(i?"speedboat.pages.addresses.form.update_error":"speedboat.pages.addresses.form.create_error")})]}),e.jsxs($e,{children:[e.jsx(He,{asChild:!0,children:e.jsx(w,{variant:"secondary",disabled:c.isPending,children:a("speedboat.pages.addresses.form.cancel")})}),e.jsxs(w,{onClick:N,disabled:c.isPending,children:[c.isPending&&e.jsx(ne,{size:"sm"}),c.isPending?a("speedboat.pages.addresses.form.submitting"):a(`${P}.submit`)]})]})]})})}function is({addressId:s,addressName:r,open:t,onOpenChange:n}){const{t:a}=C(),i=as(),l=h=>{n(h),h||i.reset()},u=()=>{i.mutate(s,{onSuccess:()=>{z.success(a("speedboat.pages.addresses.delete_dialog.success")),n(!1)}})};return e.jsx(qe,{open:t,onOpenChange:l,title:a("speedboat.pages.addresses.delete_dialog.title"),description:a("speedboat.pages.addresses.delete_dialog.description",{name:r}),error:i.isError?a("speedboat.pages.addresses.delete_dialog.error"):void 0,confirmLabel:i.isPending?a("speedboat.pages.addresses.delete_dialog.deleting"):a("speedboat.pages.addresses.delete_dialog.confirm"),cancelLabel:a("speedboat.pages.addresses.delete_dialog.cancel"),confirmVariant:"destructive",isConfirming:i.isPending,icon:e.jsx(U,{className:"size-5 text-danger","aria-hidden":"true"}),onConfirm:u})}function ds({address:s,defaultIds:r}){const{t}=C(),[n,a]=g.useState(!1),[i,l]=g.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(G,{children:[e.jsx(Y,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm","aria-label":t("speedboat.pages.addresses.actions.open"),children:e.jsx(we,{})})}),e.jsxs(q,{align:"end",className:"min-w-40",children:[e.jsxs(I,{className:"gap-2.5",onSelect:()=>a(!0),children:[e.jsx(Ie,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),e.jsx(p,{as:"span",variant:"body-sm",tone:"inherit",children:t("speedboat.pages.addresses.actions.edit")})]}),e.jsx(Ye,{}),e.jsxs(I,{className:"gap-2.5",variant:"destructive",onSelect:()=>l(!0),children:[e.jsx(U,{className:"size-4","aria-hidden":"true"}),e.jsx(p,{as:"span",variant:"body-sm",tone:"inherit",children:t("speedboat.pages.addresses.actions.delete")})]})]})]}),n&&e.jsx(X,{open:!0,onOpenChange:a,address:s,defaultIds:r}),i&&e.jsx(is,{addressId:s.id,addressName:s.name||s.line1,open:!0,onOpenChange:l})]})}const ls=".csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",cs=({onEnterManually:s,disabled:r=!1})=>{const{t}=C(),{fileInputRef:n,openFilePicker:a,handlePickFiles:i}=We();return e.jsxs(e.Fragment,{children:[e.jsxs(G,{children:[e.jsx(Y,{asChild:!0,disabled:r,children:e.jsxs(w,{className:"gap-2",disabled:r,children:[e.jsx(p,{as:"span",variant:"body",weight:"semibold",tone:"inverse",children:t("speedboat.pages.addresses.new_address")}),e.jsx(Me,{})]})}),e.jsxs(q,{align:"end",className:"min-w-56",children:[e.jsxs(I,{className:"gap-2.5",onSelect:()=>{v("select_new_address_option",{option:"upload_file"}),a()},children:[e.jsx(Fe,{className:"size-4 text-muted-foreground","aria-hidden":"true"}
2),e.jsx(p,{as:"span",variant:"body-sm",tone:"inherit",children:t("speedboat.pages.addresses.menu.upload_file")})]}),e.jsxs(I,{className:"gap-2.5",onSelect:()=>{v("select_new_address_option",{option:"enter_manually"}),s()},children:[e.jsx(Te,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),e.jsx(p,{as:"span",variant:"body-sm",tone:"inherit",children:t("speedboat.pages.addresses.menu.enter_manually")})]})]})]}),e.jsx("input",{ref:n,type:"file",accept:ls,className:"hidden",onChange:i})]})};function ps({addressId:s,defaultIds:r}){const{t}=C(),n=k.filter(a=>String(r[a])===s);return n.length===0?null:e.jsx("div",{className:"flex flex-wrap gap-1",children:n.map(a=>e.jsx(Xe,{variant:"secondary",children:t(`speedboat.pages.addresses.defaults.${a}`)},a))})}const R=12,us=3,ms={primary:null,shipping:null,billing:null};function sa(){const{t:s}=C(),[r,t]=g.useState(""),[n,a]=g.useState(1),[i,l]=g.useState(!1),{rolePermissions:u}=re(),h=Je(),S=Ne(r.trim()),f=S.length>=us?S:void 0;g.useEffect(()=>{f&&v("search_addresses",{keyword_length:f.length})},[f]);const{data:x,isError:_,isFetching:A,isLoading:c,refetch:D}=Ee({page:n,perPage:R,keyword:f}),E=Pe().data?.mappingIds??ms,y=x?.addresses??[],N=x?.meta.offset??(n-1)*R,P=x?.meta.total??0,b=!!f,o=Ae(h),j=P>=o,m=!!u.manageCompanyAddresses;g.useEffect(()=>{!c&&!_&&y.length===0&&n>1&&a(d=>d-1)},[y.length,_,c,n]);const Z=g.useMemo(()=>[{accessorKey:"name",header:()=>s("speedboat.pages.addresses.columns.name"),cell:({row:d})=>e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(p,{variant:"body",weight:"medium",truncate:!0,children:d.original.name}),e.jsx(ps,{addressId:d.original.id,defaultIds:E})]}),enableSorting:!1},{id:"address",header:()=>s("speedboat.pages.addresses.columns.address"),cell:({row:d})=>e.jsx(p,{variant:"body",tone:"muted",truncate:!0,children:[d.original.line1,d.original.line2].filter(Boolean).join(", ")}),enableSorting:!1},{accessorKey:"city",header:()=>s("speedboat.pages.addresses.columns.city"),cell:({row:d})=>e.jsx(p,{variant:"body",tone:"muted",truncate:!0,children:d.original.city}),enableSorting:!1},{id:"region",header:()=>s("speedboat.pages.addresses.columns.region"),cell:({row:d})=>e.jsx(p,{variant:"body",tone:"muted",truncate:!0,children:[d.original.state,d.original.zipCode].filter(Boolean).join(" ")}),enableSorting:!1},{accessorKey:"country",header:()=>s("speedboat.pages.addresses.columns.country"),cell:({row:d})=>e.jsx(p,{variant:"body",tone:"muted",truncate:!0,children:d.original.country}),enableSorting:!1},{id:"actions",header:()=>null,cell:({row:d})=>m?e.jsx(ds,{address:d.original,defaultIds:E}):null,enableSorting:!1}],[E,m]),J=d=>{t(d),a(1)},Q=e.jsx(cs,{disabled:j,onEnterManually:()=>l(!0)}),W=e.jsx(ge,{children:e.jsxs(he,{children:[e.jsx(fe,{asChild:!0,children:e.jsx("span",{className:"block",children:Q})}),e.jsx(xe,{children:s("speedboat.pages.addresses.max_limit_tooltip",{limit:o})})]})}),ee=j?W:Q;return e.jsxs(me,{children:[e.jsx(ue,{title:s("speedboat.pages.addresses.title"),subtitle:s("speedboat.pages.addresses.description"),actions:m?ee:void 0}),e.jsxs("label",{htmlFor:"addresses-search",className:"w-full shrink-0 lg:w-80",children:[e.jsx("span",{className:"sr-only",children:s("speedboat.pages.addresses.search_label")}),e.jsxs(de,{className:"h-10",children:[e.jsx(le,{align:"inline-start",children:e.jsx(Re,{className:"size-4 text-muted-foreground","aria-hidden":"true"})}),e.jsx(ce,{id:"addresses-search",value:r,onChange:d=>J(d.target.value),placeholder:s("speedboat.pages.addresses.search_placeholder")})]})]}),c&&e.jsx(F,{kind:"loading",loadingLabel:s("speedboat.pages.addresses.loading")}),!c&&_&&e.jsx(F,{kind:"error",title:s("speedboat.pages.addresses.error.title"),description:s("speedboat.pages.addresses.error.description"),retryLabel:s("speedboat.pages.addresses.error.retry"),onRetry:()=>D()}),!c&&!_&&y.length===0&&e.jsx(F,{kind:"empty",title:s(b?"speedboat.pages.addresses.empty_search.title":"speedboat.pages.addresses.empty.title"),description:s(b?"speedboat.pages.addresses.empty_search.description":"speedboat.pages.addresses.empty.description")}),!c&&!_&&y.length>0&&e.jsx("div",{className:oe("flex flex-col gap-3",A&&"opacity-60"),children:e.jsx(ie,{c
2olumns:Z,data:y,getRowId:d=>d.id,pageSize:R,emptyMessage:s("speedboat.pages.addresses.empty.title"),tableClassName:"[&_th:last-child]:w-14",renderPagination:()=>e.jsx(pe,{page:n,hasPrev:x?.meta.hasPrev??!1,hasNext:x?.meta.hasNext??!1,rangeStart:y.length?N+1:0,rangeEnd:N+y.length,onPageChange:a,rangeEmptyLabel:s("speedboat.pages.addresses.pagination.range_empty")})})}),i&&e.jsx(X,{open:!0,onOpenChange:l,defaultIds:E})]})}export{sa as default};
3//# sourceMappingURL=speedboat_addresses-HD1a12T1_bundle.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.