PageSourceSearch

https://drophighlight.com/assets/SuperadminFanModerationHistory-DI1HmlSC.js

js drophighlight.com collected 2026-09-30 06:38:19 UTC 13,857 bytes, 2 lines download raw bytes

1import{r as c,s as b,j as e,C as G,l as K,h as re,i as de,B as V,aC as ce,o as z,aD as me,aE as ue,aF as _e}from"./index-P0N1Je5T.js";import{T as pe,a as xe,b as D,c as S,d as he,e as j}from"./table-DyXCBCTZ.js";import{I as Z}from"./input-1tKBwIjz.js";import{S as J,a as X,b as Y,c as q,d as F}from"./select-Supfcq-S.js";const L=25,H=i=>!!i&&/^https?:\/\//i.test(i),fe=i=>{if(!i||i.length!==2)return"";const v=127462;return String.fromCodePoint(v+i.toUpperCase().charCodeAt(0)-65)+String.fromCodePoint(v+i.toUpperCase().charCodeAt(1)-65)},je=i=>{const v=new Set;return i.filter(f=>!f||v.has(f)?!1:(v.add(f),!0))},ve=({row:i,signedUrl:v})=>{var x,R;const[f,P]=c.useState(0),k=(i.file_type||((x=i.gallery_items)==null?void 0:x.file_type)||"").startsWith("video"),w=(i.file_type||((R=i.gallery_items)==null?void 0:R.file_type)||"").startsWith("image"),o=i.gallery_items,E=je([i.thumbnail_url,i.medium_thumbnail_url,i.fullscreen_thumbnail_url,o==null?void 0:o.admin_thumbnail_url,o==null?void 0:o.thumbnail_url,o==null?void 0:o.grid_thumbnail_url,o==null?void 0:o.preview_thumbnail_url,o==null?void 0:o.medium_thumbnail_url,o==null?void 0:o.fullscreen_thumbnail_url,w?v:null,w&&H(i.file_url)?i.file_url:null,w&&H(o==null?void 0:o.file_url)?o==null?void 0:o.file_url:null]),_=E.join("|"),A=E[f];return c.useEffect(()=>{P(0)},[i.id,_]),A?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:A,alt:"",loading:"lazy",className:"h-12 w-12 object-cover rounded border bg-muted",onError:()=>{P(M=>M+1)}}),f>=E.length?e.jsx("div",{className:"h-12 w-12 rounded border bg-muted flex items-center justify-center text-[10px] text-muted-foreground",children:k?"video":"—"}):null]}):e.jsx("div",{className:"h-12 w-12 rounded border bg-muted flex items-center justify-center text-[10px] text-muted-foreground",children:k?"video":"—"})},Ne=()=>{const[i,v]=c.useState([]),[f,P]=c.useState(null),[k,w]=c.useState(!0),[o,E]=c.useState(""),[_,A]=c.useState("all"),[x,R]=c.useState("all"),[M,ee]=c.useState(""),[N,Q]=c.useState(0),[$,te]=c.useState({}),[ae,se]=c.useState([]),[C,ne]=c.useState({}),[l,oe]=c.useState(null),[O,le]=c.useState({});c.useEffect(()=>{(async()=>{const{data:s}=await b.from("companies").select("id, name").order("name"),a=s||[];se(a);const r={};a.forEach(n=>{r[n.id]=n.name}),te(r)})()},[]),c.useEffect(()=>{(async()=>{w(!0);const a=t=>(t=t.not("moderated_at","is",null),_==="all"?t=t.in("status",["approved","rejected"]):t=t.eq("status",_),x!=="all"&&(t=t.eq("company_id",x)),t),r=a(b.from("fan_uploads").select("id, status, file_name, file_type, file_url, thumbnail_url, medium_thumbnail_url, fullscreen_thumbnail_url, published_gallery_item_id, moderated_at, moderated_by, moderation_note, company_id, fan_submissions(first_name, last_name, email, instagram_handle, country_code, region, city, device_type, device_brand, device_model, browser_name, browser_version, os_name, os_version, connection_effective_type, connection_downlink, connection_rtt, connection_save_data), gallery_items!fan_uploads_published_gallery_item_id_fkey(file_url, file_type, thumbnail_url, grid_thumbnail_url, preview_thumbnail_url, medium_thumbnail_url, fullscreen_thumbnail_url, admin_thumbnail_url)").order("moderated_at",{ascending:!1}).range(N,N+L-1)),n=a(b.from("fan_uploads").select("id",{count:"exact",head:!0})),[{data:g,error:u},{count:d}]=await Promise.all([r,n]);if(u)console.error("Error loading fan moderation history:",u);else{const t=g||[];v(t),P(d??null);const T=Array.from(new Set(t.map(m=>m.moderated_by).filter(Boolean))).filter(m=>!C[m]);if(T.length){const{data:m}=await b.from("profiles").select("id, full_name, email").in("id",T),U={...C};(m||[]).forEach(h=>{U[h.id]={full_name:h.full_name,email:h.email}}),ne(U)}const I=t.filter(m=>(m.file_type||"").startsWith("image")).map(m=>m.file_url).filter(m=>!!m&&!H(m)),p=Array.from(new Set(I)).filter(m=>!O[m]);if(p.length){const{data:m}=await b.storage.from("fan-uploads").createSignedUrls(p,3600);if(m){const U={...O};m.forEach(h=>{h!=null&&h.path&&(h!=null&&h.signedUrl)&&(U[h.path]=h.signedUrl)}),le(U)}}}w(!1)})()},[N,_,x]),c.useEffect(()=>{(async()=>{const s=p=>(p=p.not("moderated_at","is",null),x!=="all"&&(p=p.eq("company_id",x)),p),a=s(b.from("fan_uploads").select("id",{count:"exact",head:!0})).eq("status","approved"),r=s(b.from("fan_uploads").select("id",{count:"exact",head:!0})).eq("status","rejected");let n=b.from("fan_uploads").select("id",{count:"exact",head:!0});x!=="all"&&(n=n.eq("company_id",x));let g=s(b.from("fan_uploads").select("company_id, moderated_by").in("status",_==="all"?["approved","rejected"]:[_])).limit(1e4);const[{count:u},{count:d},{count:t},{data:y}]=await Promise.all([a,r,n,g]),T=new Set,I=new Set;
1(y||[]).forEach(p=>{p.company_id&&T.add(p.company_id),p.moderated_by&&I.add(p.moderated_by)}),oe({approved:_==="rejected"?0:u??0,rejected:_==="approved"?0:d??0,companies:T.size,moderators:I.size,totalUploads:t??0})})()},[_,x]);const B=c.useMemo(()=>{const s=o.trim().toLowerCase(),a=M.trim().toLowerCase();return i.filter(r=>{if(a){const u=r.moderated_by?C[r.moderated_by]:null,d=((u==null?void 0:u.email)||"").toLowerCase(),t=((u==null?void 0:u.full_name)||"").toLowerCase();if(!d.includes(a)&&!t.includes(a))return!1}if(!s)return!0;const n=r.fan_submissions;return[n==null?void 0:n.first_name,n==null?void 0:n.last_name,n==null?void 0:n.email,n==null?void 0:n.instagram_handle,r.file_name,$[r.company_id||""]].filter(Boolean).join(" ").toLowerCase().includes(s)})},[i,o,M,C,$]),W=()=>Q(0),ie=()=>{const s=["moderated_at","status","fan_name","fan_email","fan_instagram","company","file_name","file_type","country","region","city","device_type","device_brand","device_model","browser","os","connection","downlink_mbps","rtt_ms","moderator_name","moderator_email","moderation_note"],a=B.map(d=>{const t=d.fan_submissions,y=d.moderated_by?C[d.moderated_by]:null;return[d.moderated_at?new Date(d.moderated_at).toISOString():"",d.status,`${(t==null?void 0:t.first_name)||""} ${(t==null?void 0:t.last_name)||""}`.trim(),(t==null?void 0:t.email)||"",(t==null?void 0:t.instagram_handle)||"",$[d.company_id||""]||d.company_id||"",d.file_name||"",d.file_type||"",(t==null?void 0:t.country_code)||"",(t==null?void 0:t.region)||"",(t==null?void 0:t.city)||"",(t==null?void 0:t.device_type)||"",(t==null?void 0:t.device_brand)||"",(t==null?void 0:t.device_model)||"",[t==null?void 0:t.browser_name,t==null?void 0:t.browser_version].filter(Boolean).join(" "),[t==null?void 0:t.os_name,t==null?void 0:t.os_version].filter(Boolean).join(" "),(t==null?void 0:t.connection_effective_type)||"",(t==null?void 0:t.connection_downlink)??"",(t==null?void 0:t.connection_rtt)??"",(y==null?void 0:y.full_name)||"",(y==null?void 0:y.email)||"",d.moderation_note||""]}),r=[s,...a].map(d=>d.map(t=>`"${String(t).replace(/"/g,'""')}"`).join(",")).join(`
2`),n=new Blob([r],{type:"text/csv;charset=utf-8;"}),g=URL.createObjectURL(n),u=document.createElement("a");u.href=g,u.download=`fan-moderation-history-${new Date().toISOString().slice(0,10)}.csv`,u.click(),URL.revokeObjectURL(g)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Fan Moderation History"}),e.jsx("p",{className:"text-muted-foreground",children:"Every approved/rejected fan upload across all companies, with moderator, timestamp and note."})]}),(()=>{const s=((l==null?void 0:l.approved)??0)+((l==null?void 0:l.rejected)??0),a=n=>s>0?Math.round(n/s*100):0,r=[{label:"Total uploads",value:((l==null?void 0:l.totalUploads)??0).toLocaleString(),hint:"All statuses received"},{label:"Total moderated",value:s.toLocaleString(),hint:_==="all"?"Approved + Rejected":`${_} only`},{label:"Approved",value:((l==null?void 0:l.approved)??0).toLocaleString(),hint:`${a((l==null?void 0:l.approved)??0)}%`},{label:"Rejected",value:((l==null?void 0:l.rejected)??0).toLocaleString(),hint:`${a((l==null?void 0:l.rejected)??0)}%`},{label:"Companies",value:((l==null?void 0:l.companies)??0).toLocaleString(),hint:"distinct"},{label:"Moderators",value:((l==null?void 0:l.moderators)??0).toLocaleString(),hint:"distinct"}];return e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:r.map(n=>e.jsx(G,{className:"shadow-none",children:e.jsxs(K,{className:"p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:n.label}),e.jsx("div",{className:"text-2xl font-semibold mt-1",children:n.value}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:n.hint})]})},n.label))})})(),e.jsxs(G,{children:[e.jsx(re,{children:e.jsxs(de,{children:["Showing ",B.length,f!==null?` of ${f.toLocaleString()}`:""," entries"]})}),e.jsxs(K,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsx(Z,{placeholder:"Search fan, email, file, company…",value:o,onChange:s=>E(s.target.value)}),e.jsx(Z,{placeholder:"Filter by moderator (name/email)…",value:M,onChange:s=>ee(s.target.value)}),e.jsxs(J,{value:x,onValueChange:s=>{R(s),W()},children:[e.jsx(X,{children:e.jsx(Y,{placeholder:"Company"})}),e.jsxs(q,{className:"max-h-80",children:[e.jsx(F,{value:"all",children:"All companies"}),ae.map(s=>e.jsx(F,{value:s.id,children:s.name},s.id))]})]}),e.jsxs(J,{value:_,onValueChange:s=>{A(s),W()},children:[e.jsx(X,{children:e.jsx(Y,{placeholder:"Status"})}),e.jsxs(q,{children:[e.jsx(F,{value:"all",children:"Approved & Rejected"}),e.jsx(F,{value:"approved",children:"Approved only"}),e.jsx(F,{value:"rejected",children:"Rejected only"})]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx(V,{variant:"outline",size:"sm",disabled:N===0,onClick:()=>Q(Math.max(0,N-L)),children:"Previous"}),e.jsx(V,{variant:"outline",size:"sm",disabled:i.length<L,onClick:()=>Q(N+L),children:"Next"}),e.jsxs("span",{className:"text-xs text-muted-foreground self-center",children:["Page ",Math.floor(N/L)+1,f!==null?` of ${Math.max(1,Math.ceil(f/L))}`:""]}),e.jsx(V,{variant:"outline",size:"sm",className:"ml-auto",onClick:ie,children:"Export CSV"})]}),k?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading…"}):e.jsx(ce,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(pe,{children:[e.jsx(xe,{children:e.jsxs(D,{children:[e.jsx(S,{children:"Preview"}),e.jsx(S,{children:"Fan"}),e.jsx(S,{children:"Company"}),e.jsx(S,{children:"File"}),e.jsx(S,{children:"Status"}),e.jsx(S,{children:"Moderator"}),e.jsx(S,{children:"Moderated at"}),e.jsx(S,{children:"Context"}),e.jsx(S,{children:"Note"})]})}),e.jsxs(he,{children:[B.map(s=>{const a=s.fan_submissions,r=s.moderated_by?C[s.moderated_by]:null,n=`${(a==null?void 0:a.first_name)||""} ${(a==null?void 0:a.last_name)||""}`.trim()||"—",g=s.file_url&&!H(s.file_url)?O[s.file_url]:null;return e.jsxs(D,{children:[e.jsx(j,{children:e.jsx(ve,{row:s,signedUrl:g})}),e.jsxs(j,{className:"text-xs",children:[e.jsx("div",{className:"font-medium",children:n}),e.jsx("div",{className:"text-muted-foreground",children:(a==null?void 0:a.email)||"—"}),(a==null?void 0:a.instagram_handle)&&e.jsxs("div",{className:"text-muted-foreground",children:["@",a.instagram_handle.replace(/^@/,"")]})]}),e.jsx(j,{className:"text-xs",children:$[s.company_id||""]||(s.company_id?s.company_id.slice(0,8):"—")}),e.jsxs(j,{className:"text-xs max-w-[180px]",children:[e.jsx("div",{className:"truncate",title:s.file_name||"",children:s.file_name||"—"}),e.jsx("div",{className:"text-muted-foreground",children:s.file_type||""})]}),e.jsx(j,{children:e.jsx(z,{variant:s.status==="approved"?"default":"destructive",children:s.status})}),e.jsx(j,{className:"text-xs",children:r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-medium",children:r.full_name||r.email||"—"}),r.full_name&&e.jsx("div",{className:"text-muted-foreground",children:r.email||""})]}):e.jsx("span",{className:"text-muted-foreground",children:s.moderated_by?s.moderated_by.slice(0,8):"—"})}),e.jsx(j,{className:"whitespace-nowrap text-xs",children:s.moderated_at?new Date(s.moderated_at).toLocaleStr
2ing():"—"}),e.jsx(j,{className:"text-xs",children:a?e.jsxs("div",{className:"flex flex-col gap-1",children:[(a.country_code||a.city)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{children:fe(a.country_code)}),e.jsx("span",{className:"text-muted-foreground",children:[a.city,a.region,a.country_code].filter(Boolean).join(", ")||"—"})]}),(a.device_type||a.browser_name||a.os_name)&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.device_type&&e.jsx(z,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:a.device_type}),a.browser_name&&e.jsx(z,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:a.browser_name}),a.os_name&&e.jsx(z,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[a.os_name,a.os_version].filter(Boolean).join(" ")})]}),a.connection_effective_type&&e.jsxs("div",{className:"text-muted-foreground",children:[a.connection_effective_type.toUpperCase(),a.connection_downlink!=null&&` · ${a.connection_downlink} Mbps`]}),!a.country_code&&!a.device_type&&!a.connection_effective_type&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(j,{className:"text-xs max-w-[260px]",children:s.moderation_note?e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsx("div",{className:"truncate cursor-help",children:s.moderation_note})}),e.jsx(_e,{className:"max-w-sm whitespace-pre-wrap",children:s.moderation_note})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})})]},s.id)}),B.length===0&&e.jsx(D,{children:e.jsx(j,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No moderation activity for these filters."})})]})]})})})]})]})]})};export{Ne 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.