1import{r as u,cg as ze,e as Y,ch as V,j as e,aT as F,aS as Ue,aN as Re,bY as Ye,bl as Be,ci as Qe,cj as He,ck as Je,B as Ge,U as ie,X as Ve,bm as ne,f as Xe,aV as re,aO as le,bi as Ze,a$ as We,a_ as ea,aZ as aa}from"./vendor-DrFUuVxi.js";import{A as sa}from"./admin-layout-Dy8amNTc.js";import{d as ta,a as L}from"./admin-auth-wzAHMvzc.js";import{u as ia,e as o,D as de,m as na,n as ce,o as me,p as oe,L as x,I as h,C as pe,a as ra,b as la,B as K,d as ue,q as he,r as xe,s as B,t as j,v as ge,w as l,x as O}from"./ec2-main-entry-4Im2GDR0.js";const da=[{key:"memberid",label:"ID",width:"w-14"},{key:"name",label:"Name",width:"w-36"},{key:"email",label:"Email",width:""},{key:"membership",label:"Membership",width:"w-32"},{key:"is_paid",label:"Paid",width:"w-16"},{key:"lastlogin",label:"Last Login",width:"w-24"},{key:"expire_at",label:"Expires",width:"w-24"},{key:"created",label:"Created",width:"w-24"}];function $(t){if(!t)return"â";try{const r=new Date(t);return isNaN(r.getTime())?t:r.toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}catch{return t}}function be(t){return t.paypal_use_agreement?"PayPal":t.plan_type?t.plan_type:t.membership==="lifetime"||t.membership==="membership-lifetime"||t.paypal_product==="lifetime"?"Lifetime":t.membership==="one-year-only"?"Annual":t.membership==="one-monthly-only"?"Monthly":"Manual"}function S({label:t,count:r,icon:g,category:N,active:M,color:U,onClick:k}){return e.jsxs("button",{onClick:()=>k(N),"data-testid":`card-summary-${N}`,className:`text-left w-full rounded-lg border p-4 transition-all hover:shadow-md focus:outline-none ${M?"ring-2 ring-offset-1 shadow-md "+U:"bg-card hover:bg-accent/30"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-muted-foreground",children:g}),e.jsx("span",{className:"text-2xl font-bold","data-testid":`count-${N}`,children:r.toLocaleString()})]}),e.jsx("p",{className:"text-sm font-medium leading-tight",children:t})]})}const z={namefirst:"",namelast:"",email:"",plan_type:"",membership:"",is_paid:!1,unlimited_rep:!1,isapproved:!0,expire_at:"",paid_at:"",loginpwd:""};function je(t){if(!t)return"";const r=new Date(t);if(isNaN(r.getTime()))return"";const g=r.getFullYear(),N=String(r.getMonth()+1).padStart(2,"0"),M=String(r.getDate()).padStart(2,"0");return`${g}-${N}-${M}`}function ua(){const[t,r]=u.useState(1),[g,N]=u.useState(""),[M,U]=u.useState(""),[k,ye]=u.useState("memberid"),[q,X]=u.useState("desc"),[d,fe]=u.useState("all"),[ve,Q]=u.useState(!1),[c,P]=u.useState({namefirst:"",namelast:"",email:"",loginpwd:"",confirmpwd:"",expire_at:""}),[E,R]=u.useState(null),[s,m]=u.useState(z),{toast:b}=ia(),[C,T]=u.useState(new Set),[we,H]=u.useState(!1),[Z,W]=u.useState(!1);async function Ne(){W(!0);try{const a=g?`?search=${encodeURIComponent(g)}`:"";await ta(`/api/admin/members/export${a}`,`members-${new Date().toISOString().slice(0,10)}.csv`)}catch(a){b({title:"Export failed",description:a?.message,variant:"destructive"})}finally{W(!1)}}const _=ze(),{data:Ce,isLoading:_e}=Y({queryKey:["/api/admin/members",E],queryFn:async()=>{const a=await L(`/api/admin/members/${E}`);if(!a.ok)throw new Error("Failed to load member");return a.json()},enabled:E!==null}),n=Ce?.member;u.useEffect(()=>{n&&n.memberid===E&&m({namefirst:n.namefirst||"",namelast:n.namelast||"",email:n.email||"",plan_type:n.plan_type||"",membership:n.membership||"",is_paid:!!n.is_paid,unlimited_rep:!!n.unlimited_rep,isapproved:!!n.isapproved,expire_at:je(n.expire_at),paid_at:je(n.paid_at),loginpwd:""})},[n,E]);const J=V({mutationFn:async a=>{const i=await L(`/api/admin/members/${E}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok){const p=await i.json().catch(()=>({}));throw new Error(p.error||"Failed to update member")}return i.json()},onSuccess:()=>{b({title:"Member updated"}),R(null),m(z),_.invalidateQueries({queryKey:["/api/admin/members"]}),_.invalidateQueries({queryKey:["/api/paypal/members-category"]}),_.invalidateQueries({queryKey:["/api/paypal/members-summary"]})},onError:a=>b({title:"Error",description:a.message,variant:"destructive"})});function ee(a){m(z),R(a)}function Se(a){if(a.preventDefault(),s.loginpwd&&s.loginpwd.length<6){b({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}const i={namefirst:s.namefirst,namelast:s.namelast,email:s.email,plan_type:s.plan_type,membership:s.membership,is_paid:s.is_paid,unlimited_rep:s.unlimited_rep,isapproved:s.isapproved,expire_at:s.expire_at,paid_at:s.paid_at};s.loginpwd&&(i.loginpwd=s.loginpwd),J.mutate(i)}const{data:y,isLoading:ke}=Y({queryKey:["/api/paypal/members-summary"],queryFn:async()=>{const a=await L("/api/paypal/members-summary");if(!a.ok)throw new Error("Failed to fetch summary");return a.json()},staleTime:6e4}),f=d==="yoursites",{data:Pe,isLoading:Ee}=Y({queryKey:["/api/admin/members",t,g,k,q,d],queryFn:async()=>{const a=new URLSearchParams({page:String(t),sort:k,dir:q});g&&a.set("search",g);let i=`/api/admin/members?${a}`;d!=="all"&&d!=="yoursites"&&(a.set("category",d),i=`/api/paypal/members-category?${a}`);const p=await L(i);if(!p.ok)throw new Error("Failed to fetch members");return p.json()},enabled:!f}),{data:De,isLoading:Fe}=Y({queryKey:["/api/paypal/yoursites-accounts",t,g],queryFn:async()=>{const a=new URLSearchParams({page:String(t)});g&&a.set("search",g);const i=await L(`/api/paypal/yoursites-accounts?${a}`);if(!i.ok)throw new Error("Failed to fetch YourSites accounts");return i.json()},enabled:f}),Le=f?Fe:Ee,v=f?null:Pe,D=f?De:null,G=V({mutationFn:async a=>{const i=await L("/api/admin/members",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({namefirst:a.namefirst,namelast:a.namelast,email:a.email,loginpwd:a.loginpwd,expire_at:a.expire_at||null})});if(!i.ok){const p=await i.json();throw new Error(p.error||"Failed to create member")}return i.json()},onSuccess:()=>{b({title:"Member created successfully"}),Q(!1),P({namefirst:"",namelast:"",email:"",loginpwd:"",confirmpwd:"",expire_at:""}
1),_.invalidateQueries({queryKey:["/api/admin/members"]}),_.invalidateQueries({queryKey:["/api/admin/members-summary"]})},onError:a=>b({title:"Error",description:a.message,variant:"destructive"})}),A=V({mutationFn:async a=>{const i=await L("/api/admin/members/delete-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:a})});if(!i.ok){const p=await i.text();let te=p;try{te=JSON.parse(p).error||p}catch{}throw new Error(te.substring(0,200))}return i.json()},onSuccess:a=>{b({title:`Deleted ${a.deleted.toLocaleString()} member(s)`}),T(new Set),H(!1),_.invalidateQueries({queryKey:["/api/admin/members"]}),_.invalidateQueries({queryKey:["/api/paypal/members-summary"]}),_.invalidateQueries({queryKey:["/api/paypal/members-category"]})},onError:a=>b({title:"Delete failed",description:a?.message,variant:"destructive"})});u.useEffect(()=>{T(new Set)},[t,g,k,q,d]);const I=v?.rows??[];function $e(a){T(i=>{const p=new Set(i);return p.has(a)?p.delete(a):p.add(a),p})}function Me(){I.length>0&&I.every(a=>C.has(a.memberid))?T(new Set):T(new Set(I.map(a=>a.memberid)))}const qe=I.length>0&&I.every(a=>C.has(a.memberid)),Te=C.size>0;function Ae(a){a.preventDefault(),r(1),N(M)}function Ie(a){k===a?X(q==="asc"?"desc":"asc"):(ye(a),X("desc")),r(1)}function w(a){fe(i=>i===a?"all":a),r(1),N(""),U("")}function Ke(a){if(a.preventDefault(),c.loginpwd.length<6){b({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(c.loginpwd!==c.confirmpwd){b({title:"Error",description:"Passwords do not match",variant:"destructive"});return}G.mutate(c)}function Oe({col:a}){return k!==a?e.jsx(We,{className:"w-3 h-3 ml-1 opacity-30"}):q==="asc"?e.jsx(ea,{className:"w-3 h-3 ml-1"}):e.jsx(aa,{className:"w-3 h-3 ml-1"})}const ae={all:"All Members",paypal:"PayPal Active",plan:"Plan Subscribers",lifetime:"Lifetime",manual:"Admin-Created",inactive:"Inactive",yoursites:"YourSites Accounts"},se=f?D:v;return e.jsx(sa,{children:e.jsxs("div",{"data-testid":"admin-members-page",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold","data-testid":"text-members-title",children:"Members"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(o,{variant:"outline",onClick:Ne,disabled:Z,"data-testid":"button-export-members",children:[Z?e.jsx(F,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Export CSV"]}),e.jsxs(de,{open:ve,onOpenChange:Q,children:[e.jsx(na,{asChild:!0,children:e.jsxs(o,{"data-testid":"button-new-member",children:[e.jsx(Re,{className:"w-4 h-4 mr-2"}),"New Member"]})}),e.jsxs(ce,{children:[e.jsx(me,{children:e.jsx(oe,{children:"Create New Member"})}),e.jsxs("form",{onSubmit:Ke,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"namefirst",children:"First Name"}),e.jsx(h,{id:"namefirst",value:c.namefirst,onChange:a=>P({...c,namefirst:a.target.value}),required:!0,"data-testid":"input-new-member-firstname"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"namelast",children:"Last Name"}),e.jsx(h,{id:"namelast",value:c.namelast,onChange:a=>P({...c,namelast:a.target.value}),required:!0,"data-testid":"input-new-member-lastname"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"email",children:"Email"}),e.jsx(h,{id:"email",type:"email",value:c.email,onChange:a=>P({...c,email:a.target.value}),required:!0,"data-testid":"input-new-member-email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(x,{htmlFor:"loginpwd",children:["Password ",e.jsx("span",{className:"text-muted-foreground text-sm",children:"(min 6 chars)"})]}),e.jsx(h,{id:"loginpwd",type:"password",value:c.loginpwd,onChange:a=>P({...c,loginpwd:a.target.value}),required:!0,minLength:6,"data-testid":"input-new-member-password"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"confirmpwd",children:"Confirm Password"}),e.jsx(h,{id:"confirmpwd",type:"password",value:c.confirmpwd,onChange:a=>P({...c,confirmpwd:a.target.value}),required:!0,minLength:6,"data-testid":"input-new-member-confirmpwd"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"expire_at",children:"Membership Expires"}),e.jsx(h,{id:"expire_at",type:"date",value:c.expire_at,onChange:a=>P({...c,expire_at:a.target.value}),"data-testid":"input-new-member-expires"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(o,{type:"button",variant:"outline",onClick:()=>Q(!1),"data-testid":"button-cancel-member",children:"Cancel"}),e.jsxs(o,{type:"submit",disabled:G.isPending,"data-testid":"button-submit-member",children:[G.isPending&&e.jsx(F,{className:"w-4 h-4 mr-2 animate-spin"}),"Save Changes"]})]})]})]})]})]})]}),ke?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-6",children:[e.jsx(F,{className:"w-4 h-4 animate-spin"})," Loading summary..."]}):y&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-3 mb-6","data-testid":"summary-cards",children:[e.jsx(S,{label:"PayPal Active",count:y.paypal_active,icon:e.jsx(Ye,{className:"w-4 h-4"}),category:"paypal",active:d==="paypal",color:"ring-blue-500 bg-blue-50 dark:bg-blue-950/30",onClick:w}),e.jsx(S,{label:"Plan Subscribers",count:y.plan_active,icon:e.jsx(Be,{className:"w-4 h-4"}),category:"plan",active:d==="plan",color:"ring-purple-500 bg-purple-50 dark:bg-purple-950/30",onClick:w}),e.jsx(S,{label:"Lifetime",count:y.lifetime,icon:e.jsx(Qe,{className:"w-4 h-4"}),category:"lifetime",active:d==="lifetime",color:"ring-yellow-500 bg-yellow-50 dark:bg-yellow-950/30",onClick:w}),e.jsx(S,{label:"Admin-Created",count:y.manual_active,icon:e.jsx(He,{className:"w-4 h-4"}),category:"manual",active:d==="manual",color:"ring-green-500 bg-green-50 dark:bg-green-950/30",onClick:w}),e.jsx(S,{label:"Inactive",count:y.inactive,icon:e.jsx(Je,{className:"w-4 h-4"}),category:"inactive",active:d==="inactive",color:"ring-red-500 bg-red-50 dark:bg-red-950/30",onClick:w}),e.jsx(S,{label:"YourSites Accounts",count:y.yoursites_accounts,icon:e.jsx(Ge,{className:"w-4 h-4"}),category:"yoursites",active:d==="yoursites",color:"ring-orange-500 bg-orange-50 dark:bg-orange-950/30",onClick:w}),e.jsx(S,{label:"YourSites Users",count:y.yoursites_users,icon:e.jsx(ie,{className:"w-4 h-4"}),category:"yoursites",active:!1,color:"ring-orange-400 bg-orange-50 dark:bg-orange-950/30",onClick:w}),e.jsx(S,{label:"Total Members",count:y.total,icon:e.jsx(ie,{className:"w-4 h-4"}),category:"all",active:d==="all",color:"ring-gray-500 bg-gray-50 dark:bg-gray-900/30",onClick:w})]}),e.jsxs(pe,{children:[e.jsxs(ra,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(la,{className:"text-lg","data-testid":"text-members-count",children:se?`${se.total.toLocaleStr
1ing()} ${ae[d]}`:ae[d]}),d!=="all"&&e.jsxs(o,{variant:"ghost",size:"sm",onClick:()=>w("all"),"data-testid":"button-clear-filter",className:"h-6 px-2 text-xs text-muted-foreground",children:[e.jsx(Ve,{className:"w-3 h-3 mr-1"})," Clear filter"]}),!f&&Te&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"secondary","data-testid":"badge-selected-count",children:[C.size," selected"]}),e.jsxs(o,{variant:"destructive",size:"sm",onClick:()=>H(!0),disabled:A.isPending,"data-testid":"button-delete-selected",children:[e.jsx(ne,{className:"w-4 h-4 mr-1"}),"Delete selected"]})]})]}),e.jsxs("form",{onSubmit:Ae,className:"flex items-center gap-2",children:[e.jsx(h,{placeholder:"Search name or email...",value:M,onChange:a=>U(a.target.value),className:"w-56","data-testid":"input-members-search"}),e.jsx(o,{type:"submit",size:"icon",variant:"outline","data-testid":"button-members-search",children:e.jsx(Xe,{})})]})]}),e.jsx(ue,{children:Le?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(F,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):f&&D?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(he,{"data-testid":"table-yoursites",children:[e.jsx(xe,{children:e.jsxs(B,{children:[e.jsx(j,{children:"ID"}),e.jsx(j,{children:"Account Name"}),e.jsx(j,{children:"Email"}),e.jsx(j,{children:"Stores"}),e.jsx(j,{children:"Sub-users"}),e.jsx(j,{children:"Created"})]})}),e.jsx(ge,{children:D.rows.map(a=>e.jsxs(B,{"data-testid":`row-ys-${a.account_id}`,children:[e.jsx(l,{className:"font-mono text-xs",children:a.account_id}),e.jsx(l,{className:"font-medium",children:a.name||"â"}),e.jsx(l,{className:"text-xs",children:a.email||"â"}),e.jsx(l,{children:e.jsx(K,{variant:"secondary",children:a.store_count.toLocaleString()})}),e.jsx(l,{children:a.user_count}),e.jsx(l,{className:"text-xs whitespace-nowrap",children:$(a.created_at)})]},a.account_id))})]})}),D.pages>1&&e.jsxs("div",{className:"flex items-center justify-between gap-2 mt-4 pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",D.page," of ",D.pages]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(o,{variant:"outline",size:"sm",disabled:t<=1,onClick:()=>r(a=>Math.max(1,a-1)),"data-testid":"button-members-prev",children:[e.jsx(re,{className:"w-4 h-4"}),"Prev"]}),e.jsxs(o,{variant:"outline",size:"sm",disabled:t>=D.pages,onClick:()=>r(a=>a+1),"data-testid":"button-members-next",children:["Next",e.jsx(le,{className:"w-4 h-4"})]})]})]})]}):v&&v.rows.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsxs(he,{"data-testid":"table-members",className:"table-fixed w-full [&_th]:px-2 [&_th]:h-10 [&_td]:px-2 [&_td]:py-2",children:[e.jsx(xe,{children:e.jsxs(B,{children:[e.jsx(j,{className:"w-10",children:e.jsx(O,{checked:qe,onCheckedChange:Me,"data-testid":"checkbox-select-all"})}),da.map(a=>e.jsx(j,{className:a.width,children:e.jsxs("button",{onClick:()=>Ie(a.key),className:"flex items-center hover:text-foreground transition-colors font-medium max-w-full","data-testid":`sort-${a.key}`,children:[e.jsx("span",{className:"truncate",children:a.label}),e.jsx(Oe,{col:a.key})]})},a.key)),e.jsx(j,{className:"w-24",children:"Method"}),e.jsx(j,{className:"w-12"})]})}),e.jsx(ge,{children:v.rows.map(a=>e.jsxs(B,{"data-testid":`row-member-${a.memberid}`,className:"cursor-pointer hover:bg-accent/40",onClick:()=>ee(a.memberid),children:[e.jsx(l,{onClick:i=>i.stopPropagation(),children:e.jsx(O,{checked:C.has(a.memberid),onCheckedChange:()=>$e(a.memberid),"data-testid":`checkbox-select-${a.memberid}`})}),e.jsx(l,{className:"font-mono text-xs",children:a.memberid}),e.jsxs(l,{className:"truncate",title:`${a.namefirst} ${a.namelast}`,children:[a.namefirst," ",a.namelast]}),e.jsx(l,{className:"text-xs truncate",title:a.email,children:a.email}),e.jsx(l,{className:"text-xs truncate",title:a.membership||"",children:a.membership||"â"}),e.jsx(l,{children:a.is_paid?e.jsx(K,{variant:"default","data-testid":`badge-paid-${a.memberid}`,children:"Yes"}):e.jsx(K,{variant:"destructive","data-testid":`badge-paid-${a.memberid}`,children:"No"})}),e.jsx(l,{className:"text-xs whitespace-nowrap",children:$(a.lastlogin)}),e.jsx(l,{className:"text-xs whitespace-nowrap",children:$(a.expire_at)}),e.jsx(l,{className:"text-xs whitespace-nowrap",children:$(a.created)}),e.jsx(l,{children:e.jsx(K,{variant:"outline",className:"text-xs whitespace-nowrap","data-testid":`badge-method-${a.memberid}`,children:be(a)})}),e.jsx(l,{children:e.jsx(o,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:i=>{i.stopPropagation(),ee(a.memberid)},"data-testid":`button-edit-${a.memberid}`,title:"Edit member",children:e.jsx(Ze,{className:"w-3.5 h-3.5"})})})]},a.memberid))})]})}),v.pages>1&&e.jsxs("div",{className:"flex items-center justify-between gap-2 mt-4 pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground","data-testid":"text-members-page-info",children:["Page ",v.page," of ",v.pages]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(o,{variant:"outline",size:"sm",disabled:t<=1,onClick:()=>r(a=>Math.max(1,a-1)),"data-testid":"button-members-prev",children:[e.jsx(re,{className:"w-4 h-4"}),"Prev"]}),e.jsxs(o,{variant:"outline",size:"sm",disabled:t>=v.pages,onClick:()=>r(a=>a+1),"data-testid":"button-members-next",children:["Next",e.jsx(le,{className:"w-4 h-4"})]})]})]})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8","data-testid":"text-members-empty",children:"No members found."})})]}),e.jsx(de,{open:E!==null,onOpenChange:a=>{a||(R(null),m(z))},children:e.jsxs(ce,{className:"max-w-2xl max-h-[90vh] overflow-y-auto","data-testid":"dialog-edit-member",children:[e.jsx(me,{children:e.jsxs(oe,{children:["Edit Member ",n?`#${n.memberid}`:""]})}),_e||!n?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(F,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):e.jsxs("form",{onSubmit:Se,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"e_first",children:"First name"}),e.jsx(h,{id:"e_first",value:s.namefirst,onChange:a=>m({...s,namefirst:a.target.value}),required:!0,maxLength:30,"data-testid":"input-edit-firstname"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"e_last",children:"Last name"}),e.jsx(h,{id:"e_last",value:s.namelast,onChange:a=>m({...s,namelast:a.target.value}),required:!0,maxLength:30,"data-testid":"input-edit-lastname"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"e_email",children:"Email"}),e.jsx(h,{id:"e_email",type:"email",value:s.email,onChange:a=>m({...s,email:a.target.value}),required:!0,"data-testid":"input-edit-email"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"e_plan",children:"Plan type"}
1),e.jsx(h,{id:"e_plan",value:s.plan_type,onChange:a=>m({...s,plan_type:a.target.value}),placeholder:"e.g. monthly, annual, lifetime","data-testid":"input-edit-plan"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"e_membership",children:"Membership"}),e.jsx(h,{id:"e_membership",value:s.membership,onChange:a=>m({...s,membership:a.target.value}),placeholder:"e.g. one-monthly-only, lifetime","data-testid":"input-edit-membership"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"e_expire",children:"Expires on"}),e.jsx(h,{id:"e_expire",type:"date",value:s.expire_at,onChange:a=>m({...s,expire_at:a.target.value}),"data-testid":"input-edit-expire"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{htmlFor:"e_paid",children:"Paid on"}),e.jsx(h,{id:"e_paid",type:"date",value:s.paid_at,onChange:a=>m({...s,paid_at:a.target.value}),"data-testid":"input-edit-paid-at"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 p-3 bg-muted/40 rounded-md border",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(O,{checked:s.is_paid,onCheckedChange:a=>m({...s,is_paid:!!a}),"data-testid":"check-edit-is-paid"}),e.jsx("span",{className:"text-sm",children:"Paid"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(O,{checked:s.unlimited_rep,onCheckedChange:a=>m({...s,unlimited_rep:!!a}),"data-testid":"check-edit-unlimited"}),e.jsx("span",{className:"text-sm",children:"Unlimited reports"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(O,{checked:s.isapproved,onCheckedChange:a=>m({...s,isapproved:!!a}),"data-testid":"check-edit-approved"}),e.jsx("span",{className:"text-sm",children:"Approved"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(x,{htmlFor:"e_pwd",children:["Reset password ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(leave blank to keep current)"})]}),e.jsx(h,{id:"e_pwd",type:"password",value:s.loginpwd,onChange:a=>m({...s,loginpwd:a.target.value}),placeholder:"New password (min 6 chars)","data-testid":"input-edit-password"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground border-t pt-3 grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Created:"})," ",$(n.created)]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Last login:"})," ",$(n.lastlogin)]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Modified:"})," ",$(n.modified)]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Payment:"})," ",be(n)]}),n.paypal_agreement_id?e.jsxs("div",{className:"col-span-2 truncate",children:[e.jsx("span",{className:"font-medium",children:"PayPal agreement:"})," ",e.jsx("span",{className:"font-mono text-[11px]",children:n.paypal_agreement_id})]}):null]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t",children:[e.jsx(o,{type:"button",variant:"outline",onClick:()=>{R(null),m(z)},"data-testid":"button-edit-cancel",children:"Cancel"}),e.jsxs(o,{type:"submit",disabled:J.isPending,"data-testid":"button-edit-save",children:[J.isPending&&e.jsx(F,{className:"w-4 h-4 mr-2 animate-spin"}),"Save changes"]})]})]})]})}),we&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 flex items-center justify-center p-4","data-testid":"modal-delete-confirm",children:e.jsx(pe,{className:"max-w-md w-full",children:e.jsxs(ue,{className:"p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Confirm deletion"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You are about to delete ",e.jsx("strong",{children:C.size})," member(s). They will be removed from your members list. This does not cancel any active Stripe or PayPal subscriptions."]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(o,{variant:"outline",onClick:()=>H(!1),disabled:A.isPending,"data-testid":"button-cancel-delete",children:"Cancel"}),e.jsx(o,{variant:"destructive",onClick:()=>A.mutate(Array.from(C)),disabled:A.isPending,"data-testid":"button-confirm-delete",children:A.isPending?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"w-4 h-4 mr-1 animate-spin"})," Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 mr-1"})," Delete ",C.size," member(s)"]})})]})]})})})]})})}export{ua 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.