PageSourceSearch

https://mouthly.ai/assets/CustomersList-7rUL__w1.js

js mouthly.ai collected 2026-10-05 15:40:33 UTC 11,518 bytes, 1 lines download raw bytes

1import{e7 as Ce,r as $,an as Y,da as he,w as e,R as X,bL as J,db as ce,k8 as xe,bh as le,k9 as pe,ka as ge,kb as je,kc as be,aT as I,bm as Z,bn as ee,bK as Q,$ as g,bt as T,b2 as m,bc as d,e as E,bM as v,dd as _,bH as f,bD as D,cd as Se,de as _e,c0 as fe,ba as l,bS as De,bT as Ee,b9 as ne,M as Te,m as k,e3 as y,by as q,c as W,bp as K,b1 as ke,e6 as ye,l as we,c9 as Re,df as ve,ch as Ie,ci as Ae,dh as Be,cb as ae}from"./index-JpHfX16J.js";import{u as Le,d as Me,e as Ne,f as ze}from"./queries-D776_hOP.js";import{g as Oe,a as Pe}from"./queries-CSwdW2cG.js";import{u as Fe,a as He,A as Ue,D as Ve}from"./DashboardFilterButton-BJKips_X.js";import{D as Ge}from"./DashboardInsider-ASfvLRU2.js";import{u as Qe,B as We}from"./BulkDeleteDialogContent-B7ONcwOX.js";import{p as Ke}from"./selectors-Cg-z7QBH.js";import{D as ie}from"./DashboardActionsBar-DRHL7a5y.js";import{D as Xe}from"./index-BxQ4V1a9.js";import{D as qe}from"./DashboardActionViewsList-sRNL2kf9.js";import{u as $e}from"./use-export-pdf-CxKUDvPE.js";import{e as Ye,M as re,w as Je}from"./PrivatePages-8SBLmY5l.js";import{A as Ze}from"./AvatarCell-DO3bbj_u.js";import{M as et}from"./Money-DT5gfj6T.js";import{E as tt}from"./EmptyStatus-CzQPFFP5.js";import{D as st}from"./DashboardContentTable-BtSHkXlZ.js";import{T as ot}from"./tables-DN8i38Ws.js";import{D as nt}from"./DashboardPageContent-DCEOarDX.js";import"./query-keys-D0dkjJTf.js";import"./query-keys-DdB80Xs6.js";import"./useAutofocus-BzqLfGfZ.js";import"./useDateInputFormatter-CoAxChmU.js";import"./divider-O6HPkTFd.js";import"./withDrawers-tFlMrxgM.js";import"./useDownloadFile-CmUvN5QL.js";import"./queries-C4WaFV-2.js";import"./popover2-Czd3btii.js";import"./index-CZLfpDLB.js";import"./InputGroup-dHc3hQxa.js";import"./Row-Bf6ZTc6x.js";import"./queries-BxAGMkPV.js";const at=t=>({...Ce(t),inactive_mode:t.inactiveMode}),ue=$.createContext(void 0);function it({tableState:t,tableStateChanged:s,children:a}){const u=at(t),{data:i}=Oe(),{data:c,isLoading:r}=Fe("customers"),{data:C,isLoading:j,isFetching:b}=He("customers"),{data:o,isLoading:h,isFetching:x}=Le(u),w=Y.isEmpty(o==null?void 0:o.data)&&!h&&!s,S={customersViews:c,customers:o==null?void 0:o.data,pagination:o==null?void 0:o.pagination,fields:C!=null&&C.fields?he(C.fields):[],resourceMeta:C,isResourceMetaLoading:j,isResourceMetaFetching:b,isViewsLoading:r,isCustomersLoading:h,isCustomersFetching:x,isEmptyStatus:w,customersSettings:i};return e.jsx(Ge,{loading:r||j,name:"customers-list",children:e.jsx(ue.Provider,{value:S,children:a})})}const de=()=>{const t=X.useContext(ue);if(!t)throw new Error("useCustomersListContext must be used within a CustomersListProvider");return t},rt=()=>{const t=Me();return Qe(J.CustomerBulkDelete,t)},me=t=>t.customers.tableState,ct=()=>ce(Ke,me,(t,s)=>({...t,...s})),lt=()=>ce(me,t=>!Y.isEqual(t,xe)),te=t=>{const s=ct(),a=lt(),u=(i,c)=>{const r={customersSelectedRows:i.customers.selectedRows,customersTableState:s(i,c),customersTableStateChanged:a(i)};return t?t(r,i,c):r};return function(c){return le(u)(c)}},ut=t=>({type:pe,payload:{queries:t}}),dt=()=>({type:ge}),mt=t=>({type:je,payload:t}),Ct=()=>({type:be}),ht=t=>({setCustomersTableState:s=>t(ut(s)),resetCustomersTableState:()=>t(dt()),setCustomersSelectedRows:s=>t(mt(s)),resetCustomersSelectedRows:()=>t(Ct())});function A(t){return le(null,ht)(t)}function xt({customersSelectedRows:t=[],customersFilterConditions:s,setCustomersTableState:a,customersInactiveMode:u,openDialog:i}){const{mutateAsync:c}=Pe(),r=rt(),{openBulkDeleteDialog:C}=r,j=r.isValidatingBulkDeleteCustomers,b=ee(),{customersViews:o,fields:h,customersSettings:x}=de(),w=x==null?void 0:x.tableSize,{refresh:S}=Ne(),{downloadAsync:B}=$e(),L=()=>{b.push("/customers/new")},M=()=>{C(t)},N=p=>{a({viewSlug:p?p.slug:null})},z=p=>{const V=p.target.checked;a({inactiveMode:V})},O=()=>{S()},P=p=>{c({options:[{group:"customers",key:"tableSize",value:p}]})},F=()=>{b.push("/customers/import")},H=()=>{i(J.Export,{resource:"customer"})},U=()=>{B({resource:"Customer"})};return Y.isEmpty(t)?e.jsxs(ie,{children:[e.jsxs(Q,{children:[e.jsx(qe,{resourceName:"customers",views:o,allMenuItem:!0,allMenuItemText:e.jsx(d,{id:"all"}),onChange:N}),e.jsx(v,{}),e.jsxs(_,{I:f.Create,a:D.Customer,children:[e.jsx(g,{className:T,icon:e.jsx(m,{icon:"plus"}),text:e.jsx(d,{id:"new_customer"}),onClick:L}),e.jsx(v,{})]}),e.jsx(Ue,{advancedFilterProps:{conditions:s,defaultFieldKey:"display_name",fields:h,onFilterChange:p=>{a({filterRoles:p})}},children:e.jsx(Ve,{conditionsCount:s.length})}),e.jsx(g,{className:T,icon:e.jsx(m,{icon:"print-16",iconSize:16}),text:e.jsx(d,{id:"print"}),onClick:U}),e.jsx(g,{className:T,icon:e.jsx(m,{icon:"file-import-16",iconSize:16}),onClick:F,text:e.jsx(d,{id:"import"})}),e.jsx(g,{className:T,icon:e.jsx(m,{icon:"file-export-16",iconSize:16}),text:e.jsx(d,{id:"export"}),onClick:H}),e.jsx(v,{}),e.jsx(Xe,{initialValue:w,onChange:P}),e.jsx(v,{}),e.jsx(_,{I:f.Edit,a:D.Customer,children:e.jsx(Se,{labelElement:e.jsx(d,{id:"inactive"}),defaultChecked:u,onChange:z})})]}),e.jsx(Q,{align:_e.RIGHT,children:e.jsx(g,{className:T,icon:e.jsx(m,{icon:"refresh-16",iconSize:14}),onClick:O})})]}):e.jsx(ie,{children:e.jsx(Q,{children:e.jsx(g,{className:T,icon:e.jsx(m,{icon:"trash-16",iconSize:16}),text:e.jsx(d,{id:"delete"}),intent:E.DANGER,onClick:M,disabled:j})})})}const pt=I(xt,Z,te(({customersSelectedRows:t,customersTableState:s})=>({customersSelectedRows:t,customersInactiveMode:s.inactiveMode,customersFilterConditions:s.filterRoles})),A);function gt({dialogName:t,isOpen:s,payload:a,resetCustomersSelectedRows:u,closeDialog:i}){const{ids:c=[],deletableCount:r=0,undeletableCount:C=0,totalSelected:j=c.length}=a,{mutateAsync:b,isPending:o}=ze(),h=()=>{i(t)},x=()=>{b({ids:c,skipUndeletable:!0}).then(()=>{ne.show({message:l.get("the_customers_has_been_deleted_successfully"),intent:E.SUCCESS}),u(),i(t)}
1).catch(()=>{ne.show({message:l.get("something_went_wrong"),intent:E.DANGER})})};return e.jsxs(fe,{title:e.jsx(d,{id:"bulk_delete_dialog_title",values:{resourcePlural:l.get("resource_customer_plural")}}),isOpen:s,onClose:h,canEscapeKeyClose:!o,canOutsideClickClose:!o,children:[e.jsx(We,{totalSelected:j,deletableCount:r,undeletableCount:C,resourceSingularLabel:l.get("resource_customer_singular"),resourcePluralLabel:l.get("resource_customer_plural")}),e.jsx("div",{className:De,children:e.jsxs("div",{className:Ee,children:[e.jsx(g,{onClick:h,disabled:o,children:e.jsx(d,{id:"cancel"})}),e.jsx(g,{intent:E.DANGER,onClick:x,loading:o,disabled:r===0||o,children:e.jsx(d,{id:"delete_count",values:{count:r}})})]})})]})}const jt=I(gt,A,Z,Ye());function bt(){return e.jsx(e.Fragment,{children:e.jsx(jt,{dialogName:J.CustomerBulkDelete})})}function St({row:{original:t},payload:{onEdit:s,onDelete:a,onDuplicate:u,onInactivate:i,onActivate:c,onViewDetails:r}}){return e.jsxs(Te,{children:[e.jsx(k,{icon:e.jsx(m,{icon:"reader-18"}),text:l.get("view_details"),onClick:y(r,t)}),e.jsxs(_,{I:f.Edit,a:D.Customer,children:[e.jsx(re,{}),e.jsx(k,{icon:e.jsx(m,{icon:"pen-18"}),text:l.get("edit_customer"),onClick:y(s,t)})]}),e.jsx(_,{I:f.Create,a:D.Customer,children:e.jsx(k,{icon:e.jsx(m,{icon:"content-copy",iconSize:16}),text:l.get("duplicate"),onClick:y(u,t)})}),e.jsxs(_,{I:f.Edit,a:D.Customer,children:[e.jsx(q,{condition:t.active,children:e.jsx(k,{text:l.get("inactivate_customer"),icon:e.jsx(m,{icon:"pause-16",iconSize:16}),onClick:y(i,t)})}),e.jsx(q,{condition:!t.active,children:e.jsx(k,{text:l.get("activate_customer"),icon:e.jsx(m,{icon:"play-16",iconSize:16}),onClick:y(c,t)})})]}),e.jsxs(_,{I:f.Delete,a:D.Customer,children:[e.jsx(re,{}),e.jsx(k,{icon:e.jsx(m,{icon:"trash-16",iconSize:16}),text:l.get("delete_customer"),intent:E.DANGER,onClick:y(a,t)})]})]})}function _t(t){return e.jsx("div",{className:"work_phone",children:t.personalPhone})}function ft(t){return e.jsx(et,{amount:t.closingBalance,currency:t.currencyCode})}function Dt(t){return e.jsx(q,{condition:!!t.note,children:e.jsx(ke,{className:ye,content:t.note,position:we.LEFT_TOP,hoverOpenDelay:50,children:e.jsx(m,{icon:"file-alt",iconSize:16})})})}function Et(){return $.useMemo(()=>[{id:"avatar",Header:"",Cell:Ze,className:"avatar",width:45,disableResizing:!0,disableSortBy:!0,clickable:!0},{id:"display_name",Header:l.get("display_name"),accessor:"displayName",className:"display_name",width:150,clickable:!0},{id:"company_name",Header:l.get("company_name"),accessor:"companyName",className:W("company_name",K.TEXT_MUTED),width:150,clickable:!0},{id:"work_phone",Header:l.get("phone_number"),accessor:_t,width:100,clickable:!0,className:W("phone_number",K.TEXT_MUTED)},{id:"note",Header:l.get("note"),accessor:Dt,disableSortBy:!0,width:85,clickable:!0,className:W(K.TEXT_MUTED)},{id:"balance",Header:l.get("receivable_balance"),accessor:ft,align:"right",width:100,clickable:!0,money:!0}],[])}function Tt(){const t=ee();return e.jsx(tt,{title:e.jsx(d,{id:"create_and_manage_your_organization_s_customers"}),description:e.jsx("p",{children:e.jsx(d,{id:"here_a_list_of_your_organization_products_and_services"})}),action:e.jsx(e.Fragment,{children:e.jsxs(_,{I:f.Create,a:D.Customer,children:[e.jsx(g,{intent:E.PRIMARY,large:!0,onClick:()=>{t.push("/customers/new")},children:e.jsx(d,{id:"new_customer"})}),e.jsx(g,{intent:E.NONE,large:!0,children:e.jsx(d,{id:"learn_more"})})]})})})}function kt({setCustomersTableState:t,setCustomersSelectedRows:s,customersTableState:a,customersSelectedRows:u,openAlert:i,openDrawer:c,openDialog:r}){var se,oe;const C=ee(),j=Et(),{isEmptyStatus:b,customers:o,pagination:h,isCustomersLoading:x,isCustomersFetching:w,customersSettings:S}=de(),B=S==null?void 0:S.tableSize,[L,,M]=ve(ot.CUSTOMER),N=X.useCallback(({pageSize:n,pageIndex:R,sortBy:G})=>{t({pageIndex:R,pageSize:n,sortBy:G})},[t]),z=X.useCallback(n=>{const R=(n==null?void 0:n.map(G=>G.original.id))||[];s(R)},[s]),O=({id:n})=>{i("customer-delete",{contactId:n})},P=n=>{C.push("/customers/".concat(n.id,"/edit"))},F=({id:n})=>{r("contact-duplicate",{contactId:n})},H=({id:n})=>{i("customer-inactivate",{customerId:n})},U=({id:n})=>{i("customer-activate",{customerId:n})},p=({id:n})=>{c(ae.CUSTOMER_DETAILS,{customerId:n})},V=(n,R)=>{c(ae.CUSTOMER_DETAILS,{customerId:n.row.original.id})};return b?e.jsx(Tt,{}):e.jsx(st,{children:e.jsx(Ie,{noInitialFetch:!0,columns:j,data:o!=null?o:[],loading:x,headerLoading:x,progressBarLoading:w,onFetchData:N,selectionColumn:!0,expandable:!1,sticky:!0,spinnerProps:{size:30},pagination:!0,rowTestId:"customer-row",initialPageSize:(se=a==null?void 0:a.pageSize)!=null?se:10,manualSortBy:!0,manualPagination:!0,rowsCount:(oe=h==null?void 0:h.total)!=null?oe:0,onSelectedRowsChange:z,selectedRowsIds:u,autoResetSelectedRows:!1,autoResetSortBy:!1,autoResetPage:!1,TableLoadingRenderer:Ae,TableHeaderSkeletonRenderer:Be,onCellClick:V,initialColumnsWidths:L,onColumnResizing:M,size:B,payload:{onDelete:O,onEdit:P,onDuplicate:F,onInactivate:H,onActivate:U,onViewDetails:p},ContextMenu:St})})}const yt=I(kt,te(({customersTableState:t,customersSelectedRows:s})=>({customersTableState:t,customersSelectedRows:s})),Re,A,Z,Je);function wt({customersTableState:t,customersTableStateChanged:s,resetCustomersTableState:a,resetCustomersSelectedRows:u}){return $.useEffect(()=>()=>{a(),u()},[u,a]),e.jsxs(it,{tableState:t,tableStateChanged:s,children:[e.jsx(pt,{}),e.jsx(bt,{}),e.jsx(nt,{children:e.jsx(yt,{})})]})}const is=I(wt,A,te(({customersTableState:t,customersTableStateChanged:s})=>({customersTableState:t,customersTableStateChanged:s})));export{is as CustomersList};

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.