PageSourceSearch

https://careplanpro.ai/assets/MembershipSelectPage-BwXaufbn.js

js careplanpro.ai collected 2026-10-05 11:54:33 UTC 14,358 bytes, 1 lines download raw bytes

1import{Y as ge,u as fe,r as s,j as e,L as Q,H as y,m as be,d as X,aD as je,I as m,ay as ye,B as ve,s as A,f as g}from"./index-B9m0jA0r.js";import{P as Ne}from"./phone-input-CL7exIJI.js";import{L as o}from"./label-CHLwbswP.js";import{C as _e}from"./checkbox-B9G3g3S2.js";import{B as we}from"./badge-Deq2Zmk0.js";import{S as Se}from"./StripePayStep-B5xZzvv1.js";import{S as Ce}from"./sparkles-C0ubSClR.js";import"./phone-CzY9Lu_e.js";import"./index-CjHmcE51.js";import"./index-VHGvsBtf.js";import"./carePlanTokens-C6iTZf_M.js";import"./zap-1IcN1J7o.js";import"./target-CJUl-Eur.js";import"./infinity-CkcOdjyL.js";import"./stethoscope-Dxy2-HrW.js";import"./heart-DhSBPkva.js";const Z={weekly:"/week",monthly:"/month",quarterly:"/quarter",annual:"/year"};function ee(i){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(i)}function ke(i){var p,f;const u=((p=i.custom_label)==null?void 0:p.trim())||((f=i.service_name)==null?void 0:f.trim())||"Included service",r=Math.max(1,i.quantity??1);return r>1?`${u} (${r})`:u}const Pe="By signing below, I authorize the practice to enroll me in the selected membership plan. I understand that this is an enrollment request and the practice will follow up to confirm details, billing, and start date. Membership pricing, included services, and cancellation policy are as shown above.";function Ge(){var O,U;const{slug:i,planId:u}=ge();fe();const[r,p]=s.useState(null),[f,v]=s.useState(!0),[N,M]=s.useState(!1),[E,b]=s.useState("form"),[h,$]=s.useState(null),[te,B]=s.useState("paid"),[j,se]=s.useState(""),[_,re]=s.useState(""),[w,ae]=s.useState(""),[S,ne]=s.useState(""),[T,ie]=s.useState(""),[Y,le]=s.useState(""),[V,oe]=s.useState(""),[D,ce]=s.useState(""),[R,me]=s.useState(""),[z,de]=s.useState(""),[C,ue]=s.useState(!1),[k,pe]=s.useState("");s.useEffect(()=>{let t=!1;async function c(){if(!i||!u){p("missing"),v(!1);return}v(!0);const{data:l,error:a}=await A.rpc("get_public_membership_plan",{p_slug:i,p_plan_id:u});t||(p(a||!l?"missing":l),v(!1))}return c(),()=>{t=!0}},[i,u]);const xe=s.useMemo(()=>{var c,l;const t=r&&r!=="missing"?(l=(c=r.settings)==null?void 0:c.terms_text)==null?void 0:l.trim():"";return t&&t.length>0?t:Pe},[r]);if(f)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(Q,{className:"w-6 h-6 animate-spin text-muted-foreground"})});if(r==="missing"||!r)return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-background px-6 text-center",children:[e.jsx("h1",{className:"text-2xl font-light text-foreground mb-2",children:"Page not found"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:"We couldn’t find this membership selection. Please check the link with your practice."}),e.jsx(y,{to:"/",className:"mt-6 text-sm text-primary underline-offset-4 hover:underline",children:"Go home"})]});const P=r.settings,n=r.plan;if(r.unavailable||!P||P.enabled===!1||P.public_page_enabled===!1||!n)return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-background px-6 text-center",children:[e.jsx("h1",{className:"text-2xl font-light text-foreground mb-2",children:r.practice_name||"This practice"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:"This membership plan isn’t available right now. Please contact the practice directly."}),i&&e.jsx(y,{to:`/memberships/share/${i}`,className:"mt-6 text-sm text-primary underline-offset-4 hover:underline",children:"Back to memberships"})]});if(E==="done"){const t=te==="already_enrolled";return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center px-6",children:e.jsxs(be.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.4},className:"max-w-lg w-full rounded-2xl border border-border bg-card p-8 text-center shadow-sm",children:[e.jsx("div",{className:"w-12 h-12 mx-auto rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(X,{className:"w-6 h-6 text-primary"})}),t?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-light text-foreground mb-2",children:"You're already enrolled"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Our records show an active membership for this email. Please contact ",r.practice_name||"the practice"," if you need help."]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-light text-foreground mb-2",children:"Payment received!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your membership is being activated. You'll receive a confirmation email shortly."})]}),i&&e.jsx(y,{to:`/memberships/share/${i}`,className:"inline-block mt-6 text-sm text-primary underline-offset-4 hover:underline",children:"Back to memberships"})]})})}if(E==="pay"&&h){const t=((O=Z[n.billing_frequency])==null?void 0:O.replace("/",""))||n.billing_frequency||"month",c=`${ee(h.amountCents/100)}/${t} recurring`,l=((U=n.cancellation_policy)==null?void 0:U.trim())||"",a=l?`${c} • ${l}`:c;return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center px-6 py-10",children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl border border-border bg-card shadow-sm overflow-hidden flex flex-col",children:[e.jsx("div",{className:"px-8 pt-6 pb-2 text-center",children:e.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-muted-foreground",children:"Step 2 of 2 — Payment"})}),e.jsx(Se,{clientSecret:h.clientSecret,stripeAccountId:h.stripeAccountId,amountCents:h.amountCents,patientFirstName:j||"there",subheadline:a,onPaymentSuccess:()=>{B("paid"),b("done")},onCancel:()=>{$(null),b("form")}})]})})}async function he(t){var c,l;if(t.preventDefault(),!N){if(!j.trim()||!_.trim()){g.error("Please enter your first and last name.");return}if(!w.trim()&&!S.trim()){g.error("Please provide an email or phone so the practice can reach you.");return}if(!C){g.error("Please accept the membership terms to continue.");return}if(!k.trim()){g.error("Please type your full name as your signature.");return}M(!0);try{const{data:a,error:W}=await A.rpc("submit_membership_signup",{p_slug:i,p_plan_id:u,p_first_name:j.trim(),p_last_name:_.trim(),p_email:w.trim()||null,p_phone:S.trim()||null,p_date_of_birth:T||null,p_address_line_1:Y.trim()||null,p_address_line_2:V.trim()||null,p_city:D.trim()||null,p_state:R.trim()||null,p_postal_code:z.trim()||null,p_terms_accepted:C,p_signature_name:k.trim()});if(W)throw W;if(!((a==null?void 0:a.success)===!0))throw new Error("Submission failed");const G=(a==null?void 0:a.patient_membership_id)||(a==null?void 0:a.id)||null;if(!G)throw new Error("Missing membership reference. Please try again.");const{data:d,error:F}=await A.functions.invoke("create-membership-subscription",{body:{patient_membership_id:G}});if(F){let L="internal_error",I=F.message||"Could not start payment.";try{const q=F.context;if(q&&typeof q.json=="function"){const x=await q.json();L=((c=x==null?void 0:x.error)==null?void 0:c.code)||L,I=((l=x==null?void 0:x.error)==null?void 0:l.message)||I}}catch{}if(L==="already_enrolled"){B("already_enrolled"),b("done");return}throw new Error(I)}const H=d==null?void 0:d.client_secret,K=d==null?void 0:d.stripe_account_id,J=d==null?void 0:d.amount_cents;if(!H||!K||typeof J!="number")throw new Error("Invalid payment session response.");$({clientSecret:H,stripeAccountId:K,amountCents:J}),b("pay")}catch(a){console.error("Membership submit error",a),g.error((a==null?void 0:a.message)||"Something went wrong. Please try again.")}finally{M(!1)}}}return e.jsx("div",{className:"min-h-screen bg-background text-foreground",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-6 sm:px-10 pt-10 pb-16",children:[e.jsx("div",{className:"mb-6",children:e.jsxs(y,{to:`/memberships/share/${i}`,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(je,{className:"w-4 h-4"})," Back to plans"]})}),e.jsxs("div",{className:"text-center mb-10",children:[r.practice_logo_url?e.jsx("img",{src:r.practice_logo_url,alt:r.practice_name||"Practice logo",className:"h-12 w-auto mx-auto mb-5 object-contain"}):e.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-muted-foreground mb-3",children:r.practice_name||"Memberships"}),e.jsx("h1",{className:"text-3xl sm:text-4xl font-light tracking-tight",children:"You’re almost done"}),e.jsx("p",{className:"mt-3 text-sm sm:text-base text-muted-foreground max-w-xl mx-auto",children:"Review your selected membership, share a few details, and sign to send your request to the practice."})]}
1),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-5 gap-8",children:[e.jsx("aside",{className:"lg:col-span-2 order-1 lg:order-2",children:e.jsxs("div",{className:`relative rounded-2xl border bg-card p-6 ${n.is_featured?"border-primary shadow-lg ring-1 ring-primary/20":"border-border shadow-sm"} lg:sticky lg:top-6`,children:[n.is_featured&&e.jsxs(we,{className:"absolute -top-3 left-1/2 -translate-x-1/2 gap-1 px-3 py-1",children:[e.jsx(Ce,{className:"w-3 h-3"}),"Most Popular"]}),e.jsx("h2",{className:"text-xl font-semibold",children:n.name||"Membership"}),n.subtitle&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:n.subtitle}),e.jsxs("div",{className:"mt-4 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-4xl font-light tracking-tight",children:ee(n.monthly_price??0)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Z[n.billing_frequency]||`/${n.billing_frequency}`})]}),n.services.length>0&&e.jsx("ul",{className:"mt-5 space-y-2",children:n.services.map(t=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-foreground",children:[e.jsx(X,{className:"w-4 h-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:ke(t)})]},t.id))}),n.cancellation_policy&&e.jsx("p",{className:"text-[11px] text-muted-foreground mt-5 leading-relaxed border-t border-border pt-3",children:n.cancellation_policy})]})}),e.jsxs("form",{onSubmit:he,className:"lg:col-span-3 order-2 lg:order-1 rounded-2xl border border-border bg-card p-6 sm:p-8 shadow-sm space-y-6",noValidate:!0,children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-muted-foreground",children:"Step 1 of 2 — Your info"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold",children:"Your information"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"We use this to set up your membership account."})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{htmlFor:"first_name",children:"First name *"}),e.jsx(m,{id:"first_name",value:j,onChange:t=>se(t.target.value),required:!0,autoComplete:"given-name"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{htmlFor:"last_name",children:"Last name *"}),e.jsx(m,{id:"last_name",value:_,onChange:t=>re(t.target.value),required:!0,autoComplete:"family-name"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{htmlFor:"email",children:"Email"}),e.jsx(m,{id:"email",type:"email",value:w,onChange:t=>ae(t.target.value),autoComplete:"email"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{htmlFor:"phone",children:"Phone"}),e.jsx(Ne,{id:"phone",value:S,onChange:t=>ne(t)})]}),e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[e.jsx(o,{htmlFor:"dob",children:"Date of birth"}),e.jsx(m,{id:"dob",type:"date",value:T,onChange:t=>ie(t.target.value),min:"1900-01-01",max:"2050-12-31"})]})]}),e.jsxs("div",{className:"pt-2",children:[e.jsx("h3",{className:"text-base font-semibold",children:"Mailing address"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Optional but helpful."})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[e.jsx(o,{htmlFor:"address1",children:"Address line 1"}),e.jsx(m,{id:"address1",value:Y,onChange:t=>le(t.target.value),autoComplete:"address-line1"})]}),e.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[e.jsx(o,{htmlFor:"address2",children:"Address line 2"}),e.jsx(m,{id:"address2",value:V,onChange:t=>oe(t.target.value),autoComplete:"address-line2"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{htmlFor:"city",children:"City"}),e.jsx(m,{id:"city",value:D,onChange:t=>ce(t.target.value),autoComplete:"address-level2"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{htmlFor:"state",children:"State"}),e.jsx(m,{id:"state",value:R,onChange:t=>me(t.target.value),autoComplete:"address-level1"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{htmlFor:"postal",children:"Postal code"}),e.jsx(m,{id:"postal",value:z,onChange:t=>de(t.target.value),autoComplete:"postal-code"})]})]}),e.jsxs("div",{className:"pt-2",children:[e.jsxs("h3",{className:"text-base font-semibold flex items-center gap-2",children:[e.jsx(ye,{className:"w-4 h-4 text-primary"}),"Membership terms"]}),e.jsx("div",{className:"mt-3 max-h-48 overflow-y-auto rounded-md border border-border bg-muted/30 p-4 text-sm text-foreground
1/90 whitespace-pre-wrap leading-relaxed",children:xe}),e.jsxs("label",{className:"mt-4 flex items-start gap-3 text-sm cursor-pointer",children:[e.jsx(_e,{checked:C,onCheckedChange:t=>ue(!!t),className:"mt-0.5"}),e.jsx("span",{className:"text-foreground",children:"I have read and accept the membership terms above."})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{htmlFor:"signature",children:"Signature *"}),e.jsx(m,{id:"signature",value:k,onChange:t=>pe(t.target.value),placeholder:"Type your full legal name",className:"font-serif text-lg",required:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Typing your name acts as your electronic signature."})]}),e.jsxs("div",{className:"pt-2",children:[e.jsx(ve,{type:"submit",size:"lg",className:"w-full",disabled:N,children:N?e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"w-4 h-4 mr-2 animate-spin"}),"Continuing…"]}):e.jsx(e.Fragment,{children:"Continue to payment"})}),e.jsx("p",{className:"text-[11px] text-muted-foreground text-center mt-3",children:"Step 1 of 2 — you'll enter payment details next."})]})]})]})]})})}export{Ge 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.