PageSourceSearch

https://care.soberpedia.ai/assets/ManualInvoicePaymentModal-D49drC92.js

js soberpedia.ai collected 2026-10-05 15:11:15 UTC 5,772 bytes, 1 lines download raw bytes

1import{r as o,j as v}from"./react-vendor-CU6Sz31W.js";import{gp as Q,t as p,au as W,R as L,gq as X,ax as Y,S as D,b as ee,g as B}from"./index-DEXJEDAi.js";import{f as te,b as se,V as ne}from"./PatientBookingForm-CF9FKzmx.js";import{u as ie,a as ae}from"./usePatientBillingInfo-DXD25T6z.js";import"./firebase-w6DYUbFN.js";import"./payment-icons-Daq1K3F1.js";import"./IdAndPhotoUploadSection-CVePkTk1.js";import"./ContactInfoSection-2PBmPpSi.js";import"./collapsible-JRJGT2Lx.js";import"./cloud-upload-DO_CTloa.js";import"./CameraCapture-C4ah5pn_.js";import"./monitor-CzX6E2vl.js";import"./circle-dashed-BpzaptvF.js";import"./user-round-c4EWOTq5.js";import"./use-unsaved-changes-B6nL5Xdd.js";import"./alert-WsBxL0qd.js";import"./providerAssignments-C7MWOvAk.js";import"./visitIcons-CG7YiClb.js";import"./badge-check-DS4dztDB.js";import"./CheckoutShell-DPiImp5d.js";import"./checkoutDisplay-6C7UrTTD.js";import"./useAuthorizeHostedToken-CiwlhvjR.js";import"./VisitSchedulePicker-4J6xpsxo.js";import"./addWeeks-1hrFjz19.js";import"./patientAddress-D6GhuKXS.js";import"./CustomPaymentInstructionsPanel-wIf9paY9.js";import"./EmbeddedWhopCheckout-exs5FPDQ.js";import"./networkLicensurePolicy-Ct3PZM4V.js";const oe=B("initializeManualInvoiceCheckout"),le=B("completeManualInvoicePayment");function ke({open:g,onOpenChange:d,order:e,accentColor:U=ee,onPaymentComplete:b}){var N,j,A,S;const[T,I]=o.useState(!1),[s,h]=o.useState(null),[M,C]=o.useState(!1),{billingInfo:y,setBillingInfo:F,resetBillingInfo:P}=ie({active:g,seedKey:(e==null?void 0:e.id)||null}),a=o.useRef(d);a.current=d;const u=o.useRef(b);u.current=b;const{appliedCoupon:_,couponInput:k,couponExpanded:q,couponUpdating:z,setCouponInput:V,setCouponExpanded:$,initializeCheckout:x,resetCouponState:w,handleApplyCoupon:O,handleRemoveCoupon:J}=ae({order:e,initializeUrl:oe,onCheckoutData:h}),E=o.useCallback(()=>{h(null),C(!1),I(!1),P(),w()},[P,w]);o.useEffect(()=>{if(!g||!(e!=null&&e.id)){E();return}let n=!1;async function c(){var t,r,f;I(!0);try{(await x()).duplicate&&(p.success("This invoice is already paid."),(t=u.current)==null||t.call(u),(r=a.current)==null||r.call(a,!1))}catch(m){L(m,{area:"checkout",surface:"frontend/src/pages/orders/OrdersPatientView/ManualInvoicePaymentModal.jsx",operation:"frontend/src/pages/orders/OrdersPatientView/ManualInvoicePaymentModal.jsx:84"}),n||(console.error("Initialize manual invoice checkout:",m),p.error("Unable to open payment. Please try again."),(f=a.current)==null||f.call(a,!1))}finally{n||I(!1)}}return c(),()=>{n=!0}},[g,e==null?void 0:e.id,x,E]);const K=o.useCallback(async(n,c)=>{var f,m;if(!(e!=null&&e.id))return;const t=c||(s==null?void 0:s.mode)||"demo";if((t==="authorize"||t==="square"||Q(t))&&!(n!=null&&n.useSavedMethod)&&!(n!=null&&n.useSavedCard)){const i=te(y);if(i.length>0){p.error(se(i));return}}try{C(!0);const i=W.currentUser;if(!i)throw new Error("Not authenticated");const H=await i.getIdToken(),l=await(await fetch(le,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${H}`},body:JSON.stringify({orderId:e.id,paymentData:n||{},mode:t,billingInfo:y})})).json();if(!(l!=null&&l.success))throw Object.assign(new Error(l.error||"Payment failed"),{errorCategory:l.errorCategory,safeUserMessage:l.safeUserMessage||l.error});l.pendingManualPayment?p.success("Payment instructions were provided."):p.success("Payment completed."),(f=u.current)==null||f.call(u),(m=a.current)==null||m.call(a,!1)}catch(i){if(L(i,{area:"checkout",surface:"frontend/src/pages/orders/OrdersPatientView/ManualInvoicePaymentModal.jsx",operation:"frontend/src/pages/orders/OrdersPatientView/ManualInvoicePaymentModal.jsx:153"}),["saved_card_unavailable","saved_card_update"].includes(i==null?void 0:i.errorCategory))throw i;console.error("Complete manual invoice payment:",i),p.error(X(i==null?void 0:i.message,"Payment could not be completed. Please try again."))}finally{C(!1)}},[y,s==null?void 0:s.mode,e==null?void 0:e.id]),R=(s==null?void 0:s.amount)!=null?`$${Number(s.amount).toFixed(2)}`:(e==null?void 0:e.amount)!=null?`$${(Number(e.amount)/100).toFixed(2)}`:"",Z=o.useMemo(()=>{var c;return(Array.isArray((c=e==null?void 0:e.manualInvoice)==null?void 0:c.lineItems)&&e.manualInvoice.lineItems.length>0?e.manualInvoice.lineItems:Array.isArray(e==null?void 0:e.items)?e.items.filter(t=>String((t==null?void 0:t.type)||"").toLowerCase()!=="shipping"):[]).filter(t=>Number(t==null?void 0:t.amount)>0).map((t,r)=>({id:t.id||`line-${r}`,name:t.name||t.description||`Item ${r+1}`,quantity:Number(t.quantity)>0?Number(t.quantity):1,amount:Number(t.amount)||0}))},[(N=e==null?void 0:e.manualInvoice)==null?void 0:N.lineItems,e==null?void 0:e.items]),G=((A=(j=s==null?void 0:s.checkoutDisplay)==null?void 0:j.stepContext)==null?void 0:A.supportsCoupons)===!0;return v.jsx(Y,{open:g,onOpenChange:n=>{M||d(n)},title:"Pay invoice",description:"Complete payment for your invoice.",contentClassName:"max-w-lg",bodyClassName:"p-4 sm:p-6",contentTestId:"dialog-manual-invoice-payment",children:T?v.jsx("div",{className:"flex min-h-[220px] items-center justify-center",children:v.jsx(D,{size:"lg",label:"Loading payment",className:"text-muted-foreground"})}):s?v.jsx(ne,{visitCheckoutData:s,amount:R,visitLabel:(e==null?void 0:e.productName)||((S=s==null?void 0:s.product)==null?void 0:S.name)||"Invoice",accentColor:U,lineItems:Z,onComplete:K,onBack:()=>d(!1),billingInfo:y,onBillingInfoChange:F,paymentProcessing:M,hideFooterActions:!0,submitLabelOverride:"Complete payment",saveMethodLabel:"Save this payment method for future invoice payments",couponsEnabled:G,appliedCoupon:_,couponInput
1:k,couponExpanded:q,couponUpdating:z,onCouponInputChange:V,onToggleCouponExpanded:()=>$(n=>!n),onApplyCoupon:O,onRemoveCoupon:J}):null})}export{ke 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.