PageSourceSearch

https://who-takes-coin--joel362.replit.app/assets/AdminClaims-c-xiFdyF.js

js who-takes-coin--joel362.replit.app collected 2026-10-03 03:56:46 UTC 9,321 bytes, 1 lines download raw bytes

1import{b as C,r as x,j as e}from"./index-MMs8uNES.js";import{u as k}from"./useQuery-unwT2NKV.js";import{u as A}from"./useMutation-CLdHhkMg.js";import{A as S}from"./AuthenticatedShell-DvfH5s-P.js";import{C as P}from"./circle-check-big-D_ADk2zQ.js";import{C as R}from"./circle-alert-C-Ll15O2.js";import{C as E}from"./circle-x-DQW3Q8BY.js";import"./globe-BybOCho1.js";import"./building-2-B3Zz-zja.js";import"./briefcase-Cp-VKCfX.js";import"./calendar-EsCIARLH.js";import"./users-BKxJQ7iG.js";import"./sparkles-D5qMvRxh.js";import"./x-BuDFMjbf.js";import"./user-CZIYOn4l.js";import"./search-ByVesLSG.js";import"./circle-question-mark-DC_SsNaE.js";const j="/api";function O(){const b=C(),[a,N]=x.useState("pending"),[d,u]=x.useState({}),[s,m]=x.useState(null),[o,n]=x.useState(null),{data:g,isLoading:h,error:f}=k({queryKey:["admin-claims",a],queryFn:async()=>{const t=localStorage.getItem("token"),i=a?`?status=${a}`:"",c=await fetch(`${j}/admin/claims${i}`,{headers:{Authorization:`Bearer ${t}`}});if(!c.ok)throw new Error("Failed to fetch claims");return c.json()}}),r=A({mutationFn:async({id:t,status:i,reviewNotes:c})=>{const y=localStorage.getItem("token");if(!y)throw new Error("You are not logged in. Please refresh the page and log in again.");const l=await fetch(`${j}/admin/claims/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`},body:JSON.stringify({status:i,reviewNotes:c})});if(!l.ok){const w=await l.json().catch(()=>({}));throw l.status===401?new Error("Session expired. Please refresh the page and log in again."):l.status===403?new Error("You do not have permission to review claims."):new Error(w.error||"Failed to review claim. Please try again.")}return l.json()},onSuccess:(t,i)=>{b.invalidateQueries({queryKey:["admin-claims"]}),m(null),u({}),n({type:"success",message:`Claim has been ${i.status} successfully.`}),setTimeout(()=>n(null),5e3)},onError:t=>{n({type:"error",message:t.message}),setTimeout(()=>n(null),8e3)}}),p=(g==null?void 0:g.data)||[],v=t=>({pending:"bg-yellow-100 text-yellow-800",approved:"bg-green-100 text-green-800",rejected:"bg-red-100 text-red-800"})[t]||"bg-gray-100 text-gray-800";return e.jsx(S,{children:e.jsxs("div",{className:"p-6",children:[o&&e.jsxs("div",{className:`mb-4 p-4 rounded-lg flex items-center gap-3 ${o.type==="success"?"bg-green-50 border border-green-200 text-green-800":"bg-red-50 border border-red-200 text-red-800"}`,children:[o.type==="success"?e.jsx(P,{className:"w-5 h-5 text-green-600"}):e.jsx(R,{className:"w-5 h-5 text-red-600"}),e.jsx("span",{children:o.message}),e.jsx("button",{onClick:()=>n(null),className:"ml-auto text-gray-500 hover:text-gray-700",children:e.jsx(E,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Business Claims"}),e.jsx("p",{className:"text-gray-600",children:"Review and approve ownership claims for listings"})]}),e.jsx("div",{className:"flex gap-2",children:["pending","approved","rejected",""].map(t=>e.jsx("button",{onClick:()=>N(t),className:`px-4 py-2 rounded-lg text-sm font-medium transition ${a===t?"bg-cyan-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:t===""?"All":t.charAt(0).toUpperCase()+t.slice(1)},t))})]}),h&&e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-cyan-600"})}),f&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-red-700",children:"Failed to load claims. Please try again."}),!h&&p.length===0&&e.jsxs("div",{className:"bg-gray-50 rounded-lg p-12 text-center",children:[e.jsx("svg",{className:"w-16 h-16 mx-auto text-gray-400 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.jsxs("h3",{className:"text-lg font-medium text-gray-900 mb-1",children:["No ",a||""," claims"]}),e.jsx("p",{className:"text-gray-500",children:a==="pending"?"All claims have been reviewed!":"No claims match this filter."})]}),!h&&p.length>0&&e.jsx("div",{className:"bg-white rounded-xl shadow overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Listing"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Claimant"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Role"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Status"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Submitted"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:p.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900",children:t.listingTitle||"Unknown Listing"}),e.jsx("div",{className:"text-xs text-gray-500",children:t.listingId})]}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"text-sm text-gray-900",children:t.submitterName||"N/A"}),e.jsx("div",{className:"text-sm text-gray-500",children:t.submitterEmail}),t.submitterPhone&&e.jsx("div",{className:"text-xs text-gray-400",children:t.submitterPhone})]}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-600",children:t.businessRole||"Not specified"}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${v(t.status)}`,children:t.status})}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-500",children:new Date(t.submittedAt).toLocaleDateString()}),e.jsx("td",{className:"px-6 py-4 text-right",children:t.status==="pending"?e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>m(t),className:"text-cyan-600 hover:text-cyan-700 text-sm font-medium",children:"Review"}),e.jsx("button",{onClick:()=>r.mutate({id:t.id,status:"approved"}),disabled:r.isPending,className:"text-green-600 hover:text-green-700 text-sm font-medium",children:"Approve"}),e.jsx("button",{onClick:()=>r.mutate({id:t.id,status:"rejected"}),disabled:r.isPending,className:"text-red-600 hover:text-red-700 text-sm font-medium",children:"Reject"})]}):e.jsx("span",{className:"text-gray-400 text-sm",children:"Reviewed"})})]},t.id))})]})}),s&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-lg w-full mx-4 p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-4",children:"Review Claim"}),e.jsxs("div",{className:"space-y-3 mb-6",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-500",children:"Listing:"}),e.jsx("p",{className:"font-medium",children:s.listingTitle||"Unknown"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-500",children:"Claimant:"}),e.jsx("p",{className:"font-medium",children:s.submitterName||s.submitterEmail}),e.jsx("p",{className:"text-sm text-gray-600",children:s.submitterEmail}),s.submitterPhone&&e.jsx("p",{className:"text-sm text-gray-600",children:s.submitterPhone})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-500",children:"Business Role:"}),e.jsx("p",{className:"font-medium",children:s.businessRole||"Not specified"})]}),s.notes&&e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-500",children:"Notes from Claimant:"}),e.jsx("p",{className:"text-gray-700 bg-gray-50 p-3 rounded mt-1",children:s.notes})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Review Notes (optional)"}),e.jsx("textarea",{value:d[s.id]||"",onChange:t=>u({...d,[s.id]:t.target.value}),rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-cyan-500 focus:border-cyan-500",placeholder:"Add notes about your decision..."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>m(null),className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50",children:"Cancel"}),e.jsx("button",{onClick:()=>r.mutate({id:s.id,status:"rejected",reviewNotes:d[s.id]}),disabled:r.isPending,className:"flex-1 px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 disabled:opacity-50",children:"Reject"}),e.jsx("button",{onClick:()=>r.mutate({id:s.id,status:"approved",reviewNotes:d[s.id]}),disabled:r.isPending,className:"flex-1 px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 disabled:opacity-50",children:"Approve"})]})]})})]})})}export{O as AdminClaims};

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.