PageSourceSearch

https://mayulearn.com/assets/ProfilePage-BNK-O_0f.js

js mayulearn.com collected 2026-10-02 01:35:46 UTC 8,292 bytes, 1 lines download raw bytes

1import{c as X,j as e,L as d,b as q,r as n}from"./react-vendor-CuXqCZZG.js";import{V as H,g as J,h as Q,b as Z,a as ee,W as te,B as _,X as j,Y as se}from"./index-CxYQAUOF.js";import{f as re}from"./authOutcome-cpYuYWKU.js";import{C as ne}from"./ConfirmDialog-Bb91Koc-.js";import"./supabase-BoK9SHHt.js";function ae(){const s=X.c(1);let t;return s[0]===Symbol.for("react.memo_cache_sentinel")?(t=e.jsx(d,{to:H,state:{paywallTrigger:"profile_upgrade"},className:J(Q({size:"sm"}),"h-10 px-4 text-sm font-medium bg-orange-500 text-white hover:bg-orange-600 focus-visible:ring-orange-500"),children:"Upgrade to Plus"}),s[0]=t):t=s[0],t}function u(s){return s.cancelScheduled&&s.status==="trialing"}function ie(s){if(!s)return null;const t=new Date(s);return Number.isNaN(t.getTime())?null:new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"long"}).format(t)}function N(s){const t=ie(s);return t?`Plus stays active until ${t}, and you won't be charged.`:"Plus stays active until the free trial ends, and you won't be charged."}function A(s){return u(s)?N(s.currentPeriodEnd):"Your subscription is set to cancel at the end of the billing period."}function le(s){return s.status==="trialing"?N(s.currentPeriodEnd):"Your subscription remains active until the current billing period ends."}function oe(s){return u(s)?N(s.currentPeriodEnd):"We're sorry to see you go! Your subscription remains active until the current billing period ends"}const xe=()=>{const s=q(),{user:t,refreshSession:m}=Z(),{session:i,signOut:D,resetPassword:U}=ee(),[l,S]=n.useState(!1),[p,v]=n.useState(!1),[I,x]=n.useState(!1),[E,o]=n.useState(null),[w,c]=n.useState(null),[f,k]=n.useState(!1),[P,C]=n.useState(null),[L,O]=n.useState(null),[g,T]=te(),[B,Y]=n.useState(!1),[h,M]=n.useState(!1),[F,R]=n.useState(null),b=h?B:t?.profile.streakEmailOptIn===!0;async function G(r){if(!h){M(!0),R(null),Y(r);try{await j.put("/api/notifications/streak-email",{optedIn:r}),await m()}catch(a){const K=a instanceof Error?a.message:"Failed to update streak emails";R(K)}finally{M(!1)}}}const y=t?.subscription.currentPeriodEnd&&new Date(t.subscription.currentPeriodEnd).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"});async function V(){await D(),s("/login",{replace:!0,state:se()})}async function $(){const r=i?.user.email?.trim();if(!(!r||f)){k(!0),C(null),O(null);try{const a=await U(r);if(!a.ok){O(re(a.error,"Failed to send reset email."));return}C("Check your email for a reset link.")}finally{k(!1)}}}async function W(){if(!l){S(!0),x(!1),c(null),o(null);try{await j.post("/api/billing/cancel",{}),await m(),o(oe({cancelScheduled:!0,status:t?.subscription.status,currentPeriodEnd:t?.subscription.currentPeriodEnd}))}catch(r){const a=r instanceof Error?r.message:"Failed to cancel subscription";c(a)}finally{S(!1)}}}async function z(){if(!p){v(!0),c(null),o(null);try{await j.post("/api/billing/uncancel",{}),await m(),o("Cancellation removed. Your subscription will continue renewing normally.")}catch(r){const a=r instanceof Error?r.message:"Failed to uncancel subscription";c(a)}finally{v(!1)}}}return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Profile"}),e.jsxs("div",{className:"mt-4 flex items-center justify-between rounded-lg border border-border bg-card px-4 py-3",children:[e.jsx("span",{className:"text-sm text-foreground",children:"Sound"}),e.jsx("button",{type:"button",role:"switch","aria-checked":g,className:"rounded-lg border border-border px-3 py-1 text-sm",onClick:()=>T(!g),children:g?"On":"Off"})]}),t&&e.jsxs("div",{className:"mt-4 rounded-lg border border-border bg-card p-4",children:[i?.user.email&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Email"}),e.jsx("p",{className:"font-medium",children:i.user.email})]}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-foreground",children:"Streak emails"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Email me if a streak ends. Off until you turn this on."}),F?e.jsx("p",{className:"mt-1 text-sm text-destructive",children:F}):null]}),e.jsx("button",{type:"button",role:"switch","aria-checked":b,"aria-label":"Streak emails",disabled:h,className:"rounded-lg border border-border px-3 py-1 text-sm disabled:opacity-50",onClick:()=>{G(!b)},children:b?"On":"Off"})]}),e.jsx("div",{className:"mt-4 border-t border-border pt-4",children:t.isPlus?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Membership"}),e.jsx("p",{className:"font-medium",children:"Mayu Learn Plus"}
1),y&&!u(t.subscription)?e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t.subscription.cancelScheduled?`Cancels on ${y}`:`Renews on ${y}`}):null,t.subscription.provider==="revenuecat"?e.jsxs("div",{className:"mt-3",children:[u(t.subscription)?e.jsx("p",{className:"text-sm text-muted-foreground",children:A(t.subscription)}):null,e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This subscription is managed through the App Store or Google Play. Open your device subscription settings to cancel or change it."}),e.jsxs("p",{className:"mt-2 text-sm",children:[e.jsx("a",{href:"https://apps.apple.com/account/subscriptions",className:"text-muted-foreground underline",target:"_blank",rel:"noreferrer",children:"Apple subscription settings"}),e.jsx("span",{className:"mx-2 text-muted-foreground","aria-hidden":!0,children:"·"}),e.jsx("a",{href:"https://play.google.com/store/account/subscriptions",className:"text-muted-foreground underline",target:"_blank",rel:"noreferrer",children:"Google Play subscriptions"})]})]}):t.subscription.provider==="complimentary"?e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"Complimentary membership provided by Mayu Learn."}):t.subscription.cancelScheduled?e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:A(t.subscription)}),e.jsx("div",{className:"mt-2",children:e.jsx(_,{type:"button",onClick:()=>{z()},disabled:p,loading:p,children:"Keep subscription"})})]}):e.jsx("p",{className:"mt-3 text-sm",children:e.jsx("button",{type:"button",className:"text-muted-foreground underline disabled:opacity-60",onClick:()=>x(!0),disabled:l,children:"Cancel subscription"})}),E?e.jsx("p",{className:"mt-2 text-sm text-primary",children:E}):null,w?e.jsx("p",{className:"mt-2 text-sm text-red-600 dark:text-red-400",children:w}):null]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Membership"}),e.jsx("p",{className:"font-medium",children:"Free Plan"}),e.jsx("div",{className:"mt-3",children:e.jsx(ae,{})})]})}),e.jsxs("div",{className:"mt-4 border-t border-border pt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"User settings"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:e.jsx(_,{type:"button",onClick:()=>{V()},children:"Log out"})}),e.jsx("p",{className:"mt-3 text-sm",children:e.jsx("button",{type:"button",className:"text-muted-foreground underline disabled:opacity-60",onClick:()=>{$()},disabled:!i?.user.email||f,children:f?"Sending reset link…":"Reset password"})}),P?e.jsx("p",{className:"mt-2 text-sm text-primary",children:P}):null,L?e.jsx("p",{className:"mt-2 text-sm text-red-600 dark:text-red-400",children:L}):null,e.jsxs("p",{className:"mt-3 text-sm text-muted-foreground",children:["By using Mayu Learn, you agree to our"," ",e.jsx(d,{to:"/terms-of-use",className:"underline",children:"Terms of Use"})," ","and"," ",e.jsx(d,{to:"/privacy-policy",className:"underline",children:"Privacy Policy"}),"."]}),e.jsx("p",{className:"mt-3 text-sm",children:e.jsx(d,{to:"/profile/delete-account",className:"text-muted-foreground underline",children:"Delete Account"})})]})]}),e.jsx(ne,{open:I,title:"Are you sure you want to cancel?",message:le({status:t?.subscription.status,currentPeriodEnd:t?.subscription.currentPeriodEnd}),confirmLabel:"Yes, cancel",cancelLabel:"Never mind",confirmVariant:"danger",cancelVariant:"secondary",alignActions:"center",confirmLoading:l,cancelDisabled:l,dismissOnBackdrop:!1,dismissOnEscape:!1,onConfirm:()=>{W()},onCancel:()=>x(!1)})]})};export{xe 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.