PageSourceSearch

https://www.zolabs.ai/assets/Account-gFgaQDXs.js

js zolabs.ai collected 2026-10-05 13:55:18 UTC 17,137 bytes, 6 lines download raw bytes

1import{j as e}from"./motion-CVTwpPKx.js";import{r,u as O}from"./vendor-CIx5J0Tc.js";import{c as V,b as G,q as J,f as Q,U as X,K as ee,n as te,r as se,g as ae,F as le,s as ne,u as re,v as ie,e as g,D as oe,t as C}from"./index-D6BiZGyn.js";import{C as ce}from"./credit-card-9ozNoZKX.js";import{T as de}from"./triangle-alert-B-9BEUQx.js";import"./syntaxHighlight-D9odjxAA.js";import"./charts-CkZASFcz.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const me=V("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),je=()=>{const[x,D]=r.useState("account"),[n,I]=r.useState(null),[o,B]=r.useState(null),[c,R]=r.useState(null),[q,T]=r.useState(!0),[W,E]=r.useState(!1),[Y,b]=r.useState(!1),[v,w]=r.useState(null),[j,y]=r.useState(null),[F,k]=r.useState(null),[_,A]=r.useState(!1),[U,M]=r.useState(null),[L,S]=r.useState(null),$=r.useContext(G),{auth:h,logout:f}=$||{auth:{isAuthenticated:!1},logout:async()=>{}},d=O();r.useEffect(()=>{(async()=>{var s,a;if($){if(!h.isAuthenticated){d("/login");return}T(!0),w(null);try{const l=await g.get("/auth/user_account_details");I({email:l.data.email,username:l.data.username})}catch(l){((s=l.response)==null?void 0:s.status)===401?(await f(),d("/login")):((a=l.response)==null?void 0:a.status)===404?w("User not found."):w("Failed to fetch account details. Please try again.")}finally{T(!1)}}})()},[h.isAuthenticated,f,d]),r.useEffect(()=>{(async()=>{var s,a,l,i,m;if(!(x!=="plan"||!h.isAuthenticated)){E(!0),y(null);try{const p=await g.get("/balance/current_balance");B(p.data)}catch(p){((s=p.response)==null?void 0:s.status)===401?(await f(),d("/login")):((a=p.response)==null?void 0:a.status)===403?y("Subscription limit reached. Please upgrade your subscription to access plan details."):((l=p.response)==null?void 0:l.status)===404?y("Plan not found for user."):y(((m=(i=p.response)==null?void 0:i.data)==null?void 0:m.error)||"Failed to fetch plan details. Please try again.")}finally{E(!1)}}})()},[x,h.isAuthenticated,f,d]),r.useEffect(()=>{(async()=>{var s,a,l;if(!(x!=="payments"||!h.isAuthenticated)){b(!0),k(null);try{const i=await g.get("/subscriptions/transactions?months=12");R(i.data)}catch(i){((s=i.response)==null?void 0:s.status)===401?(await f(),d("/login")):k(((l=(a=i.response)==null?void 0:a.data)==null?void 0:l.error)||"Failed to fetch payment history. Please try again.")}finally{b(!1)}}})()},[x,h.isAuthenticated,f,d]);const N=t=>{try{return oe.fromISO(t,{zone:"utc"}).setZone("local").toFormat("MM/dd/yyyy hh:mm:ss a")}catch(s){return console.error("Failed to parse UTC date:",t,s),"Invalid Date"}},z=async()=>{var t,s,a,l;if(!(n!=null&&n.email)){M("No email available for reset.");return}A(!0),M(null),S(null);try{await g.post("/auth/forget-password",{email:n.email}),S("Reset link sent to your email. Please check your inbox."),setTimeout(()=>S(null),2e3)}catch(i){let m="Failed to request password reset. Please try again.";((t=i.response)==null?void 0:t.status)===400?m="Email is required.":((s=i.response)==null?void 0:s.status)===404?m="No user found with that email.":(l=(a=i.response)==null?void 0:a.data)!=null&&l.error&&(m=i.response.data.error),M(m),console.error("Forgot password error:",i)}finally{A(!1)}},K=async()=>{var t,s,a,l,i,m,p;if(!(c!=null&&c.paypal_subscription_id)){C({title:"Error",description:"No subscription ID found.",variant:"destructive"}),d("/billing/cancel?subscription_id=none");return}if(window.confirm("Are you sure you want to cancel your subscription?")){b(!0);try{const u=await g.post("/subscriptions/cancel",{paypal_subscription_id:c.paypal_subscription_id});C({title:"Success",description:u.data.message||"Subscription cancelled successfully."}),d(`/billing/cancel?subscription_id=${c.paypal_subscription_id}`)}catch(u){console.error("Subscription cancellation failed:",{status:(t=u.response)==null?void 0:t.status,statusText:(s=u.response)==null?void 0:s.statusText,data:(a=u.response)==null?void 0:a.data,message:u.message});const H=((l=u.response)==null?void 0:l.status)===424?"Cancellation failed due to a server dependency issue. Please try again later or contact support.":((i=u.response)==null?void 0:i.status)===502?"
6Server error: Unable to process cancellation. Please try again later or contact support.":((p=(m=u.response)==null?void 0:m.data)==null?void 0:p.error)||"Failed to cancel subscription. Please try again.";C({title:"Error",description:H,variant:"destructive"}),d(`/billing/cancel?subscription_id=${c.paypal_subscription_id}`)}finally{b(!1)}}},P=t=>{if(t==="unlimited")return"Unlimited";const s=Math.floor(t/60),a=t%60;return`${s} minute${s!==1?"s":""} ${a} second${a!==1?"s":""}`},Z=(t,s)=>{if(s==="unlimited")return e.jsx("span",{className:"text-gray-700",children:t});const a=Math.min(t/s*100,100),l=s-t<=s*.1;return e.jsxs("div",{className:"w-full max-w-[200px]",children:[e.jsx("div",{className:"h-2 bg-gray-200 rounded-full",children:e.jsx("div",{className:`h-2 rounded-full transition-all duration-300 ${l?"bg-red-600":"bg-purple-600"}`,style:{width:`${a}%`},"aria-label":`Usage progress: ${t} of ${s}`})}),e.jsxs("span",{className:`text-sm ${l?"text-red-600":"text-gray-700"}`,children:[t,"/",s]})]})};return e.jsx(J,{children:e.jsxs("div",{className:"min-h-screen bg-[#F8F8FA]",children:[e.jsxs("div",{className:"bg-purple-200/80 border-b border-purple-300/30 px-6 py-4 flex items-center gap-4",children:[e.jsx("button",{onClick:()=>d("/admin/dashboard"),className:"p-2 rounded-xl bg-purple-100 text-purple-700 hover:bg-purple-200 transition-colors",children:e.jsx(Q,{className:"w-5 h-5"})}),e.jsx("h1",{className:"text-2xl font-bold text-purple-900",children:"Manage Your Account"})]}),e.jsxs("div",{className:"max-w-5xl mx-auto px-4 md:px-6 py-6",children:[e.jsx("div",{className:"border-b border-gray-200 mb-6",children:e.jsx("div",{className:"flex gap-1",children:["account","plan","payments"].map(t=>{const s=t==="account"?X:t==="plan"?me:ce,a=t==="account"?"Account":t==="plan"?"Your Plan":"Payments";return e.jsxs("button",{onClick:()=>D(t),className:`flex items-center gap-2 px-5 py-3 text-sm font-semibold border-b-2 transition-all ${x===t?"border-purple-600 text-purple-700":"border-transparent text-gray-500 hover:text-gray-700"}`,"aria-pressed":x===t,children:[e.jsx(s,{size:16}),a]},t)})})}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-6 lg:p-10",children:[x==="account"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h1",{className:"text-3xl font-bold mb-10",children:["Hello ",(n==null?void 0:n.username)||"User","!"]}),e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Your Account Info:"}),q?e.jsxs("div",{className:"text-center text-gray-600",children:[e.jsx("div",{className:"flex justify-center mb-5",children:e.jsx("div",{className:"h-6 w-6 border-4 border-purple-700 border-t-transparent rounded-full animate-[spin_2s_linear_infinite]"})}),e.jsx("p",{children:"Loading account details..."})]}):v?e.jsx("div",{className:"text-center text-red-600",children:e.jsxs("p",{className:"flex items-center justify-center gap-2",children:[v.includes("Failed to fetch")&&e.jsxs("svg",{className:"h-5 w-5 text-red-600","aria-label":"Error fetching account details",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"}),e.jsx("path",{d:"M9 7h6M9 17h6"})]}),v]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-900",children:"Username"}),e.jsx("input",{type:"text",value:(n==null?void 0:n.username)||"",className:"w-full px-4 py-2 mt-1 border rounded-lg bg-gray-50",disabled:!0,"aria-label":"Username"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-gray-900",children:"Email"}),e.jsx("input",{type:"email",value:(n==null?void 0:n.email)||"",className:"w-full px-4 py-2 mt-1 border rounded-lg bg-gray-50",disabled:!0,"aria-label":"Email"})]}),L&&e.jsx("div",{className:"text-center text-green-600",children:e.jsx("p",{children:L})}),U&&e.jsx("div",{className:"text-center text-red-600",children:e.jsxs("p",{className:"flex items-center justify-center gap-2",children:[e.jsxs("svg",{className:"h-5 w-5 text-red-600","aria-label":"Error resetting password",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"}),e.jsx("path",{d:"M9 7h6M9 17h6"})]}),U]})}),e.jsx("div",{className:"flex justify-end space-x-4",children:e.jsxs("button",{onClick:z,disabled:_||!(n!=null&&n.email),className:`px-4 py-2 bg-gradient-to-r from-purple-600 to-purple-700 text-white rounded-lg hover:shadow-lg hover:scale-105 focus:ring-2 focus:ring-purple-500 focus:ring-offset-2 transition-all duration-200 flex items-center text-sm font-medium shadow-sm ${_||!(n!=null&&n.email)?"opacity-50 cursor-not-allowed":""}`,"aria-label":"Reset password",children:[e.jsx(ee,{className:"h-4 w-4 mr-2"}),_?"Requesting...":"Reset Password"]})})]})]}),x==="plan"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Your Plan"}),W?e.jsxs("div",{className:"text-center text-gray-600",children:[e.jsx("div",{className:"flex justify-center mb-5",children:e.jsx("div",{className:"h-6 w-6 border-4 border-purple-700 border-t-transparent roun
6ded-full animate-[spin_2s_linear_infinite]"})}),e.jsx("p",{children:"Loading plan details..."})]}):j?e.jsx("div",{className:"text-center text-red-600",children:e.jsxs("p",{className:"flex items-center justify-center gap-2",children:[j.includes("Subscription limit reached")&&e.jsxs("svg",{className:"h-5 w-5 text-red-600","aria-label":"Subscription limit exceeded",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"}),e.jsx("path",{d:"M9 7h6M9 17h6"})]}),j,j.includes("Subscription limit reached")&&e.jsxs("span",{className:"text-xs text-red-600 ml-1",children:["Please"," ",e.jsx("a",{href:"/pricing",className:"underline cursor-pointer text-blue-600 hover:text-blue-800",children:"upgrade"})," ","your subscription."]})]})}):o?e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-6",children:o.plan_name}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs md:text-sm rounded-lg shadow-md",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gradient-to-r from-purple-600 to-purple-700 text-white rounded-t-lg",children:[e.jsx("th",{scope:"col",className:"p-2 md:p-4 text-left font-medium rounded-tl-lg",children:"Resource"}),e.jsx("th",{scope:"col",className:"p-2 md:p-4 text-left font-medium hidden sm:table-cell",children:"Limit"}),e.jsx("th",{scope:"col",className:"p-2 md:p-4 text-left font-medium hidden md:table-cell",children:"Used"}),e.jsx("th",{scope:"col",className:"p-2 md:p-4 text-left font-medium rounded-tr-lg",children:"Remaining"})]})}),e.jsx("tbody",{className:"bg-white rounded-b-lg",children:[{name:"Phone Calls",icon:e.jsx(te,{className:"h-5 w-5 text-purple-600"}),tooltip:"Number of call sessions",limit:o.no_of_phone_calls_limit,used:o.no_of_phone_calls_used,balance:o.no_of_phone_calls_balance},{name:"Call Duration",icon:e.jsx(se,{className:"h-5 w-5 text-purple-600"}),tooltip:"Total call duration in minutes and seconds",limit:o.phone_call_seconds_limit,used:o.phone_call_seconds_used,balance:o.phone_call_balance_seconds},{name:"Text Chats",icon:e.jsx(ae,{className:"h-5 w-5 text-purple-600"}),tooltip:"Number of text chat messages",limit:o.text_chat_limit,used:o.text_chat_used,balance:o.text_chat_remaining},{name:"Form Creations",icon:e.jsx(le,{className:"h-5 w-5 text-purple-600"}),tooltip:"Number of forms created",limit:o.form_creations_limit,used:o.form_creations_used,balance:o.form_creations_balance}].map(t=>e.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-gray-50 transition-colors duration-200",children:[e.jsx("td",{className:"p-2 md:p-4 text-gray-700 flex items-center space-x-2",children:e.jsxs(ne,{children:[e.jsx(re,{asChild:!0,children:e.jsxs("span",{className:"flex items-center space-x-2","aria-label":t.tooltip,children:[t.icon,e.jsx("span",{className:"text-xs md:text-sm",children:t.name})]})}),e.jsx(ie,{className:"bg-gray-800 text-white p-2 rounded shadow-lg",children:t.tooltip})]})}),e.jsx("td",{className:"p-2 md:p-4 text-gray-700 hidden sm:table-cell text-xs md:text-sm",children:t.limit==="unlimited"?"Unlimited":t.name==="Call Duration"?P(t.limit):t.limit}),e.jsx("td",{className:"p-2 md:p-4 text-gray-700 hidden md:table-cell",children:t.name==="Call Duration"?P(t.used):t.limit==="unlimited"?t.used:Z(t.used,t.limit)}),e.jsx("td",{className:`p-2 md:p-4 text-xs md:text-sm ${typeof t.balance=="number"&&t.balance<=(typeof t.limit=="number"?t.limit*.1:0)?"text-red-600 font-medium":"text-gray-700"}`,children:t.balance==="unlimited"?"Unlimited":t.name==="Call Duration"?P(t.balance):t.balance})]},t.name))})]})})]}):e.jsx("div",{className:"text-center text-gray-600",children:e.jsx("p",{children:"No plan data available."})})]}),x==="payments"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Subscription Details"}),Y?e.jsxs("div",{className:"text-center text-gray-600",children:[e.jsx("div",{className:"flex justify-center mb-5",children:e.jsx("div",{className:"h-6 w-6 border-4 border-purple-700 border-t-transparent roun
6ded-full animate-[spin_2s_linear_infinite]"})}),e.jsx("p",{children:"Loading subscription details..."})]}):F?e.jsx("div",{className:"text-center text-red-600",children:e.jsxs("p",{className:"flex items-center justify-center gap-2",children:[e.jsx(de,{className:"h-5 w-5 text-red-600"}),F]})}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg mb-6",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-700",children:["Status: ",c.subscription_status||"N/A"]}),e.jsxs("p",{className:"text-sm font-medium text-gray-700",children:["Next Billing: ",N(c.next_billing_at)]}),e.jsxs("p",{className:"text-sm font-medium text-gray-700",children:["Window: ",N(c.window.start)," to ",N(c.window.end)]})]}),c.subscription_status==="ACTIVE"&&e.jsx("button",{onClick:K,className:"px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 focus:ring-2 focus:ring-red-500 focus:ring-offset-2 transition-all duration-200 flex items-center text-sm font-medium shadow-sm mb-6",children:"Cancel Subscription"}),e.jsx("div",{className:"overflow-x-auto -mx-4 md:mx-0",children:e.jsxs("table",{className:"w-full text-xs md:text-sm rounded-lg shadow-md",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gradient-to-r from-purple-600 to-purple-700 text-white rounded-t-lg",children:[e.jsx("th",{className:"p-2 md:p-4 text-left font-medium rounded-tl-lg hidden sm:table-cell",children:"Transaction ID"}),e.jsx("th",{className:"p-2 md:p-4 text-left font-medium",children:"Status"}),e.jsx("th",{className:"p-2 md:p-4 text-left font-medium hidden md:table-cell",children:"Time"}),e.jsx("th",{className:"p-2 md:p-4 text-left font-medium hidden lg:table-cell",children:"Type"}),e.jsx("th",{className:"p-2 md:p-4 text-left font-medium",children:"Amount"}),e.jsx("th",{className:"p-2 md:p-4 text-left font-medium rounded-tr-lg hidden lg:table-cell",children:"Payer Email"})]})}),e.jsx("tbody",{className:"bg-white rounded-b-lg",children:c.transactions.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"p-4 text-center text-gray-600",children:"No transactions found."})}):c.transactions.map((t,s)=>e.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-gray-50 transition-colors duration-200",children:[e.jsx("td",{className:"p-2 md:p-4 text-gray-700 hidden sm:table-cell text-xs md:text-sm truncate",children:t.transaction_id}),e.jsx("td",{className:"p-2 md:p-4 text-gray-700 text-xs md:text-sm",children:e.jsx("span",{className:"bg-green-100 text-green-800 px-2 py-1 rounded text-xs font-medium",children:t.status})}),e.jsx("td",{className:"p-2 md:p-4 text-gray-700 hidden md:table-cell text-xs",children:N(t.time)}),e.jsx("td",{className:"p-2 md:p-4 text-gray-700 hidden lg:table-cell text-xs md:text-sm",children:t.type}),e.jsxs("td",{className:"p-2 md:p-4 text-gray-700 font-semibold text-xs md:text-sm",children:[t.amount.value," ",t.amount.currency_code]}),e.jsx("td",{className:"p-2 md:p-4 text-gray-700 hidden lg:table-cell text-xs truncate",children:t.payer_email})]},s))})]})})]}):e.jsx("div",{className:"text-center text-gray-600",children:e.jsx("p",{children:"No subscription details available."})})]})]})]})]})})};export{je 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.