PageSourceSearch

https://bondedpath.com/assets/AdminDiagnosticsPage-BsGbuJfv.js

js bondedpath.com collected 2026-10-02 00:48:20 UTC 8,682 bytes, 15 lines download raw bytes

1import{r as n,j as e}from"./vendor-react-BoyrKzsG.js";import{A as v}from"./AdminLayout-UtVj2u1H.js";import{y as w,R as p}from"./index-CKCEYSTE.js";import{C as A,m as C,a6 as N,aa as k,F as I,ab as l}from"./vendor-ui-Cy9YOY35.js";import"./vendor-firebase-DbFCdLkQ.js";const L=()=>{const[o,x]=n.useState(!0),[d,m]=n.useState(null),[h,g]=n.useState(!1),[s,R]=n.useState(null),[f,y]=n.useState(null),r=async()=>{x(!0),y(null);try{const i=await p.getAdminRepository(),z=(await i.getDashboardStats()).totalUsers,b=await i.getAllUsers({},{limit:1e3}),u=b.data.filter(c=>!c.createdAt||!c.verification||c.verification.isEmailVerified===!1);R({totalUsers:z,visibleUsers:b.data.length-u.length,incompleteUsers:u})}catch(i){console.error("Audit failed:",i),y(i.message||"Failed to run diagnostic audit.")}finally{x(!1)}};n.useEffect(()=>{r()},[]);const U=async i=>{m(i);try{await(await p.getAdminRepository()).repairUser(i),await r()}catch(t){alert("Repair failed: "+t.message)}finally{m(null)}},S=async()=>{if(!(!s||s.incompleteUsers.length===0)&&window.confirm(`Are you sure you want to repair ${s.incompleteUsers.length} users?`)){g(!0);try{const i=await p.getAdminRepository();for(const t of s.incompleteUsers)await i.repairUser(t.id);await r(),alert("Bulk repair completed successfully.")}catch(i){alert("Bulk repair encountered an error: "+i.message)}finally{g(!1)}}};if(o&&!s)return e.jsx(v,{title:"System Diagnostics",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"100px 0",gap:"20px"},children:[e.jsx(w,{}),e.jsx("p",{style:{color:"#666"},children:"Analyzing Firestore data health..."})]})});const j=s?Math.round(s.visibleUsers/s.totalUsers*100):0,a=j===100;return e.jsxs(v,{title:"System Diagnostics",children:[e.jsxs("div",{className:"admin-diagnostics",children:[e.jsxs("div",{className:"admin-stats-grid",children:[e.jsxs("div",{className:`stat-card ${a?"healthy":"warning"}`,style:{borderLeft:`4px solid ${a?"#10b981":"#f59e0b"}`},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{color:"#666",fontSize:"0.9rem",marginBottom:"5px"},children:"Data Health Score"}),e.jsxs("p",{style:{fontSize:"2.5rem",fontWeight:800,color:a?"#065f46":"#92400e"},children:[j,"%"]})]}),a?e.jsx(A,{color:"#10b981",size:32}):e.jsx(C,{color:"#f59e0b",size:32})]}),e.jsx("p",{style:{fontSize:"0.85rem",color:"#666",marginTop:"10px"},children:a?"All users are visible and correctly indexed.":`${s==null?void 0:s.incompleteUsers.length} users are hidden from sorted lists.`})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("h3",{style:{color:"#666",fontSize:"0.9rem",marginBottom:"5px"},children:"Total Records"}),e.jsx("p",{style:{fontSize:"2.5rem",fontWeight:800},children:s==null?void 0:s.totalUsers}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"5px",marginTop:"10px",fontSize:"0.85rem",color:"#666"},children:[e.jsx(N,{size:14})," ",e.jsx("span",{children:"Firestore count"})]})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("h3",{style:{color:"#666",fontSize:"0.9rem",marginBottom:"5px"},children:"Incomplete Profiles"}),e.jsx("p",{style:{fontSize:"2.5rem",fontWeight:800,color:((s==null?void 0:s.incompleteUsers.length)||0)>0?"#ef4444":"inherit"},children:s==null?void 0:s.incompleteUsers.length}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"5px",marginTop:"10px",fontSize:"0.85rem",color:"#666"},children:[e.jsx(k,{size:14})," ",e.jsx("span",{children:"Missing mandatory fields"})]})]})]}),f&&e.jsxs("div",{style:{margin:"20px 0",padding:"15px",backgroundColor:"#fef2f2",border:"1px solid #fee2e2",borderRadius:"8px",color:"#991b1b",display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx(I,{size:20}),e.jsx("span",{children:f})]}),!a&&s&&e.jsx("div",{style:{margin:"30px 0",padding:"20px",background:"linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%)",borderRadius:"12px",border:"1px solid #fde68a"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{color:"#92400e",marginBottom:"5px"},children:"Data Repair Available"}),e.jsxs("p",{style:{color:"#b45309",fontSize:"0.9rem"},children:["We found ",s.incompleteUsers.length," records missing timestamps. Repairing them will make them visible in the User List."]})]}),e.jsxs("button",{className:"admin-btn-primary",onClick:S,disabled:h,style:{backgroundColor:"#d97706",display:"flex",alignItems:"center",gap:"8px",padding:"12px 24px"},children:[h?e.jsx(l,{className:"animate-spin",size:18}):e.jsx(l,{size:18}),"Repair All Records"]})]})}),s&&s.incompleteUsers.length>0&&e.jsxs("div",{className:"admin-section",style:{marginTop:"30px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[e.jsxs("h3",{style:{margin:0},children:["Hidden Users (",s.incompleteUsers.length,")"]}),e.jsxs("button",{onClick:r,disabled:o,style:{background:"none",border:"none",color:"#8B5A2B",cursor:"pointer",display:"flex",alignItems:"center",gap:"5px",fontSize:"0.9rem"},children:[e.jsx(l,{size:14,className:o?"animate-spin":""})," Refresh List"]})]}),e.jsx("div",{className:"admin-table-container",style:{borderRadius:"12px",overflow:"hidden",border:"1px solid #eee"},children:e.jsxs("table",{className:"admin-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"User Details"}),e.jsx("th",{children:"Missing Fields"}),e.jsx("th",{children:"Status"}),e.jsx("th",{style:{textAlign:"right"},children:"Actions"})]})}),e.jsx("tbody",{children:s.incompleteUsers.map(i=>{var t;return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx("div",{className:"user-avatar-mini",children:((t=i.displayName)==null?void 0:t.charAt(0))||"U"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx("span",{style:{fontWeight:600},children:i.displayName||"Unknown User"}),e.jsx("span",{style:{fontSize:"0.8rem",color:"#666"},children:i.email||"No Email"})]})]})}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"5px",flexWrap:"wrap"},children:[!i.createdAt&&e.jsx("span",{className:"badge",style:{backgroundColor:"#fee2e2",color:"#b91c1c",border:"none"},children:"createdAt"}),!i.accountStatus&&e.jsx("span",{className:"badge",style:{backgroundColor:"#fee2e2",color:"#b91c1c",border:"none"},children:"accountStatus"}),i.hasCompletedOnboarding===void 0&&e.jsx("span",{className:"badge",style:{backgroundColor:"#fef3c7",color:"#92400e",border:"none"},children:"onboardingFlag"}),(!i.verification||i.verification.isEmailVerified===!1)&&e.jsx("span",{className:"badge",style:{backgroundColor:"#fee2e2",color:"#b91c1c",border:"none"},children:"isEmailVerified"})]})}),e.jsx("td",{children:e.jsx("span",{className:"badge status-deleted",children:"Hidden"})}),e.jsx("td",{style:{textAlign:"right"},children:e.jsxs("button",{className:"repair-btn",onClick:()=>U(i.id),disabled:!!d,style:{padding:"6px 12px",backgroundColor:"#f3f4f6",border:"1px solid #d1d5db",borderRadius:"6px",fontSize:"0.85rem",cursor:d?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:"5px"},children:[d===i.id?e.jsx(l,{size:14,className:"animate-spin"}):e.jsx(l,{size:14}),"Repair"]})})]},i.id)})})]})})]}),s&&s.incompleteUsers.length===0&&e.jsxs("div",{style:{textAlign:"center",padding:"80px 0",display:"flex",flexDirection:"column",alignItems:"center",gap:"20px"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"40px",backgroundColor:"#ecfdf5",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(A,{color:"#10b981",size:40})}),e.jsx("h3",{children:"Database is Healthy"}),e.jsxs("p",{style:{color:"#666",maxWidth:"400px"},children:["All ",s.totalUsers," users have mandatory fields and are visible in administrative tools."]}),e.jsx("button",{className:"admin-btn-secondary",onClick:r,style:{marginTop:"10px"},children:"Run Analysis Again"})]})]}),e.jsx("style",{dangerouslySetInnerHTML:{__html:`
2                .animate-spin {
3                    animation: spin 1s linear infinite;
4                }
5                @keyframes spin {
6                    from { transform: rotate(0deg); }
7                    to { transform: rotate(360deg); }
8                }
9                .stat-card.warning {
10                    background: #fffbeb;
11                }
12                .stat-card.healthy {
13                    background: #f0fdf4;
14                }
15            `}})]})};export{L 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.