PageSourceSearch

https://app.coachbuilder.com/build/assets/Products-CoIzg5wY.js

js coachbuilder.com collected 2026-09-28 11:09:59 UTC 12,188 bytes, 1 lines download raw bytes

1import{e as _,r as y,a as B,y as M,j as e,c as C,I as L,u as W}from"./app-C9MmtEoK.js";import{T as $}from"./TextInput-BKSmrSQx.js";import{E as V,S as O}from"./Toasts-B_BLmkMr.js";import{u as S}from"./useBoolean-Cw3k-baa.js";import{u as Y}from"./useDebounce-Bx4iIuGz.js";import{o as Q}from"./MagnifyingGlass.es-DQm2gYgs.js";import{I as U}from"./IntegrateWithStripeBanner-B3oxqHkq.js";import{I as Z}from"./IntegrateWithStripeModal-C2JAHEXz.js";import{M as G}from"./Modal-CUVkRZhm.js";import{D as H}from"./DeleteModal-Vph2ozE8.js";import{L as I}from"./Label-CBsjIOPx.js";import{S as x}from"./SimpleDropdown-vgzV_TAq.js";import{T as J}from"./TextArea-D3S3Qvj3.js";import{p as X}from"./parseAmountToCurrency-DK2TtIkv.js";import{T as A}from"./toastHelper-C7R2HAxh.js";import{u as K,g as ee}from"./useCurrency-DxWCCttD.js";import{y as se,v as te,r as oe,A as re}from"./AuthenticatedLayout-zC4PxQms.js";import{e as ie}from"./CaretUp.es-9VzXQckX.js";import{c as ne}from"./CircleNotch.es-mzAZ_PSb.js";import{o as le}from"./DotsThree.es-yBsYdK0B.js";import{e as z}from"./Plus.es-CpxCRE0j.js";import{e as ae}from"./constants-IydEU6zQ.js";import{N as ce}from"./react-number-format.es-cOAQ7ImZ.js";import{m as q,A as de}from"./proxy-DnvNemOA.js";import"./IconBase.es-D8OykiYB.js";import"./HandWaving.es-wawK3MM8.js";import"./differenceInMinutes-B3EUkaAU.js";import"./differenceInMilliseconds-D1kKhPnl.js";import"./toDate-CSwDiQTw.js";import"./LinkSimple.es-BG9WDYxs.js";import"./transition-CBj5BI0Z.js";import"./use-server-handoff-complete-DrD4bZXU.js";import"./portal-DdphB22-.js";import"./with-selector-BEsCSSIB.js";import"./use-tab-direction-C4WCIPip.js";import"./use-inert-others-oVI5YzEZ.js";import"./User.es-DJD9_maY.js";import"./index-FSFl0VXl.js";import"./CheckBox-Da8CDJna.js";import"./SignOut.es-BN2SoA1I.js";import"./Logo-C0UBLJJa.js";import"./DotsSixVertical.es-BdjNUUyW.js";import"./Image.es-CUAngtsS.js";import"./LadderSimple.es-DXkY8pn_.js";import"./Buttons-DTRq7Vzc.js";import"./floating-ui.react-dom-DH3VvUTt.js";const me={autoClose:1e4,closeButton:!1},pe="Something went wrong on our end. We've been notified and our team is working to resolve the issue.";function ue({heading:h,dataKey:p,routeName:P,filters:m,isDisabled:f,children:T}){const l=_().props[p];if(typeof l>"u")throw new Error("The data key must correspond with an Inertia Scroll page prop key. https://inertiajs.com/docs/v3/data-props/infinite-scroll#infinite-scroll");const[w,c]=S(!1),[r,d]=y.useState(m?m[0]:null),[s,u]=y.useState(""),i=Y(s,500);y.useEffect(()=>{const n={q:i};r&&(n[r.queryKey]=r.queryValue),B.visit(route(P,{...n}),{onBefore:()=>c.on(),onError:E=>{console.log(E),c.off(),M(e.jsx(V,{copy:pe}),me)},onSuccess:()=>{c.off()},reset:[p],preserveState:!0})},[i,r]);const N=!r||r.queryKey==="",g=i==="",v=g&&N&&l.total===0&&!w,j=(!g||!N)&&l.total===0&&!w;
1return e.jsxs("div",{className:"flex flex-col gap-4 rounded-3xl bg-white p-6",children:[e.jsxs("div",{className:"mb-2 flex flex-col gap-4 md:flex-row md:items-center md:justify-between md:gap-0",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold capitalize leading-7",children:h}),m?e.jsxs("div",{className:"mt-4 flex flex-row flex-wrap items-center gap-2",children:[e.jsx("label",{className:"text-xs font-bold leading-5",children:"Filter By:"}),m.map(n=>e.jsx("button",{type:"button",className:C("rounded-sm border p-2 text-[10px] font-bold leading-[14px]",(r==null?void 0:r.queryValue)===n.queryValue&&"bg-black text-white"),onClick:()=>d(n),disabled:f,children:n.copy},n.queryValue))]}):null]}),e.jsx("div",{className:"w-full md:w-4/12",children:e.jsx($,{Icon:Q,iconPlacement:"right-2",placeholder:`Search ${p}...`,value:s,onChange:n=>u(n.target.value),disabled:f||i===""&&l.total===0})})]}),e.jsx(L,{data:p,buffer:500,preserveUrl:!0,className:"grid gap-4 lg:grid-cols-2",children:T({[p]:l.data,noResults:j,isEmpty:v})})]})}const xe="Something went wrong on our end. We've been notified and our team is working to resolve the issue.";function R({showModal:h,showModalSetters:p,currencyOptions:P,defaultCurrency:m,defaultFormData:f,productId:T,isCreating:k,onClose:l,isConnected:w}){const{data:c,setData:r,errors:d,setError:s,clearErrors:u,processing:i,post:N,patch:g,transform:v}=W(f);y.useEffect(()=>{r(f)},[f]);const[j,n]=y.useState(m);y.useEffect(()=>{n(m)},[m]);function E(o){o.preventDefault(),v(t=>{const a=t;return a.price=typeof t.price=="string"?Number(t.price.split(",").join("")):t.price,a.currency_code=j.code,{...a}}),k?N(route("invoicing.createProduct"),{onError:t=>{console.log(t)},onSuccess:()=>{M(e.jsx(O,{copy:"Product Added!"}),A),p.off()}}):g(route("invoicing.updateProduct",{product:T}),{onError:t=>{console.log(t)},onSuccess:()=>{M(e.jsx(O,{copy:"Product Updated!"}),A),l()}})}return e.jsxs(G,{show:h,onClose:l,maxWidth:"xl",paddingClass:"p-7",closeable:!i,children:[e.jsxs("button",{type:"button",className:"ml-auto block rounded-full bg-disabled-light-grey p-1.5 disabled:cursor-not-allowed",onClick:l,disabled:i,children:[e.jsx("span",{className:"sr-only",children:"Close Modal"}),e.jsx("figure",{children:e.jsx(ae,{size:18,weight:"regular",className:"text-disabled-dark-grey"})})]}),e.jsxs("form",{className:"flex flex-col gap-4",onSubmit:E,children:[e.jsxs("h2",{className:"text-[32px] font-bold leading-6",children:[k?"Add a":"Edit"," Product"]}),e.jsxs("fieldset",{children:[e.jsx(I,{className:"text-xs font-bold leading-4",required:!0,children:"Name"}),e.jsx($,{placeholder:"Enter Product Name",value:c.name,onChange:o=>r(t=>({...t,name:o.target.value})),required:!0,disabled:i})]}),e.jsxs("fieldset",{children:[e.jsxs(I,{className:"text-xs font-bold leading-4",children:["Description"," ",e.jsx("span",{className:"text-brand-light-grey",children:"(Optional)"})]}),e.jsx(J,{rows:5,placeholder:"Enter Description",value:c.description,onChange:o=>{const{value:t}=o.target;t.length>500?s("description","Description must be less than or equal to 500 characters"):u("description"),r(a=>({...a,description:t}))},disabled:i,hasError:"description"in d}),e.jsxs("span",{role:"description"in d?"alert":"complementary",className:C("block place-self-end text-xs leading-[14px]","description"in d?"text-red-500":"text-[#A6ABB0]"),children:[c.description.length,"/500"]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("fieldset",{children:[e.jsx(I,{className:"text-xs font-bold leading-4",children:"Price"}),e.jsx(ce,{className:C("crm-input black-focus","price"in d&&"border-red-500"),value:c.price,allowNegative:!1,decimalScale:2,fixedDecimalScale:!0,thousandSeparator:",",isAllowed:o=>o.floatValue>0&&o.floatValue<=999999999,onChange:o=>r(t=>({...t,price:o.target.value})),disabled:i}),"price"in d&&e.jsx("span",{className:"text-xs leading-4 text-red-500",children:"Price must be greater than or equal to 1"})]}),e.jsxs("fieldset",{children:[e.jsx(I,{className:"text-xs font-bold leading-4",children:"Currency"}),e.jsxs(x,{children:[e.jsxs(x.Trigger,{type:"button",className:"crm-input black-focus flex items-center justify-between px-3 font-normal uppercase",disabled:i,children:[j.code," (",j.symbol,")",e.jsx(ie,{size:16,weight:"bold"})]}),e.jsx(x.List,{children:P.map(o=>e.jsx(x.Item,{children:({showDropdownSetters:t,itemStyle:a})=>e.jsxs("button",{type:"button",className:C(a,"px-2"),onClick:()=>{n(o),t.off()},children:[o.code," (",o.symbol,")"]})},o.code))})]})]})]}),e.jsx(q.button,{type:"submit",className:"btn btn-black-primary mt-[34px] !ju
1stify-center text-center",disabled:i,layout:"size",transition:{layout:{duration:.2,ease:"easeInOut"}},children:e.jsx(de,{mode:"wait",initial:!1,children:e.jsx(q.span,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.15},className:"flex items-center gap-1",children:i?e.jsxs(e.Fragment,{children:["Saving Product..."," ",e.jsx(ne,{size:14,weight:"bold",className:"animate-spin"})]}):w?"Save & Sync with Stripe":"Save Product"},i?"processing":"idle")})})]})]})}function fe({hasConnectedAccount:h,visitOnboarding:p,onBoardingInProgress:P,currencyCode:m,paymentCurrencies:f}){_().props.auth.user.profile.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone;const[k,l]=S(!1),[w,c]=S(!1),[r,d]=S(!1),[s,u]=y.useState(null),[i]=S(!1),[N,g]=S(!1),v=h&&!p&&!P,{defaultCurrency:j,currencyOptions:n}=K(f,m);function E(o){B.delete(route("invoicing.deleteProduct",{product:s.id}),{onBefore:()=>o.on(),onError:t=>{console.log(t);let a="";"active-invoice"in t?a=t["active-invoice"]:a=xe,M(e.jsx(V,{copy:a}),A),o.off()},onSuccess:()=>{o.off(),d.off(),u(null),M(e.jsx(O,{copy:"Product deleted!"}),A)}})}return e.jsxs(e.Fragment,{children:[e.jsx(Z,{showLearnMore:N,showLearnMoreSetters:g}),e.jsx(R,{showModal:k,showModalSetters:l,currencyOptions:n,defaultCurrency:j,defaultFormData:{name:"",description:"",price:"1"},isCreating:!0,onClose:l.off,isConnected:v,productId:null}),e.jsx(R,{showModal:w,showModalSetters:c,currencyOptions:n,defaultCurrency:{code:s==null?void 0:s.currency_code,symbol:s?ee(s==null?void 0:s.currency_code):""},defaultFormData:{name:(s==null?void 0:s.name)??"",description:(s==null?void 0:s.description)??"",price:s!=null&&s.price?s==null?void 0:s.price:"1"},isCreating:!1,onClose:()=>{c.off(),u(null)},productId:s==null?void 0:s.id,isConnected:v}),e.jsx(H,{show:r,heading:"Delete Product",copy:"This will permanently delete the product from your product library and stripe.",successCopy:"Product Deleted!",onDelete:E,onClose:()=>{d.off(),u(null)}}),e.jsxs("div",{className:"mx-auto max-w-7xl",children:[e.jsx("div",{className:"mb-4 flex items-center justify-between",children:e.jsxs("button",{type:"button",className:"btn btn-black-primary mb-4 self-start",onClick:l.on,children:[e.jsx("figure",{children:e.jsx(z,{size:16,weight:"bold",className:"text-white"})}),"New Product"]})}),e.jsx(U,{onClick:g.on}),e.jsx(ue,{heading:"Products",dataKey:"products",routeName:"invoicing.showProducts",isDisabled:i,children:({noResults:o,isEmpty:t,products:a})=>e.jsxs(e.Fragment,{children:[o&&e.jsx("p",{className:"text-sm font-bold",children:"No Results Matching Criteria Found."}),t&&e.jsxs("div",{className:"col-span-full flex w-full flex-col items-center justify-center rounded-2xl border-[1.5px] bg-white p-4 py-8",children:[e.jsxs("figure",{className:"mb-4 mt-6 flex h-[60px] w-[60px] items-center justify-center rounded-full bg-brand-dark-grey",children:[e.jsx("span",{className:"sr-only",children:"You have no Products"}),e.jsx(se,{size:24,color:"white"})]}),e.jsx("p",{className:"font-bold capitalize",children:"Create Your First Product"}),e.jsx("div",{className:"flex flex-col",children:e.jsx("small",{className:"mb-6 max-w-[400px] text-center",children:"Click below to create your first Product"})}),e.jsx("div",{children:e.jsxs("button",{type:"button",className:"btn btn-black-primary",onClick:l.on,children:[e.jsx("figure",{children:e.jsx(z,{size:16,weight:"bold",className:"text-white"})}),"New Product"]})})]}),a.map(b=>e.jsxs("div",{className:"col-span-full rounded-2xl bg-[#F9F9F9] p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-bold leading-6",children:b.name}),e.jsxs(x,{children:[e.jsx(x.Trigger,{type:"button",children:e.jsx(le,{size:16,weight:"bold"})}),e.jsxs(x.List,{children:[e.jsx(x.Item,{children:({showDropdownSetters:D,itemStyle:F})=>e.jsxs("button",{type:"button",className:C(F,"px-2"),onClick:()=>{u(b),c.on(),D.off()},children:[e.jsx(te,{size:12,weight:"bold"}),"Edit"]})}),e.jsx(x.Item,{children:({showDropdownSetters:D,itemStyle:F})=>e.jsxs("button",{type:"button",className:C(F,"px-2"),onClick:()=>{u(b),d.on(),D.off()},children:[e.jsx(oe,{size:12,weight:"bold"}),"Delete"]})})]})]})]}),e.jsxs("div",{className:"mt-6 flex w-full flex-col items-start sm:flex-row",children:[e.jsx("p",{className:"text-sm font-normal leading-[18px]",children:b.description}
1),e.jsxs("div",{className:"mr-12 sm:-mt-6 sm:ml-auto",children:[e.jsx(I,{className:"text-xs leading-7",children:"Price"}),e.jsx("span",{className:"block text-xl font-bold leading-4",children:X(b.currency_code,b.price)})]})]})]},b.id))]})})]})]})}fe.layout=h=>e.jsx(re,{children:h,title:"Products"});export{fe as default};

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.