PageSourceSearch

https://app.withvayu.com/assets/ProductsPage-2eaf5c82.js

js withvayu.com collected 2026-10-03 19:31:26 UTC 17,110 bytes, 1 lines download raw bytes

1import{q as pe,j as e,aR as Q,aN as he,r as S,n as ge,o as A,p as Y,L as me}from"./vendor-react-2cb5d109.js";import{a as Ce,ae as M,fx as xe,df as _,fy as k,d as ne,ec as fe,bb as W,fz as ye,fA as De,fB as Ee,bg as b,p as Te,r as re,fC as Pe,fD as Se,b_ as be,cP as te}from"./vendor-vy-bde48d53.js";import{l as je,aM as Me,g as Ie,H as ve}from"./vendor-misc-09f7f1da.js";import{V as Re}from"./VyLayout-20044627.js";import{P as Ae}from"./page-frame-c2a7254f.js";import{e as U,p as $,q as Oe,n as V,w as K,u as we,V as F,h as E,_ as L,b8 as Ne,aV as T,Z as H,z as ke,c3 as Fe,M as Be,k as _e}from"./app-core-47ba8b05.js";import{a as Ve}from"./use-table-pagination-2ef45298.js";import{u as ie}from"./use-search-with-search-params-e26dc43c.js";import{u as ze}from"./use-state-params-e6f24508.js";import{E as We}from"./edit-catalog-product-param-47b34885.js";import{u as Ue}from"./use-catalog-products-list-c0194d38.js";import{N as Le,Q as Ge,c as qe,X as Qe,A as Ye,S as $e,u as Ke}from"./build-erp-entity-from-external-integration-c2233303.js";import{N as He,U as X}from"./UpsertCatalogProductsDialog-137266f3.js";import{u as Xe}from"./use-sync-query-param-to-state-995010ee.js";import{u as Ze}from"./use-debounce-9c73162a.js";import{u as Je}from"./use-table-columns-manager-476ce6ee.js";import{u as et}from"./use-stripe-tax-enabled-f180c173.js";import{N as tt}from"./NetSuiteProductsDropdown-9e8092ec.js";import{S as N,B as le,o as ce,T as q,I as Z,M as J,p as I,L as v,a9 as R,q as at,u as st}from"./vendor-mui-c34240eb.js";import{e as ae,V as y,o as ot,bA as nt,c as se,a5 as rt,ao as it,ay as oe,a0 as lt}from"./vendor-vy-ds-da93fbfd.js";import{U as de}from"./UpsertCreditTypeDialog-68370c7a.js";import{u as ee}from"./use-menu-fcf82705.js";import{u as ue}from"./use-toggle-783e3c5d.js";import"./use-account-f5081143.js";import"./reference-data-query-options-consts-650f2d3a.js";import"./use-subsidiaries-8dc9e8d5.js";import"./use-descope-sdk-5ae34fa9.js";import"./breadcrumbs-context-0c78adb5.js";import"./breadcrumb-routes-44c27586.js";import"./app-router-b196f9b3.js";import"./AiCopilotProvider-549ad299.js";import"./use-jobs-a8040d6f.js";import"./VyPageLayoutTabs-bb33aa5c.js";import"./use-page-param-6119b40d.js";import"./use-effect-once-07b631b8.js";import"./use-net-suite-classes-75dcbd11.js";import"./use-subsidiary-name-map-1b4f6602.js";import"./use-formatted-xero-products-59612754.js";import"./use-paddle-products-e49d99db.js";import"./use-integration-settings-73f65532.js";import"./use-net-suite-products-fd048f9c.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"a44d049e7c59"};var a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="3d245461-f089-493c-aeba-5cf36761dcda",t._sentryDebugIdIdentifier="sentry-dbid-3d245461-f089-493c-aeba-5cf36761dcda")}catch{}})();function ct(t={},a){return pe(Oe.productsPage(...Object.values(t)),async()=>{const o=await U().getProductsPageData({search:Ce(t.search)?void 0:t.search,pageSize:M(t.pageSize,100),page:M(t.page,0)});return $(xe,o)},{...a})}function dt(){return ze("",We,t=>t,t=>t)}const ut=({control:t,errors:a,nameRegister:s,descriptionRegister:o})=>{var l;const n=V(_.NETSUITE),c=V(_.QUICKBOOKS),i=V(_.XERO),r=V(_.ANROK),p=et(),h=(l=je.get(a,s.name))==null?void 0:l.message;return e.jsxs(N,{spacing:3,children:[e.jsx(ae,{label:"Product name","data-vy":k.createDialogNameInput,placeholder:"Enter product name",...s,error:ne(h),helperText:h}),e.jsx(ae,{label:"Description","data-vy":k.createDialogDescriptionInput,placeholder:"Enter a description of what this product includes",...o}),n&&e.jsxs(e.Fragment,{children:[e.jsx(tt,{fieldPath:"netSuiteProduct",control:t,showDropdown:!0,placeholder:"Select NetSuite product"}),e.jsx(Le,{control:t})]}),c&&e.jsxs(e.Fragment,{children:[e.jsx(Ge,{control:t}),e.jsx(qe,{control:t})]}),i&&e.jsx(Qe,{control:t}),r&&e.jsx(Ye,{control:t}),p&&e.jsx($e,{control:t})]})},pt=({openCreateProductDialog:t,onClose:a,onProductCreated:s,navigateBack:o})=>{const n=we(),{control:c,handleSubmit:i,register:r,formState:{errors:p,isValid:h}}=Me({resolver:Ie(He)}),l=i(f=>{s&&s(f.name),n("/products/create",{replace:!0,state:{...f,aggregationMethod:{operator:fe.Count}}}),x()}),d=r("name"),C=r("description"),x=()=>{a()};return e.jsx(F,{open:t,onClose:x,label:"Metered product",ctaText:"Go to product builder",ctaDisabled:!h||!E([W.METER_CREATE]),cancelButtonText:"Cancel",disableDividers:!0,onSubmit:l,maxWidth:"md",navigateBack:o??x,children:e.jsx(le,{component:"form",onSubmit:l,sx:{mb:4},children:e.jsx(ut,{control:c,errors:p,nameRegister:d,descriptionRegister:C}
1)})})},ht=K(pt,{variant:"compact"}),g=Object.freeze({METERED:"Metered",SERVICE:"Service",CREDIT:"Credit"});ye.extend({type:Q(g.SERVICE)});De.extend({type:Q(g.METERED)});Ee.extend({type:Q(g.CREDIT),isDeletable:he()});const G=({title:t,description:a,icon:s,iconBackgroundColor:o="#B0D2FF",selected:n,onClick:c,titleSx:i,descriptionSx:r,"data-vy":p})=>e.jsx(ce,{elevation:0,role:"radio",tabIndex:0,"data-vy":p,sx:{flex:1,padding:3,border:n?"1px solid #5EA3EF":"1px solid #E8EBF2",borderRadius:"8px",cursor:"pointer",backgroundColor:n?"#E7F2FF":"white",transition:"all 0.2s ease-in-out","&:hover":{borderColor:"#5EA3EF",backgroundColor:"#E7F2FF"}},onClick:c,children:e.jsxs(N,{spacing:2,sx:{alignItems:"center",textAlign:"center"},children:[s&&e.jsx(N,{sx:{width:48,height:48,borderRadius:"50%",backgroundColor:o,display:"flex",alignItems:"center",justifyContent:"center"},children:s}),e.jsxs(N,{spacing:.5,sx:{alignItems:"center",textAlign:"center"},children:[e.jsx(q,{variant:"h6",sx:[{fontFamily:"Inter, sans-serif",fontWeight:400},...Array.isArray(i)?i:[i]],children:t}),e.jsx(q,{variant:"body2",sx:[{color:"text.secondary",lineHeight:1.5},...Array.isArray(r)?r:[r]],children:a})]})]})}),gt=({selectedProductType:t,handleProductTypeSelection:a})=>{const s=t===g.METERED,o=t===g.SERVICE,n=t===g.CREDIT;return e.jsxs(N,{direction:"row",spacing:2,role:"radiogroup","aria-label":"Product type",children:[E([W.METER_CREATE])&&e.jsx(G,{"data-vy":k.createMeteredOption,title:"Metered product",titleSx:{fontSize:"14px !important",fontWeight:600},description:"Charge based on customer usage, like API calls or data volume.",descriptionSx:{fontWeight:"12px"},icon:e.jsx(y,{icon:"BusinessChart"}),iconBackgroundColor:"#B0D2FF",selected:s,onClick:()=>a(g.METERED)}),E([b.createCatalogProducts])&&e.jsx(G,{title:"Standard or service product",titleSx:{fontSize:"14px !important",fontWeight:600},description:"Define new Services and products with fixed fees.",descriptionSx:{fontWeight:"12px"},icon:e.jsx(y,{icon:"DataStorage"}),iconBackgroundColor:"#B0D2FF",selected:o,onClick:()=>a(g.SERVICE)}),E([b.createCreditType])&&e.jsx(G,{title:"Credit product",titleSx:{fontSize:"14px !important",fontWeight:600},description:"Prepaid credits applied to usage within a contract",descriptionSx:{fontWeight:"12px"},icon:e.jsx(y,{icon:"MoneyBanknotes"}),iconBackgroundColor:"#B0D2FF",selected:n,onClick:()=>a(g.CREDIT)})]})},mt=({children:t})=>{const[a,s]=S.useState(null),[o,n]=S.useState(!1),[c,i]=S.useState(!1),[r,p]=S.useState(!1),{isDialogOpen:h,handleOpen:l,handleClose:d}=L(),x=h&&!o&&!c&&!r,f=()=>{s(null),n(!1),i(!1),p(!1)},m=()=>{f(),d()},D=B=>{s(B)},u=()=>{switch(Te(a,"Selected product type is required"),a){case g.METERED:n(!0);break;case g.SERVICE:i(!0);break;case g.CREDIT:p(!0);break;default:re(a)}},P=()=>{m()},O=()=>{m()},j=B=>{m()},w=()=>{n(!1),i(!1),p(!1),s(null)};return e.jsxs(e.Fragment,{children:[t&&ge.cloneElement(t,{onClick:l}),e.jsx(F,{open:x,onClose:m,label:"Create new product",labelDescription:"Define a new metered or standard product",ctaText:"Next",ctaDisabled:!a,cancelButtonText:"Cancel",onSubmit:u,maxWidth:"md",disableDividers:!0,children:e.jsx(gt,{selectedProductType:a,handleProductTypeSelection:D})}),o&&e.jsx(ht,{openCreateProductDialog:o,onClose:P,onProductCreated:j,navigateBack:w}),c&&e.jsx(X,{openCreateProductDialog:c,onClose:O,onProductCreated:j,onBackToMain:w}),r&&e.jsx(de,{openCreateProductDialog:r,onClose:m,onProductCreated:j,onBackToMain:w})]})},Ct=K(mt,{variant:"compact"});function xt(t){const a=A();return Y({mutationFn:async({meterId:s})=>{const n=await U().deleteMeter({meterId:s});return $(Pe,n)},onSuccess:async()=>{await Promise.all([Ne(a),T(a)])},...t})}const ft=({meterId:t,row:a,disableDelete:s,meterName:o})=>{const{isDialogOpen:n,handleOpen:c,handleClose:i}=L(),{anchorElement:r,isOpen:p,handleMenuOpen:h,handleMenuClose:l}=ee(),d=E([W.METER_UPDATE]),C=E([b.deleteMeter]),x=A(),f=xt({onSuccess:()=>T(x)}),m=u=>{l(),u==null||u()},D=async()=>{await H(f,{meterId:t},{pending:"Deleting meter...",success:"Meter successfully deleted",error:"Failed to delete meter"})};return!d&&!C?null:e.jsxs("div",{children:[e.jsx(F,{open:n,onClose:i,label:`Delete ${o}?`,ctaText:"Yes, delete",cancelButtonText:"Cancel",onSubmit:D,ctaButtonProps:{color:"error"},dialogContentProps:{style:{maxWidth:"569px",minWidth:"569px"}},children:e.jsx(q,{variant:"body1",children:"Are you sure you want to delete this metered product? This action is final and cannot be reversed."})}),e.jsx(Z,{size:"medium",onClick:h,disabled:!1,children:e.jsx(y,{icon:"DotsMenu",style:{transform:"rotate(90deg)"}})}),e.jsxs(J,{anchorEl:r,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},open:p,onClose:l,children:[d&&e.jsx(me,{to:`/products/${t}/edit`,state:a,children:e.jsxs(I,{children:[e.jsx(v,{children:e.jsx(y,{icon:"Edit",style:{transform:"scale(0.8)"}})}),e.jsx(R,{children:" Edit"})]})}),C&&e.jsxs(I,{onClick:()=>m(c),disabled:s,children:[e.jsx(v,{children:e.jsx(y,{icon:"Delete",style:{transform:"scale(0.8)"}})}),e.jsx(R,{children:"Delete"})]})]})]})};function yt(t){const a=A();return Y({mutationFn:async({catalogProductId:s})=>
1{const n=await U().deleteCatalogProducts({catalogProductId:s});return $(Se,n)},onSuccess:async()=>{await T(a)},...t})}const Dt=({catalogProductId:t,row:a,disableDelete:s,catalogProductName:o})=>{const{isDialogOpen:n,handleOpen:c,handleClose:i}=L(),{anchorElement:r,isOpen:p,handleMenuOpen:h,handleMenuClose:l}=ee(),[d,C]=ue(!1),x=E([b.updateCatalogProducts]),f=E([b.deleteCatalogProducts]),m=A(),D=yt({onSuccess:()=>T(m)}),u=()=>{l(),C()},P=()=>{C()},O=()=>{l(),c()},j=async()=>{await H(D,{catalogProductId:t},{pending:"Deleting catalog product...",success:"Catalog product successfully deleted",error:"Failed to delete catalog product"},{onSuccess:async()=>{await T(m)}})};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:n,onClose:i,label:`Delete ${o}`,labelDescription:"Are you sure you want to delete this product?",ctaText:"Delete",warningText:"This action is final and cannot be reversed",cancelButtonText:"Cancel",onSubmit:j,disableDividers:!0}),d&&e.jsx(X,{openCreateProductDialog:d,onClose:P,editProduct:a}),e.jsx(Z,{size:"medium",onClick:h,children:e.jsx(y,{icon:"DotsMenu",style:{transform:"rotate(90deg)"}})}),e.jsxs(J,{anchorEl:r,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},open:p,onClose:l,children:[e.jsxs(I,{onClick:u,disabled:!x,children:[e.jsx(v,{children:e.jsx(y,{icon:"Edit",style:{transform:"scale(0.8)"}})}),e.jsx(R,{children:"Edit"})]}),e.jsxs(I,{onClick:O,disabled:s||!f,children:[e.jsx(v,{children:e.jsx(y,{icon:"Delete",style:{transform:"scale(0.8)"}})}),e.jsx(R,{children:"Delete"})]})]})]})};function Et(t){const a=A();return Y({mutationFn:async({creditTypeId:s})=>await U().deleteCreditType({creditTypeId:s}),onSuccess:async()=>{await T(a)},...t})}const Tt=({creditTypeId:t,row:a,disableDelete:s,creditTypeName:o})=>{const{isDialogOpen:n,handleOpen:c,handleClose:i}=L(),{anchorElement:r,isOpen:p,handleMenuOpen:h,handleMenuClose:l}=ee(),[d,C]=ue(!1),x=A(),f=Et({onSuccess:()=>T(x)}),m=()=>{l(),C()},D=()=>{C()},u=()=>{l(),c()},P=async()=>{await H(f,{creditTypeId:t},{pending:"Deleting credit product...",success:"Credit product successfully deleted",error:"Failed to delete credit product"},{onSuccess:async()=>{await T(x)}})};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:n,onClose:i,label:`Delete ${o}`,labelDescription:"Are you sure you want to delete this product?",ctaText:"Delete",warningText:"This action is final and cannot be reversed",cancelButtonText:"Cancel",onSubmit:P,disableDividers:!0}),e.jsx(de,{openCreateProductDialog:d,onClose:D,editCreditType:a}),e.jsx(Z,{size:"medium",onClick:h,"data-vy":"credit-types-table-actions-edit",children:e.jsx(y,{icon:"DotsMenu",style:{transform:"rotate(90deg)"}})}),e.jsxs(J,{anchorEl:r,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},open:p,onClose:l,children:[e.jsxs(I,{onClick:m,"data-vy":"credit-types-table-actions-edit",children:[e.jsx(v,{children:e.jsx(y,{icon:"Edit",style:{transform:"scale(0.8)"}})}),e.jsx(R,{children:"Edit"})]}),e.jsx(at,{title:s?"This credit type is in use and cannot be deleted":"",placement:"left",children:e.jsx("span",{children:e.jsxs(I,{onClick:u,disabled:s,"data-vy":"credit-types-table-actions-delete",children:[e.jsx(v,{children:e.jsx(y,{icon:"Delete",style:{transform:"scale(0.8)"}})}),e.jsx(R,{children:"Delete"})]})})})]})]})},z=Object.freeze({NAME:"name",TYPE:"type",CREATED_AT:"createdAt",CONTRACTS:"contractsCount",ACTIONS:"actionMenu"});function Pt(t){return t.type===g.METERED}function St(t){return t.type===g.SERVICE}function bt(t){return t.type===g.CREDIT}const jt=(t,a,s)=>{const o=Mt(t),n=It(a),c=vt(s);return[...o,...n,...c].sort((i,r)=>r.createdAt.getTime()-i.createdAt.getTime())};function Mt(t){return t.map(a=>({...a,type:g.METERED}))}function It(t){return t.map(a=>({...a,type:g.SERVICE}))}function vt(t){return t.map(a=>({...a,type:g.CREDIT}))}function Rt(){return[{field:z.NAME,headerName:"Product name",flex:1,sortable:!1,headerClassName:"pl-6",cellClassName:"pl-6"},{field:z.TYPE,width:200,headerName:"Type",headerAlign:"left",align:"left",sortable:!1,headerClassName:"pr-6",cellClassName:"pr-6",valueGetter:(t,a)=>a.type},{field:z.CREATED_AT,headerName:"Created on",align:"left",sortable:!1,renderCell:({row:t})=>ke(t.createdAt)},{field:z.ACTIONS,headerName:"",sortable:!1,width:30,filterable:!1,headerClassName:"bg-white",cellClassName:"bg-white",renderCell:({row:t})=>{const a=Pt(t)?e.jsx(ft,{row:t,meterId:t.id,disableDelete:!1,meterName:t.name}):St(t)?e.jsx(Dt,{row:t,catalogProductId:t.id,disableDelete:!1,catalogProductName:t.name}):bt(t)?e.jsx(Tt,{row:t,creditTypeId:t.id,disableDelete:!t.isDeletable,creditTypeName:t.name}):re(t);return e.jsx("span",{className:"flex items-center justify-center h-full",children:a})}}]}const At=[10,25,50,100,500],Ot=({items:t,itemsCount:a,loadingItems:s,page:o,pageSize:n,onPageChange:c,onPageSizeChange:i})=>{const r=st(),[p,h]=ie(),[l,d]=S.useState(p??""),C=Ze(l);S.useEffect(()=>{h(C)},[C]),Xe(p,d);const x=S.useMemo(()=>Rt(),[]),{processedColumns:f}=Je({apiRef:r,columns:x,tableName:"products"}),m=u=>{if(u.pageSize!==n){i(u.pageSize),c(0);return}u.page!==o&&c(u.page)},D=()=>e.jsx(nt,{children:e.jsxs(se,{direction:"row",sx:{gap:2,alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(se,{sx:{width:300,flexShrink:0}
1,children:e.jsx(rt,{value:l,onChange:u=>d(u.target.value),onClear:()=>d(""),placeholder:"Search"})}),E([W.METER_CREATE,b.createCatalogProducts,b.createCreditType])&&e.jsx(Ct,{children:e.jsx(it,{"data-vy":k.createNewButton,variant:"cta",startIcon:e.jsx(y,{icon:"PlusMedium",width:oe,height:oe}),children:"Create New"})})]})});return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[D(),e.jsx(ce,{variant:"outlined",sx:Fe,"data-vy":k.table,children:e.jsx(ot,{apiRef:r,rows:t??[],columns:f,getRowId:u=>`${u.type}-${u.id}`,loading:s,pinnedColumns:{right:["actionMenu"]},pagination:!0,paginationMode:"server",rowCount:a,paginationModel:{page:o,pageSize:n},onPaginationModelChange:m,pageSizeOptions:At,slots:{loadingOverlay:Be}})})]})},wt=(t,a)=>t.filter(s=>!a||be(s.name,a)),Nt=()=>{const[t]=ie(),[a,s]=dt(),{page:o,pageSize:n,onPageChange:c,onPageSizeChange:i}=Ve(),{data:r,isLoading:p}=Ue({suspense:!1}),{data:h,isLoading:l}=Ke({suspense:!1},{search:te(t)||void 0}),{data:d,isLoading:C}=ct({search:te(t),page:o,pageSize:n},{suspense:!1}),x=M(d==null?void 0:d.meters,[]),f=M(r==null?void 0:r.catalogProducts,[]),m=M(h==null?void 0:h.creditTypes,[]),D=wt(f,t),u=f.find(B=>B.id===a),P=jt(x,D,m),O=C||p||l,w=M(d==null?void 0:d.countedFilteredMeters,0)+D.length+m.length;return e.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsx(ve,{children:e.jsx("title",{children:"Products"})}),e.jsxs(Re,{sx:{display:"flex",flexDirection:"column",...Ae},children:[e.jsx(lt,{sx:{marginBottom:4},children:"Products catalog"}),e.jsx(le,{sx:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:e.jsx(Ot,{items:P,itemsCount:w,loadingItems:O,page:o,pageSize:n,onPageChange:c,onPageSizeChange:i})})]}),ne(u)&&e.jsx(X,{openCreateProductDialog:!0,onClose:()=>s(void 0),editProduct:u})]})},Ta=K(_e(Nt));export{Ta as ProductsPage};

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.