1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2014,9519],{49558:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>o});var a=s(37876),r=s(14232),i=s(89099),l=s(98467),n=s(20485),d=s(50580);function o(e){let{skipTotpCheck:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(s){let o=(0,i.useRouter)(),[c,m]=(0,r.useState)(!0),[x,u]=(0,r.useState)(!1),[h,p]=(0,r.useState)(!1),[g,b]=(0,r.useState)(!1),[f,y]=(0,r.useState)(!1);return((0,r.useEffect)(()=>{let e=async()=>{let e=l.auth.currentUser;if(!e)return void o.push("/");let s=(await (0,n.getDoc)((0,n.doc)(l.db,"users",e.uid))).data();if(s?.role!=="admin")return void o.push("/");if(u(!0),t)return void m(!1);if(s?.totpEnabled)sessionStorage.getItem("admin_totp_verified")===e.uid?b(!0):p(!0);else{y(!0),o.push("/admin/security");return}m(!1)};l.auth.onAuthStateChanged(()=>e())},[]),c)?(0,a.jsx)("p",{className:"text-center mt-10",children:"Loading admin access..."}):x?h&&!g?(0,a.jsx)(d.A,{userType:"admin",onSuccess:()=>{let e=l.auth.currentUser;e&&sessionStorage.setItem("admin_totp_verified",e.uid),p(!1),b(!0)},onCancel:()=>{l.auth.signOut(),o.push("/")}}):(0,a.jsx)(e,{...s}):null}}},54554:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>c});var a=s(37876),r=s(14232),i=s(98467),l=s(20485),n=s(49558),d=s(81250);let o="[email protected]",c=(0,n.default)(function(){let[e,t]=(0,r.useState)(0),[s,n]=(0,r.useState)([]),[c,m]=(0,r.useState)(!0),[x,u]=(0,r.useState)({userLookup:"",amount:"10",expiryDays:"60",sendEmail:!0}),[h,p]=(0,r.useState)(!1);async function g(){m(!0);try{let e=await b(),s=e?.balance||0;t(s>100?s/100:s);let a=(0,l.collectionGroup)(i.db,"credits"),r=(0,l.query)(a,(0,l.orderBy)("grantedAt","desc"),(0,l.limit)(50)),d=await (0,l.getDocs)(r),o=new Set;d.docs.forEach(e=>{let t=e.ref.parent.parent?.id;t&&o.add(t)});let c=await Promise.all(Array.from(o).map(e=>(0,l.getDoc)((0,l.doc)(i.db,"users",e)))),m={};
1c.forEach(e=>{e.exists()&&(m[e.id]=e.data())});let x=d.docs.map(e=>{let t=e.data(),s=e.ref.parent.parent?.id,a=s?m[s]:{},r=a?.balance||0;return{id:e.id,userId:s||"unknown",userEmail:a?.email||"Unknown",userName:a?.displayName||a?.email||"Unknown",userBalance:r>100?r/100:r,amount:t.amount||0,type:t.type||"unknown",status:t.status||"active",grantedAt:t.grantedAt?.toDate?.()||null,expiresAt:t.expiresAt?.toDate?.()||null}});n(x)}catch(e){console.error("Error loading credits:",e),alert("Error loading credits: "+e.message)}finally{m(!1)}}async function b(){let e=(0,l.query)((0,l.collection)(i.db,"users"),(0,l.where)("email","==",o)),t=await (0,l.getDocs)(e);return t.empty?null:{id:t.docs[0].id,...t.docs[0].data()}}async function f(){let e=String(x.userLookup||"").trim();if(!e)return void alert("Enter a user email or UID.");let t=Number(x.amount);if(!Number.isFinite(t)||t<=0)return void alert("Enter a valid amount (> 0).");let s=Number(x.expiryDays);if(!Number.isFinite(s)||s<=0)return void alert("Enter a valid expiry (days).");let a=e;if(e.includes("@"))try{let t=await (0,l.getDocs)((0,l.query)((0,l.collection)(i.db,"users"),(0,l.where)("email","==",e.toLowerCase())));if(t.empty)return void alert(`No user found with email ${e}.`);a=t.docs[0].id}catch(e){alert("Email lookup failed: "+e.message);return}if(confirm(`Grant $${t.toFixed(2)} signup bonus to ${e}? 2 3This will: 4- Deduct $${t.toFixed(2)} from ${o} 5- Add $${t.toFixed(2)} to the user's balance 6- Create a welcome_bonus credit (expires in ${s} days)${x.sendEmail?"\n- Email the user":""}`)){p(!0);try{let r=await fetch("/api/admin/grant-credit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:a,creditAmount:t,expiryDays:s,sendEmail:!!x.sendEmail})}),i=await r.json();if(!r.ok)throw Error(i.error||"Failed to grant bonus");alert(`Signup bonus granted. 7 8User: ${e} 9Amount: $${t.toFixed(2)} 10Expires in: ${s} days`),u({userLookup:"",amount:"10",expiryDays:"60",sendEmail:!0}),g()}catch(e){console.error("Grant failed:",e),alert("Error: "+e.message)}finally{p(!1)}}}return(0,r.useEffect)(()=>{g()},[]),(0,a.jsx)(d.default,{children:(0,a.jsxs)("div",{className:"container mx-auto px-4 py-8",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,a.jsx)("h1",{className:"text-3xl font-bold",children:"Member Credits"}),(0,a.jsx)("button",{onClick:g,className:"px-4 py-2 bg-purple-600 text-white rounded hover:bg-purple-700",children:"Refresh"})]}),(0,a.jsxs)("div",{className:"bg-gradient-to-r from-purple-500 to-indigo-600 text-white p-6 rounded-lg shadow-lg mb-6",children:[(0,a.jsxs)("h2",{className:"text-xl font-semibold mb-2",children:["Platform Account (",o,")"]}),(0,a.jsxs)("p",{className:"text-4xl font-bold",children:["$",e.toFixed(2)]}),(0,a.jsx)("p",{className:"text-sm opacity-90 mt-2",children:"Signup bonuses are deducted from this account."})]}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg shadow p-6 mb-6",children:[(0,a.jsx)("h2",{className:"text-xl font-semibold mb-1",children:"Grant Signup Bonus"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:"Adds funds directly to a user's balance so they can start a session with a maven. Deducted from the platform account."}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-3 items-end",children:[(0,a.jsxs)("div",{className:"md:col-span-5",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"User email or UID"}),(0,a.jsx)("input",{type:"text",value:x.userLookup,onChange:e=>u({...x,userLookup:e.target.value}),placeholder:"[email protected]",className:"w-full border border-gray-300 rounded px-3 py-2 text-sm",disabled:h})]}),(0,a.jsxs)("div",{className:"md:col-span-2",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"Amount ($)"}),(0,a.jsx)("input",{type:"number",min:"1",step:"1",value:x.amount,onChange:e=>u({...x,amount:e.target.value}),className:"w-full border border-gray-300 rounded px-3 py-2 text-sm",disabled:h})]}),(0,a.jsxs)("div",{className:"md:col-span-2",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:"Expires (days)"}),(0,a.jsx)("input",{type:"number",min:"1",step:"1",value:x.expiryDays,onChange:e=>u({...x,expiryDays:e.target.value}),className:"w-full border border-gray-300 rounded px-3 py-2 text-sm",disabled:h})]}),(0,a.jsxs)("div",{className:"md:col-span-2 flex items-center gap-2 pb-1",children:[(0,a.jsx)("input",{id:"sendEmailToggle",type:"checkbox",checked:x.sendEmail,onChange:e=>u({...x,sendEmail:e.target.checked}),disabled:h}),(0,a.jsx)("label",{htmlFor:"sendEmailToggle",className:"text-sm text-gray-700",children:"Send email"})]}),(0,a.jsx)("div",{className:"md:col-span-1",children:(0,a.jsx)("button",{onClick:f,disabled:h,className:"w-full px-4 py-2 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50",children:h?"Grantingâ¦":"Grant"})})]})]}),c?(0,a.jsx)("div",{className:"text-center py-8",children:"Loading creditsâ¦"}):(0,a.jsxs)("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:[(0,a.jsx)("div",{className:"px-6 py-3 bg-gray-50 border-b",children:(0,a.jsx)("h3",{className:"text-sm font-semibold text-gray-700",children:"Recent
10Credits (last 50)"})}),(0,a.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"User"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Amount"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Type"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Status"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Granted"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Days Left"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"User Balance"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:s.map(e=>{var t;let s=(t=e.expiresAt)?Math.floor((t-new Date)/864e5):null,r="expired"===e.status||null!==s&&s<0;return(0,a.jsxs)("tr",{className:r?"bg-red-50":"",children:[(0,a.jsxs)("td",{className:"px-6 py-4 whitespace-nowrap",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-900",children:e.userEmail}),(0,a.jsx)("div",{className:"text-xs text-gray-500",children:e.userName})]}),(0,a.jsxs)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-semibold text-gray-900",children:["$",(e.amount||0).toFixed(2)]}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-xs text-gray-600",children:e.type}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,a.jsx)("span",{className:`px-2 py-1 text-xs font-medium rounded ${"active"===e.status?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:e.status})}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:e.grantedAt?.toLocaleDateString()||"-"}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:null!==s?(0,a.jsx)("span",{className:`text-sm font-medium ${s<0?"text-red-600":s<=7?"text-orange-600":"text-green-600"}`,children:s<0?`${Math.abs(s)} days ago`:`${s} days`}):"-"}),(0,a.jsxs)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-semibold",children:["$",(e.userBalance||0).toFixed(2)]})]},`${e.userId}-${e.id}`)})})]}),0===s.length&&(0,a.jsx)("div",{className:"text-center py-12 text-gray-500",children:"No credits yet."})]})]})})})},59652:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/credits",function(){return s(54554)}])},81250:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>S});var a=s(37876),r=s(48230),i=s.n(r),l=s(89099),n=s(93889),d=s(98467),o=s(14232),c=s(63906),m=s(28249),x=s(66762),u=s(73305),h=s(21355),p=s(97433),g=s(83981),b=s(54893),f=s(9498),y=s(27011),j=s(79247),N=s(29998),v=s(36414),w=s(68425),A=s(71742),k=s(50276),C=s(54410),E=s(15818);function S(e){let{children:t}=e,s=(0,l.useRouter)(),[r,i]=(0,o.useState)(!1),[S,L]=(0,o.useState)(!1);(0,o.useEffect)(()=>{L(!1)},[s.pathname]),(0,o.useEffect)(()=>{let e=e=>{!S||e.target.closest(".mobile-menu")||e.target.closest(".hamburger-btn")||L(!1)};return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[S]);let D=async()=>{if(!r)try{i(!0),await (0,n.CI)(d.auth),s.push("/")}catch(e){console.error("â Logout error:",e),alert("Failed to logout. Please try again.")}finally{i(!1)}};return(0,a.jsxs)("div",{className:"flex min-h-screen bg-gray-100",children:[(0,a.jsx)("div",{className:"lg:hidden fixed top-0 left-0 right-0 bg-white shadow-lg z-50",children:(0,a.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,a.jsxs)("h1",{className:"text-lg font-bold text-gray-800 flex items-center",children:[(0,a.jsx)(c.A,{className:"w-5 h-5 mr-2"}),"Admin Panel"]}),(0,a.jsx)("button",{className:"hamburger-btn p-2 rounded-lg hover:bg-gray-100 transition-colors",onClick:()=>L(!S),children:S?(0,a.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}):(0,a.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})]})}),S&&(0,a.jsx)("div",{className:"lg:hidden fixed inset-0 bg-black bg-opacity-50 z-40",onClick:()=>L(!1)}),(0,a.jsxs)("aside",{className:` 11 mobile-menu 12 fixed lg:static 13 w-64 bg-white shadow-lg 14 h-full lg:h-auto 15 z-50 lg:z-auto 16 transition-transform duration-300 ease-in-out 17 ${S?"translate-x-0":"-translate-x-full lg:translate-x-0"} 18 `,children:[(0,a.jsx)("div",{className:"hidden lg:block p-6 border-b border-gray-200",children:(0,a.jsxs)("h1",{className:"text-xl font-bold text-gray-800 flex items-center",children:[(0,a.jsx)(c.A,{className:"w-6 h-6 mr-2"}),"Admin Panel"]})}),(0,a.jsxs)("div",{className:"lg:hidden p-4 border-b border-gray-200 flex items-center justify-between",children:[(0,a.jsxs)("h1",{className:"text-lg font-bold text-gray-800 flex items-center",children:[(0,a.jsx)(c.A,{className:"w-5 h-5 mr-2"}),"Admin Menu"]}),(0,a.jsx)("button",{onClick:()=>L(!1),className:"p-2 rounded-lg hover:bg-gray-100 transition-colors",children:(0,a.jsx)(m.A,{className:"w-5 h-5"})})]}),(0,a.jsxs)("nav",{className:"p-4 space-y-2",children:[(0,a.jsx)($,{href:"/admin/dashboard",icon:(0,a.jsx)(x.A,{className:"w-5 h-5"}),label:"Dashboard",isActive:"/admin/dashboard"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/live-calls",icon:(0,a.jsx)(u.A,{className:"w-5 h-5"}),label:"Live Call Monitor",isActive:"/admin/live-calls"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/testimonials",icon:(0,a.jsx)(h.A,{className:"w-5 h-5"}),label:"Testimonials",isActive:"/admin/testimonials"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/experts",icon:(0,a.jsx)(p.A,{className:"w-5 h-5"}),label:"Mavens",isActive:"/admin/experts"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/expert-approvals",icon:(0,a.jsx)(g.A,{className:"w-5 h-5"}),label:"Maven Approvals",isActive:"/admin/expert-approvals"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/payouts",icon:(0,a.jsx)(b.A,{className:"w-5 h-5"}),label:"Payouts",isActive:"/admin/payouts"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/eligible-payouts",icon:(0,a.jsx)(f.A,{className:"w-5 h-5"}),label:"Ready for Payout",isActive:"/admin/eligible-payouts"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/ledger-drift",icon:(0,a.jsx)(y.A,{className:"w-5 h-5"}),label:"Ledger Drift",isActive:"/admin/ledger-drift"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/cron-monitor",icon:(0,a.jsx)(j.A,{className:"w-5 h-5"}),label:"Cron Monitor",isActive:"/admin/cron-monitor"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/call-reports",icon:(0,a.jsx)(u.A,{className:"w-5 h-5"}),label:"Call Reports",isActive:"/admin/call-reports"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/chat-reports",icon:(0,a.jsx)(N.A,{className:"w-5 h-5"}),label:"Chat Reports",isActive:"/admin/chat-reports"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/refunds",icon:(0,a.jsx)(v.A,{className:"w-5 h-5"}),label:"Refunds",isActive:"/admin/refunds"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/reports",icon:(0,a.jsx)(w.A,{className:"w-5 h-5"}),label:"Reports",isActive:"/admin/reports"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/call-sessions",icon:(0,a.jsx)(A.A,{className:"w-5 h-5"}),label:"Call Sessions",isActive:"/admin/call-sessions"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/webrtc-monitor",icon:(0,a.jsx)(k.A,{className:"w-5 h-5"}),label:"WebRTC Monitor",isActive:"/admin/webrtc-monitor"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)($,{href:"/admin/roles",icon:(0,a.jsx)(C.A,{className:"w-5 h-5"}),label:"Admin Roles",isActive:"/admin/roles"===s.pathname,onClick:()=>L(!1)}),(0,a.jsx)("div",{className:"pt-4 border-t border-gray-200",children:(0,a.jsx)("button",{onClick:D,disabled:r,className:"w-full bg-red-600 hover:bg-red-700 disabled:bg-red-400 text-white font-medium py-3 px-4 roun
18ded-lg transition-colors duration-200 flex items-center justify-center text-sm",children:r?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Logging out..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(E.A,{className:"w-4 h-4 mr-2"}),"Logout"]})})})]}),(0,a.jsx)("div",{className:"absolute bottom-4 left-4 right-4 hidden lg:block",children:(0,a.jsx)("div",{className:"text-xs text-gray-500 text-center",children:"Camyvera Admin v1.0"})})]}),(0,a.jsx)("main",{className:"flex-1 overflow-auto lg:ml-0 mt-16 lg:mt-0",children:(0,a.jsx)("div",{className:"p-4 lg:p-6",children:t})})]})}function $(e){let{href:t,icon:s,label:r,isActive:l,onClick:n}=e;return(0,a.jsx)(i(),{href:t,children:(0,a.jsxs)("div",{onClick:n,className:` 19 cursor-pointer px-4 py-3 rounded-lg transition-colors duration-200 flex items-center gap-3 20 ${l?"bg-blue-100 text-blue-700 font-medium":"text-gray-700 hover:bg-gray-100 hover:text-gray-900"} 21 `,children:[s,r]})})}}},e=>{e.O(0,[7141,4167,8199,636,6593,8792],()=>e(e.s=59652)),_N_E=e.O()}]); 22//# sourceMappingURL=credits-4ea95241aa00bdac.js.map
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.