PageSourceSearch

https://app.treeninja.ai/assets/Storms-Cjm6tbeM.js

js treeninja.ai collected 2026-10-05 13:09:03 UTC 4,737 bytes, 1 lines download raw bytes

1import{r as l,F as k,j as e,cu as I,B as o,aI as E,G as v,H as N,J as y,M as w,bg as R,I as z,Y as T,bt as C,E as D,L as S,g as B}from"./index-C8KwbIXq.js";import{a as q,u as H,S as G}from"./storm-card-BfQcaPdn.js";import{C as $}from"./CommonPageContainer-Ch04DT1k.js";import{F as J}from"./funnel-Bb7w8NfE.js";import"./vendor-offline-DCjJAT_B.js";import"./format-location-3NQVLEpY.js";import"./map-pin-DpsKzuLf.js";import"./megaphone-lVYAJZD9.js";function _(){const[r,L]=l.useState(""),[a,m]=l.useState("all"),[x,b]=l.useState(!1),f=l.useRef(null),{statuses:M}=k(),A=M.googleAds,F=q(),{data:d,fetchNextPage:p,hasNextPage:h,isFetchingNextPage:u,isLoading:P}=H({queryKey:["/api/storm-events","infinite",a],queryFn:async({pageParam:t=1})=>{const s=new URLSearchParams;return s.set("page",t.toString()),s.set("limit","20"),a&&a!=="all"&&s.set("severity",a),await B("GET",`/api/storm-events?${s.toString()}`)},getNextPageParam:t=>{const{pagination:s}=t;if(s.page<s.totalPages)return s.page+1},initialPageParam:1}),j=l.useMemo(()=>d!=null&&d.pages?d.pages.flatMap(t=>t.data):[],[d]),n=l.useMemo(()=>{const t=Date.now()-108e5;return j.filter(s=>{var i;if(r){const c=s.location.toLowerCase(),g=r.toLowerCase();if(!(c.includes(g)||c.includes(g.substring(0,2))||((i=s.description)==null?void 0:i.toLowerCase().includes(g))))return!1}return!(x&&new Date(s.createdAt||s.date).getTime()<t)}).sort((s,i)=>new Date(i.createdAt||i.date).getTime()-new Date(s.createdAt||s.date).getTime())},[j,r,x]);return l.useEffect(()=>{const t=new IntersectionObserver(i=>{var c;(c=i[0])!=null&&c.isIntersecting&&h&&!u&&p()},{threshold:.1}),s=f.current;return s&&t.observe(s),()=>{s&&t.unobserve(s)}},[h,u,p]),e.jsxs($,{children:[e.jsxs("div",{className:"flex flex-col space-x-4",children:[e.jsx(I,{href:"/",children:e.jsxs(o,{variant:"ghost",size:"sm",children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Back to Dashboard"]})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-gray-900 whitespace-nowrap",children:"All Storm Events"}),e.jsxs("p",{className:"text-gray-600",children:[(n==null?void 0:n.length)||0," storm events found"]})]})]}),e.jsxs(v,{className:"mb-8",children:[e.jsx(N,{children:e.jsxs(y,{className:"flex items-center",children:[e.jsx(J,{className:"mr-2 h-5 w-5"}),"Filters"]})}),e.jsx(w,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsx("div",{className:"flex-1 min-w-64",children:e.jsxs("div",{className:"relative",children:[e.jsx(R,{className:"absolute left-3 top-3 h-4 w-4 text-gray-400"}),e.jsx(z,{type:"text",placeholder:"Search by location, state, or description...",className:"pl-10",value:r,onChange:t=>L(t.target.value)})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"Severity:"}),e.jsx(o,{variant:a==="all"?"default":"outline",size:"sm",onClick:()=>m("all"),children:"All"}),e.jsx(o,{variant:a==="Extreme"?"default":"outline",size:"sm",onClick:()=>m("Extreme"),children:"Extreme"}),e.jsx(o,{variant:a==="Severe"?"default":"outline",size:"sm",onClick:()=>m("Severe"),children:"Severe"}),e.jsx(o,{variant:a==="Moderate"?"default":"outline",size:"sm",onClick:()=>m("Moderate"),children:"Moderate"}),e.jsx(o,{variant:a==="Minor"?"default":"outline",size:"sm",onClick:()=>m("Minor"),children:"Minor"}),e.jsxs(o,{variant:x?"default":"outline",size:"sm",onClick:()=>b(!x),children:[e.jsx(T,{className:"h-3 w-3 mr-1"}),"Recent"]})]})]})})]}),e.jsxs(v,{children:[e.jsx(N,{children:e.jsxs(y,{className:"flex items-center",children:[e.jsx(C,{className:"mr-2 h-5 w-5"}),"Storm Events",r&&e.jsx(D,{variant:"secondary",className:"ml-2",children:r})]})}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4 max-h-[600px] overflow-y-auto",children:P?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(S,{className:"h-8 w-8 text-gray-400 mx-auto mb-4 animate-spin"}),e.jsx("p",{className:"text-gray-500",children:"Loading storm events..."})]}):n!=null&&n.length?e.jsxs(e.Fragment,{children:[n.map(t=>e.jsx(G,{event:t,googleAdsStatus:A,hasActiveCampaign:F.has(t.id)},t.id)),e.jsxs("div",{ref:f,className:"h-10 flex items-center justify-center",children:[u&&e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsx(S,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading more..."})]}),!h&&n.length>0&&e.jsx("p",{className:"text-sm text-gray-500",children:"No more storm events to load"})]})]}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(C,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500",children:r?`No storm events found for "${r}"`:"No storm events found"})]})})})]})]})}export{_ 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.