PageSourceSearch

https://drophighlight.com/assets/SuperadminUploadInbox-BWcVAQtd.js

js drophighlight.com collected 2026-09-30 06:38:46 UTC 7,343 bytes, 1 lines download raw bytes

1import{r as i,s as m,j as e,O as L,C as u,l as p,ah as V,aj as H,B as N,J as C,o as x}from"./index-P0N1Je5T.js";import{I as J}from"./input-1tKBwIjz.js";import{S as U,a as D,b as E,c as z,d as c}from"./select-Supfcq-S.js";import{H as q}from"./hard-drive-Db7S_XsL.js";import{L as G}from"./loader-circle-BQs4OzSl.js";import{E as K}from"./eye-BxqX1t91.js";import{A as Q}from"./archive-B1aoBXiv.js";import{F as W}from"./file-B2Q_lErU.js";import{D as X}from"./download-JbV5bimG.js";const ie=()=>{const[S,y]=i.useState([]),[h,F]=i.useState([]),[A,f]=i.useState(!0),[j,B]=i.useState("all"),[_,R]=i.useState("all"),[g,M]=i.useState(""),[I,P]=i.useState(null);i.useEffect(()=>{$()},[]);const $=async()=>{f(!0);const[s,n]=await Promise.all([m.from("client_uploads").select("*").order("created_at",{ascending:!1}),m.rpc("get_all_companies_for_superadmin")]);if(s.error){console.error("Error fetching uploads:",s.error),f(!1);return}const t=s.data||[],o=(n.data||[]).map(a=>({id:a.id,name:a.name}));F(o);const r=new Map;o.forEach(a=>r.set(a.id,a.name));const d=new Map;for(const a of t){d.has(a.session_id)||d.set(a.session_id,{session_id:a.session_id,company_id:a.company_id,company_name:r.get(a.company_id)||"Unknown",sender_name:a.sender_name,sender_email:a.sender_email,notes:a.notes,status:a.status,created_at:a.created_at,file_count:0,total_size:0,files:[]});const l=d.get(a.session_id);l.file_count++,l.total_size+=a.file_size||0,l.files.push({id:a.id,file_url:a.file_url,file_name:a.file_name,file_size:a.file_size,file_type:a.file_type,status:a.status,created_at:a.created_at})}y(Array.from(d.values())),f(!1)},O=async(s,n)=>{try{const{data:t,error:o}=await m.storage.from("client-uploads").createSignedUrl(s,3600);if(o||!(t!=null&&t.signedUrl))throw o||new Error("No signed URL");const r=await fetch(t.signedUrl);if(!r.ok)throw new Error("Download failed");const d=await r.blob(),a=URL.createObjectURL(d),l=document.createElement("a");l.href=a,l.download=n||"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(a)}catch(t){console.error("Download error:",t),C.error("Failed to download file")}},b=async(s,n)=>{const{error:t}=await m.from("client_uploads").update({status:n}).eq("session_id",s);if(t){C.error("Failed to update status");return}C.success(`Status updated to ${n}`),y(o=>o.map(r=>r.session_id===s?{...r,status:n}:r))},w=s=>s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:s<1024*1024*1024?`${(s/(1024*1024)).toFixed(1)} MB`:`${(s/(1024*1024*1024)).toFixed(2)} GB`,T=s=>{switch(s){case"pending":return e.jsx(x,{variant:"secondary",children:"Pending"});case"downloaded":return e.jsx(x,{variant:"default",children:"Downloaded"});case"archived":return e.jsx(x,{variant:"outline",children:"Archived"});default:return e.jsx(x,{variant:"outline",children:s})}},k=S.filter(s=>{if(j!=="all"&&s.company_id!==j||_!=="all"&&s.status!==_)return!1;if(g){const n=g.toLowerCase();return(s.sender_name||"").toLowerCase().includes(n)||(s.sender_email||"").toLowerCase().includes(n)||s.company_name.toLowerCase().includes(n)||s.files.some(t=>(t.file_name||"").toLowerCase().includes(n))}return!0}),v=new Map;return S.forEach(s=>{v.set(s.company_id,(v.get(s.company_id)||0)+s.total_size)}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center gap-2",children:[e.jsx(L,{className:"h-8 w-8"}),"Upload Inbox"]}),e.jsx("p",{className:"text-muted-foreground",children:"Client-uploaded files awaiting review"})]}),h.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:h.map(s=>e.jsx(u,{children:e.jsxs(p,{className:"pt-4 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(q,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium truncate",children:s.name})]}),e.jsx("p",{className:"text-lg font-bold",children:w(v.get(s.id)||0)})]})},s.id))}),e.jsx(u,{children:e.jsx(p,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx(J,{placeholder:"Search by sender, company, or filename...",value:g,onChange:s=>M(s.target.value),className:"flex-1"}),e.jsxs(U,{value:j,onValueChange:B,children:[e.jsx(D,{className:"w-[200px]",children:e.jsx(E,{placeholder:"All Companies"})}),e.jsxs(z,{children:[e.jsx(c,{value:"all",children:"All Companies"}),h.map(s=>e.jsx(c,{value:s.id,children:s.name},s.id))]})]}),e.jsxs(U,{value:_,onValueChange:R,children:[e.jsx(D,{className:"w-[160px]",children:e.jsx(E,{placeholder:"All Status"})}),e.jsxs(z,{children:[e.jsx(c,{value:"all",children:"All Status"}),e.jsx(c,{value:"pending",children:"Pending"}),e.jsx(c,{value:"downloaded",children:"Downloaded"}),e.jsx(c,{value:"archived",children:"Archived"})]})]})]})})}),A?e.jsx("div",{className:"text-center py-8",children:e.jsx(G,{className:"h-6 w-6 animate-spin mx-auto"})}):k.length===0?e.jsx(u,{children:e.jsxs(p,{className:"pt-6 text-center text-muted-foreground py-12",children:[e.jsx(L,{className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"No uploads found"})]})}):e.jsx("div",{className:"space-y-3",children:k.map(s=>{const n=I===s.session_id;return e.jsx(u,{children:e.jsxs(p,{className:"pt-4 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>P(n?null:s.session_id),children:[n?e.jsx(V,{className:"h-4 w-4 shrink-0"}):e.jsx(H,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("span",{className:"font-medium",children:s.company_name}),T(s.status)]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[s.file_count," file",s.file_count!==1?"s":""]}),e.jsx("span",{children:w(s.total_size)}),e.jsx("span",{children:new Date(s.created_at).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[s.status==="pending"&&e.jsxs(N,{size:"sm",variant:"outline",onClick:t=>{t.stopPropagation(),b(s.session_id,"downloaded")},children:[e.jsx(K,{className:"h-3 w-3 mr-1"}),"Mark Downloaded"]}),s.status!=="archived"&&e.jsxs(N,{size:"sm",variant:"ghost",onClick:t=>{t.stopPropagation(),b(s.session_id,"archived")},children:[e.jsx(Q,{className:"h-3 w-3 mr-1"}),"Archive"]})]})]}),n&&e.jsxs("div",{className:"mt-4 border-t pt-4 space-y-3",children:[s.notes&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-3",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Notes"}),e.jsx("p",{className:"text-sm",children:s.notes})]}),e.jsx("div",{className:"space-y-2",children:s.files.map(t=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md bg-muted/30",children:[e.jsx(W,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm truncate",children:t.file_name||"Unnamed file"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w(t.file_size||0),t.file_type&&e.jsx("span",{className:"ml-2",children:t.file_type})]})]}),e.jsx(N,{size:"sm",variant:"ghost",onClick:()=>O(t.file_url,t.file_name),children:e.jsx(X,{className:"h-3 w-3"})})]},t.id))})]})]})},s.session_id)})})]})};export{ie 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.