PageSourceSearch

https://escortadvisor-b4fe68rl.manus.space/assets/AdminVerifyListings-a8nwkRkM.js

js escortadvisor-b4fe68rl.manus.space collected 2026-10-03 05:02:15 UTC 19,556 bytes, 6 lines download raw bytes

1import{c as G,f as H,t as u,r as j,j as e,a6 as W,L as V,B as N,N as ee,_ as te,Y as z,ah as se,ai as A,x as B,am as ae,aZ as ie,F as re}from"./index-cscxoOf9.js";import{B as L}from"./badge-Dj3athcC.js";import{A as E}from"./activity-yT1jo4yw.js";import{P}from"./play-Bwj_2dIe.js";import{D as $}from"./database-LDECHH4a.js";import{C as ne}from"./circle-check-so_R1iP7.js";import{C as U}from"./circle-x-DHp6YeSD.js";import{C as O}from"./calendar-DIZWl4mR.js";import{R as K}from"./refresh-cw-D0KbhpJJ.js";import{T as le}from"./trending-down-BrwL8aoe.js";import{R as oe,B as ce,o as de,X as xe,Y as me,T as he,q as fe,r as F}from"./BarChart-D7jJTDvp.js";/**
2 * @license lucide-react v0.453.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 q=G("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),M=20;function Le(){const{user:w,loading:Q}=H(),f=u.useUtils(),{data:o,isLoading:X}=u.verifyListings.getVerifyStats.useQuery(),{data:p,isLoading:C}=u.verifyListings.getVerifyRuns.useQuery(),{data:i,isLoading:_}=u.verifyListings.getVerifiableCount.useQuery(),[t,c]=j.useState({status:"idle",processed:0,total:0,deleted:0,kept:0,skipped:0,currentBatch:0}),b=j.useRef(!1),Y=j.useCallback(async()=>{b.current=!1,c({status:"running",processed:0,total:0,deleted:0,kept:0,skipped:0,currentBatch:0});try{const s=await fetch(`/api/admin/verify-listings/batch?offset=0&limit=${M}`,{credentials:"include"});if(!s.ok)throw new Error(`Errore API: ${s.status}`);const d=(await s.json()).total??0;c(l=>({...l,total:d}));let n=0,x=0,S=0,m=0,k=0;for(;n<d;){if(b.current){c(a=>({...a,status:"stopped"}));return}const l=await fetch(`/api/admin/verify-listings/batch?offset=${n}&limit=${M}`,{credentials:"include"});if(!l.ok)throw new Error(`Errore batch ${k}: ${l.status}`);const D=(await l.json()).profiles??[];if(D.length===0)break;const h=[];for(const a of D){if(b.current)break;if(!a.originalUrl){m++,h.push({profileId:a.profileId,isOnline:!0});continue}try{const R=await fetch("/api/admin/verify-listings/check",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:a.originalUrl,phone:a.phone})});if(R.ok){const Z=await R.json();h.push({profileId:a.profileId,isOnline:Z.online===!0})}else m++,h.push({profileId:a.profileId,isOnline:!0})}catch{m++,h.push({profileId:a.profileId,isOnline:!0})}}const T=await fetch("/api/admin/verify-listings",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({results:h})});if(T.ok){const a=await T.json();x+=a.deleted??0,S+=a.kept??0}n+=D.length,k++,c(a=>({...a,processed:n,deleted:x,kept:S,skipped:m,currentBatch:k})),await new Promise(a=>setTimeout(a,500))}c(l=>({...l,status:"done",processed:d,deleted:x,kept:S,skipped:m})),f.verifyListings.getVerifyStats.invalidate(),f.verifyListings.getVerifyRuns.invalidate(),f.verifyListings.getVerifiableCount.invalidate()}catch(s){c(r=>({...r,status:"error",errorMsg:s.message??"Errore sconosciuto"}))}},[f]),J=j.useCallback(()=>{b.current=!0},[]);if(Q)return e.jsx("div",{className:"min-h-screen bg-[oklch(0.10_0.015_280)] flex items-center justify-center pt-[94px]",children:e.jsx("div",{className:"w-8 h-8 border-2 border-rose-500 border-t-transparent rounded-full animate-spin"})});if(!w||w.role!=="admin"&&w.role!=="superadmin")return e.jsx("div",{className:"min-h-screen bg-[oklch(0.10_0.015_280)] flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(W,{className:"w-12 h-12 text-rose-400 mx-auto mb-4"}),e.jsx("p",{className:"text-white/60 font-['DM_Sans']",children:"Accesso riservato agli amministratori"}),e.jsx(V,{href:"/admin",children:e.jsx(N,{className:"mt-4 bg-rose-500/20 text-rose-400 border border-rose-500/30",children:"Torna all'Admin"})})]})});const v=(p??[]).slice(0,30).reverse().map(s=>({date:s.runDate.slice(5),eliminati:s.totalDeleted,confermati:s.totalKept})),g=X||C||_,y=t.status==="running",I=t.total>0?Math.round(t.processed/t.total*100):0;return e.jsxs("div",{className:"min-h-screen bg-[oklch(0.10_0.015_280)]",children:[e.jsx(ee,{}),e.jsxs("div",{className:"container py-8 pt-24",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[e.jsx(V,{href:"/admin",children:e.jsxs(N,{size:"sm",variant:"ghost",className:"text-white/50 hover:text-white",children:[e.jsx(te,{className:"w-4 h-4 mr-1"}),"Admin"]})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"font-['Syne'] font-bold text-2xl text-white flex items-center gap-2",children:[e.jsx(E,{className:"w-6 h-6 text-emerald-400"}),"Verifica Annunci"]}),e.jsx("p",{className:"text-sm text-white/40 font-['DM_Sans'] mt-0.5",children:"Verifica se gli annunci sono ancora online nelle sorgenti originali"})]}),e.jsx("div",{className:"ml-auto flex items-center gap-3",children:e.jsxs(L,{className:"bg-emerald-500/15 text-emerald-400 border border-emerald-500/25 font-['DM_Sans']",children:[e.jsx(z,{className:"w-3 h-3 mr-1"}),"Auto: ogni notte 03:00"]})})]}),e.jsxs("div",{className:"rounded-2xl border border-emerald-500/20 bg-emerald-500/5 p-6 mb-8",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("h2",{className:"font-['Syne'] font-bold text-lg text-white flex items-center gap-2 mb-1",children:[e.jsx(P,{className:"w-5 h-5 text-emerald-400"}),"Avvia Verifica Manuale"]}),e.jsxs("p",{className:"text-sm text-white/50 font-['DM_Sans']",children:["Controlla subito tutti i ",i?.withUrl?.toLocaleStr
6ing("it-IT")??"…"," profili verificabili senza aspettare la notte. La verifica avviene in batch da ",M," profili con pausa anti-ban."]})]}),e.jsx("div",{className:"flex gap-3 shrink-0",children:y?e.jsxs(N,{onClick:J,className:"bg-rose-500/20 hover:bg-rose-500/30 text-rose-400 border border-rose-500/30 font-['Syne'] font-bold px-6 h-10",children:[e.jsx(q,{className:"w-4 h-4 mr-2"}),"Interrompi"]}):e.jsxs(N,{onClick:Y,disabled:t.status==="running",className:"bg-gradient-to-r from-emerald-600 to-emerald-500 hover:from-emerald-500 hover:to-emerald-400 text-white border-0 font-['Syne'] font-bold px-6 h-10 shadow-lg shadow-emerald-500/20",children:[e.jsx(P,{className:"w-4 h-4 mr-2"}),"Avvia Verifica"]})})]}),t.status!=="idle"&&e.jsxs("div",{className:"mt-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-xs text-white/50 font-['DM_Sans']",children:y?`Batch ${t.currentBatch} in corso…`:t.status==="done"?"Verifica completata":t.status==="stopped"?"Verifica interrotta":t.status==="error"?"Errore durante la verifica":""}),e.jsxs("span",{className:"text-xs font-['Syne'] font-bold text-white",children:[t.processed.toLocaleString("it-IT")," / ",t.total.toLocaleString("it-IT")," (",I,"%)"]})]}),e.jsx("div",{className:"h-2.5 rounded-full bg-[#0f1117]/10 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${t.status==="done"?"bg-gradient-to-r from-emerald-500 to-emerald-400":t.status==="error"?"bg-rose-500":t.status==="stopped"?"bg-amber-500":"bg-gradient-to-r from-emerald-600 to-emerald-400 animate-pulse"}`,style:{width:`${I}%`}})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"rounded-xl bg-[#0f1117]/5 border border-white/8 p-3 flex items-center gap-3",children:[y?e.jsx(se,{className:"w-5 h-5 text-blue-400 animate-spin shrink-0"}):e.jsx($,{className:"w-5 h-5 text-blue-400 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-['Syne'] font-bold text-lg text-blue-300",children:t.processed.toLocaleString("it-IT")}),e.jsx("div",{className:"text-xs text-white/40 font-['DM_Sans']",children:"Processati"})]})]}),e.jsxs("div",{className:"rounded-xl bg-[#0f1117]/5 border border-white/8 p-3 flex items-center gap-3",children:[e.jsx(ne,{className:"w-5 h-5 text-emerald-400 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-['Syne'] font-bold text-lg text-emerald-400",children:t.kept.toLocaleString("it-IT")}),e.jsx("div",{className:"text-xs text-white/40 font-['DM_Sans']",children:"Confermati"})]})]}),e.jsxs("div",{className:"rounded-xl bg-[#0f1117]/5 border border-white/8 p-3 flex items-center gap-3",children:[e.jsx(U,{className:"w-5 h-5 text-rose-400 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-['Syne'] font-bold text-lg text-rose-400",children:t.deleted.toLocaleString("it-IT")}),e.jsx("div",{className:"text-xs text-white/40 font-['DM_Sans']",children:"Eliminati"})]})]}),e.jsxs("div",{className:"rounded-xl bg-[#0f1117]/5 border border-white/8 p-3 flex items-center gap-3",children:[e.jsx(A,{className:"w-5 h-5 text-amber-400 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-['Syne'] font-bold text-lg text-amber-400",children:t.skipped.toLocaleString("it-IT")}),e.jsx("div",{className:"text-xs text-white/40 font-['DM_Sans']",children:"Saltati"})]})]})]}),t.status==="done"&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-xl bg-emerald-500/10 border border-emerald-500/20",children:[e.jsx(B,{className:"w-4 h-4 text-emerald-400 shrink-0"}),e.jsxs("p",{className:"text-sm text-emerald-300 font-['DM_Sans']",children:["Verifica completata. ",e.jsx("strong",{children:t.deleted})," profili eliminati, ",e.jsx("strong",{children:t.kept})," confermati attivi. Le statistiche sono state aggiornate."]})]}),t.status==="stopped"&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-xl bg-amber-500/10 border border-amber-500/20",children:[e.jsx(q,{className:"w-4 h-4 text-amber-400 shrink-0"}),e.jsxs("p",{className:"text-sm text-amber-300 font-['DM_Sans']",children:["Verifica interrotta manualmente dopo ",t.processed.toLocaleStr
6ing("it-IT")," profili. I profili già processati sono stati aggiornati."]})]}),t.status==="error"&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-xl bg-rose-500/10 border border-rose-500/20",children:[e.jsx(U,{className:"w-4 h-4 text-rose-400 shrink-0"}),e.jsxs("p",{className:"text-sm text-rose-300 font-['DM_Sans']",children:["Errore: ",t.errorMsg]})]})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-8",children:[{icon:O,label:"Esecuzioni totali",value:g?"—":o?.totalRuns.toLocaleString("it-IT")??"0",color:"text-violet-400",bg:"bg-violet-500/10 border-violet-500/20"},{icon:$,label:"Profili verificati",value:g?"—":o?.totalChecked.toLocaleString("it-IT")??"0",color:"text-blue-400",bg:"bg-blue-500/10 border-blue-500/20"},{icon:B,label:"Confermati attivi",value:g?"—":o?.totalKept.toLocaleString("it-IT")??"0",color:"text-emerald-400",bg:"bg-emerald-500/10 border-emerald-500/20"},{icon:ae,label:"Eliminati (offline)",value:g?"—":o?.totalDeleted.toLocaleString("it-IT")??"0",color:"text-rose-400",bg:"bg-rose-500/10 border-rose-500/20"}].map(({icon:s,label:r,value:d,color:n,bg:x})=>e.jsxs("div",{className:`rounded-2xl border p-5 ${x}`,children:[e.jsx("div",{className:`w-9 h-9 rounded-xl bg-[#0f1117]/5 flex items-center justify-center mb-3 ${n}`,children:e.jsx(s,{className:"w-5 h-5"})}),e.jsx("div",{className:`font-['Syne'] font-bold text-2xl ${n}`,children:d}),e.jsx("div",{className:"text-xs text-white/40 font-['DM_Sans'] mt-1",children:r})]},r))}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-8",children:[e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-[#0f1117]/3 p-5",children:[e.jsxs("h3",{className:"font-['Syne'] font-semibold text-white mb-4 flex items-center gap-2",children:[e.jsx(ie,{className:"w-4 h-4 text-blue-400"}),"Profili nel DB"]}),_?e.jsxs("div",{className:"flex items-center gap-2 text-white/40 text-sm",children:[e.jsx(K,{className:"w-4 h-4 animate-spin"}),"Caricamento..."]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-white/60 font-['DM_Sans']",children:"Profili attivi totali"}),e.jsx("span",{className:"font-['Syne'] font-bold text-white",children:i?.total.toLocaleString("it-IT")??0})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-white/60 font-['DM_Sans']",children:"Con URL sorgente (verificabili)"}),e.jsx("span",{className:"font-['Syne'] font-bold text-emerald-400",children:i?.withUrl.toLocaleString("it-IT")??0})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-white/60 font-['DM_Sans']",children:"Senza URL sorgente"}),e.jsx("span",{className:"font-['Syne'] font-bold text-amber-400",children:((i?.total??0)-(i?.withUrl??0)).toLocaleString("it-IT")})]}),e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"h-2 rounded-full bg-[#0f1117]/10 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-emerald-500 to-emerald-400 transition-all",style:{width:`${i?.total?Math.round(i.withUrl/i.total*100):0}%`}})}),e.jsxs("p",{className:"text-xs text-white/30 font-['DM_Sans'] mt-1",children:[i?.total?Math.round(i.withUrl/i.total*100):0,"% verificabili automaticamente"]})]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-[#0f1117]/3 p-5",children:[e.jsxs("h3",{className:"font-['Syne'] font-semibold text-white mb-4 flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4 text-violet-400"}),"Prossima esecuzione automatica"]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-white/60 font-['DM_Sans']",children:"Orario schedulato"}),e.jsx(L,{className:"bg-violet-500/15 text-violet-400 border border-violet-500/25 font-['DM_Sans']",children:"Ogni notte 03:00"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-white/60 font-['DM_Sans']",children:"Ultima esecuzione"}),e.jsx("span",{className:"font-['Syne'] font-semibold text-white text-sm",children:o?.lastRunDate??"Mai eseguita"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-white/60 font-['DM_Sans']",children:"Dimensione batch"}),e.jsx("span",{className:"font-['Syne'] font-semibold text-white text-sm",children:"50 profili / richiesta"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-white/60 font-['DM_Sans']",children:"Pausa anti-ban"}),e.jsx("span",{className:"font-['Syne'] font-semibold text-white text-sm",children:"2s tra i batch"})]})]}),!o?.lastRunDate&&e.jsxs("div",{className:"mt-4 flex items-start gap-2 p-3 rounded-xl bg-amber-500/10 border border-amber-500/20",children:[e.jsx(A,{className:"w-4 h-4 text-amber-400 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-xs text-amber-300/80 font-['DM_Sans']",children:"Nessuna esecuzione ancora. Il task partirà automaticamente la prossima notte alle 03:00 dopo il deploy in produzione. Puoi anche avviare una verifica manuale adesso."})]})]})]}),v.length>0&&e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-[#0f1117]/3 p-6 mb-8",children:[e.jsxs("h3",{className:"font-['Syne'] font-semibold text-white mb-6 flex items-center gap-2",children:[e.jsx(le,{className:"w-4 h-4 text-rose-400"}
6),"Storico eliminazioni (ultimi ",v.length," giorni)"]}),e.jsx("div",{style:{height:260},children:e.jsx(oe,{width:"100%",height:"100%",children:e.jsxs(ce,{data:v,margin:{top:0,right:0,left:-20,bottom:0},children:[e.jsx(de,{strokeDasharray:"3 3",stroke:"rgba(255,255,255,0.06)"}),e.jsx(xe,{dataKey:"date",tick:{fill:"rgba(255,255,255,0.35)",fontSize:11,fontFamily:"DM Sans"},axisLine:!1,tickLine:!1}),e.jsx(me,{tick:{fill:"rgba(255,255,255,0.35)",fontSize:11,fontFamily:"DM Sans"},axisLine:!1,tickLine:!1}),e.jsx(he,{contentStyle:{backgroundColor:"oklch(0.16 0.015 280)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"12px",color:"white",fontFamily:"DM Sans",fontSize:12},cursor:{fill:"rgba(255,255,255,0.04)"}}),e.jsx(fe,{wrapperStyle:{fontFamily:"DM Sans",fontSize:12,color:"rgba(255,255,255,0.5)"}}),e.jsx(F,{dataKey:"eliminati",name:"Eliminati",fill:"#f43f5e",radius:[4,4,0,0]}),e.jsx(F,{dataKey:"confermati",name:"Confermati",fill:"#10b981",radius:[4,4,0,0]})]})})})]}),e.jsxs("div",{className:"rounded-2xl border border-white/8 bg-[#0f1117]/3 overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-white/8 flex items-center justify-between",children:[e.jsxs("h3",{className:"font-['Syne'] font-semibold text-white flex items-center gap-2",children:[e.jsx(O,{className:"w-4 h-4 text-blue-400"}),"Storico esecuzioni"]}),e.jsx("span",{className:"text-xs text-white/30 font-['DM_Sans']",children:"Ultimi 90 giorni"})]}),C?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(K,{className:"w-6 h-6 text-white/30 animate-spin"})}):!p||p.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(E,{className:"w-10 h-10 text-white/15 mb-3"}),e.jsx("p",{className:"text-white/40 font-['DM_Sans'] text-sm",children:"Nessuna esecuzione ancora registrata"}),e.jsx("p",{className:"text-white/25 font-['DM_Sans'] text-xs mt-1",children:"Avvia una verifica manuale o attendi la prima esecuzione notturna"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/8",children:[e.jsx("th",{className:"text-left px-6 py-3 text-xs font-['Syne'] font-semibold text-white/40 uppercase tracking-wider",children:"Data"}),e.jsx("th",{className:"text-right px-6 py-3 text-xs font-['Syne'] font-semibold text-white/40 uppercase tracking-wider",children:"Verificati"}),e.jsx("th",{className:"text-right px-6 py-3 text-xs font-['Syne'] font-semibold text-white/40 uppercase tracking-wider",children:"Confermati"}),e.jsx("th",{className:"text-right px-6 py-3 text-xs font-['Syne'] font-semibold text-white/40 uppercase tracking-wider",children:"Eliminati"}),e.jsx("th",{className:"text-right px-6 py-3 text-xs font-['Syne'] font-semibold text-white/40 uppercase tracking-wider",children:"Tasso eliminazione"})]})}),e.jsx("tbody",{children:p.map(s=>{const r=s.totalChecked>0?Math.round(s.totalDeleted/s.totalChecked*100):0;return e.jsxs("tr",{className:"border-b border-white/5 hover:bg-[#0f1117]/3 transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:"font-['Syne'] font-semibold text-white text-sm",children:s.runDate})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("span",{className:"font-['DM_Sans'] text-blue-300 text-sm",children:s.totalChecked.toLocaleString("it-IT")})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("span",{className:"font-['DM_Sans'] text-emerald-400 text-sm",children:s.totalKept.toLocaleString("it-IT")})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("span",{className:"font-['DM_Sans'] text-rose-400 font-semibold text-sm",children:s.totalDeleted.toLocaleString("it-IT")})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs(L,{className:`text-xs font-['DM_Sans'] ${r>20?"bg-rose-500/15 text-rose-400 border-rose-500/25":r>5?"bg-amber-500/15 text-amber-400 border-amber-500/25":"bg-emerald-500/15 text-emerald-400 border-emerald-500/25"}`,children:[r,"%"]})})]},s.id)})})]})})]})]}),e.jsx(re,{})]})}
6export{Le 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.