PageSourceSearch

https://litelinxfiber.com/assets/Inquiries-DYGuB8Hl.js

js litelinxfiber.com collected 2026-10-09 22:18:04 UTC 8,399 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-Dw1-o7kh.js";import{u as s,r as t}from"./react-BpC26T6t.js";import{s as r,B as a,F as i,R as l,S as c,C as d,A as n}from"./index-BTs3I-_Y.js";import{R as m}from"./RedirectForm-6Uzs-G4e.js";import{E as o}from"./external-link-CZPW3wXw.js";import{A as x}from"./arrow-up-down-Du4nE51-.js";import{A as u,a as h}from"./arrow-up-CvieMSNg.js";import"./supabase-H1x_w4VC.js";function p(){s();const[p,j]=t.useState([]),[g,f]=t.useState(!0),[N,v]=t.useState(null),[y,w]=t.useState(!1),[b,C]=t.useState(null),[_,k]=t.useState({searchTerm:"",minCount:null,hasRedirect:null,dateFrom:"",dateTo:""}),[R,S]=t.useState(!1),[F,T]=t.useState({}),[A,q]=t.useState("count"),[L,E]=t.useState("desc"),[z,I]=t.useState(!1);async function M(){try{f(!0),I(!0);let e=r.from("inquiries").select("*, redirects(*)").order(A,{ascending:"asc"===L});_.searchTerm&&(e=e.ilike("source",`%${_.searchTerm}%`)),null!==_.minCount&&(e=e.gte("count",_.minCount)),null!==_.hasRedirect&&(e=_.hasRedirect?e.not("redirect_id","is",null):e.is("redirect_id",null)),_.dateFrom&&(e=e.gte("last_accessed",_.dateFrom)),_.dateTo&&(e=e.lte("last_accessed",_.dateTo));const{data:s,error:t}=await e;if(t)throw t;const a={};null==s||s.forEach(e=>{e.redirects&&(a[e.redirect_id]=e.redirects)}),T(a),j(s||[])}catch(e){v(e instanceof Error?e.message:"An error occurred")}finally{f(!1),I(!1)}}t.useEffect(()=>{M()},[]);const D=e=>{A===e?E("asc"===L?"desc":"asc"):(q(e),E("desc")),M()},U=s=>A!==s?e.jsx(x,{className:"h-4 w-4 ml-1"}):"asc"===L?e.jsx(u,{className:"h-4 w-4 ml-1"}):e.jsx(h,{className:"h-4 w-4 ml-1"});return g&&!z?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("div",{className:"text-gray-600",children:"Loading inquiries..."})}):N?e.jsxs("div",{className:"bg-red-50 border border-red-200 text-red-700 p-4 rounded-md",children:["Error: ",N]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-secondary",children:"404 Inquiries"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(a,{variant:"outline",onClick:()=>S(!R),children:[e.jsx(i,{className:"h-4 w-4 mr-2"}),"Filters"]}),e.jsxs(a,{variant:"outline",onClick:M,disabled:z,children:[e.jsx(l,{className:"h-4 w-4 mr-2 "+(z?"animate-spin":"")}),z?"Refreshing...":"Refresh"]})]})]}),R&&e.jsxs("div",{className:"bg-white rounded-lg shadow-sm p-6 mb-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Search"}),e.jsxs("div",{className:"relative",children:[e.jsx(c,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 h-5 w-5"}),e.jsx("input",{type:"text",value:_.searchTerm,onChange:e=>k({..._,searchTerm:e.target.value}),placeholder:"Search source URL...",className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-md"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Minimum Count"}),e.jsx("input",{type:"number",value:_.minCount||"",onChange:e=>k({..._,minCount:e.target.value?parseInt(e.target.value):null}),placeholder:"Minimum hits",className:"w-full px-3 py-2 border border-gray-300 rounded-md",min:"1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Has Redirect"}),e.jsxs("select",{value:null===_.hasRedirect?"":_.hasRedirect?"true":"false",onChange:e=>k({..._,hasRedirect:""===e.target.value?null:"true"===e.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md",children:[e.jsx("option",{value:"",children:"All"}),e.jsx("option",{value:"true",children:"Yes"}),e.jsx("option",{value:"false",children:"No"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Date Range"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("input",{type:"date",value:_.dateFrom,onChange:e=>k({..._,dateFrom:e.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md"}),e.jsx("input",{type:"date",value:_.dateTo,onChange:e=>k({..._,dateTo:e.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md"})]})]})]}),e.jsxs("div",{className:"mt-4 flex justify-end",children:[e.jsx(a,{variant:"outline",onClick:()=>{k({searchTerm:"",minCount:null,hasRedirect:null,dateFrom:"",dateTo:""}),q("count"),E("desc"),M()},className:"mr-2",children:"Reset"}),e.jsx(a,{onClick:()=>{M()},children:"Apply Filters"})]})]}),e.jsx("div",{className:"bg-white rounded-lg shadow",children:0===p.length?e.jsx("div",{className:"p-8 text-center",children:e.jsx("p",{className:"text-gray-600 mb-4",children:"No inquiries found"})}):e.jsx("div",{className:"overflow-x-auto",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 cursor-pointer",onClick:()=>D("source"),children:e.jsxs("div",{className:"flex items-center",children:["Source URL",U("source")]})}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer",onClick:()=>D("count"),children:e.jsxs("div",{className:"flex items-center",children:["Count",U("count")]})}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer",onClick:()=>D("last_accessed"),children:e.jsxs("div",{className:"flex items-center",children:["Last Accessed",U("last_accessed")]})}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Redirect"}),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(s=>{var t,r,i,l;return e.jsxs("tr",{children:[e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900",children:s.source}),s.referrer&&e.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:["From: ",s.referrer]})]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"text-sm text-gray-900 font-medium",children:s.count})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"text-sm text-gray-500 flex items-center",children:[e.jsx(d,{className:"h-3.5 w-3.5 mr-1 text-gray-400"}
1),(l=s.last_accessed,new Date(l).toLocaleString())]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:s.redirect_id?e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-center text-primary",children:[e.jsx(n,{className:"h-4 w-4 mr-1"}),e.jsx("span",{children:null==(t=F[s.redirect_id])?void 0:t.destination})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:["Status: ",null==(r=F[s.redirect_id])?void 0:r.status_code,(null==(i=F[s.redirect_id])?void 0:i.is_active)?"":" (Inactive)"]})]}):e.jsx("span",{className:"text-sm text-gray-500",children:"No redirect"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:s.redirect_id?e.jsx(a,{variant:"outline",size:"sm",as:"a",href:`/admin/redirects?id=${s.redirect_id}`,className:"text-primary",children:e.jsx(o,{className:"h-4 w-4"})}):e.jsxs(a,{variant:"outline",size:"sm",onClick:()=>(e=>{C(e),w(!0)})(s),className:"text-primary",children:[e.jsx(n,{className:"h-4 w-4 mr-2"}),"Create Redirect"]})})]},s.id)})})]})})}),y&&b&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-2xl mx-auto",children:e.jsx(m,{redirect:{id:"",source:b.source,destination:"",status_code:301,is_active:!0,created_at:"",updated_at:""},onSubmit:async e=>{try{const{data:s,error:t}=await r.from("redirects").insert([e]).select().single();if(t)throw t;const{error:a}=await r.from("inquiries").update({redirect_id:s.id}).eq("id",b.id);if(a)throw a;w(!1),C(null),await M()}catch(s){alert("Failed to create redirect")}},onCancel:()=>{w(!1),C(null)}})})})]})}export{p as AdminInquiries};

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.