1import{j as s}from"./ui-vendor-B12AOeKi.js";import{r as o}from"./react-vendor-DZt7wVAJ.js";import{P as _,q as N,g as x,B as u,al as y,s as c,i as p}from"./index-BZo64Z7H.js";import{g as w}from"./api-yesdblu2.js";import{u as C}from"./useScope-EqU563EW.js";import{C as b}from"./circle-check-big-3X4sON1s.js";import"./charts-vendor-B6q1L48j.js";import"./supabase-vendor-dOy44Gxq.js";import"./animation-vendor-BAVy02gd.js";function I(){const{canSeeAll:i,userId:a,ready:d}=C(),[m,f]=o.useState([]),[h,r]=o.useState(!0);async function l(){const e=await w();if(!e)return r(!1);let t=c.from("m360_alerts").select("*, m360_vehicles(year,make,model,vin,assigned_user_id)").eq("dealership_id",e).eq("status","open").order("created_at",{ascending:!1});!i&&a&&(t=t.eq("assigned_user_id",a));const{data:n}=await t;f(n||[]),r(!1)}o.useEffect(()=>{if(d){if(!i&&!a){r(!1);return}l()}},[d,i,a]);async function v(e){await c.from("m360_alerts").update({status:"resolved",resolved_at:new Date().toISOString()}).eq("id",e),p.success("Resolved"),l()}async function g(e){const t=new Date(Date.now()+864e5).toISOString();await c.from("m360_alerts").update({status:"snoozed",snoozed_until:t}).eq("id",e),p.success("Snoozed 24h"),l()}return h?s.jsxs("div",{className:"p-8 flex items-center gap-2 text-[#9FB3C8]",children:[s.jsx(_,{className:"h-4 w-4 animate-spin"}),"Loadingâ¦"]}):s.jsxs("div",{className:"p-6 space-y-4",children:[s.jsx("h1",{className:"text-2xl font-semibold text-[#E6EDF3]",children:"Sold & Likely-Sold Alerts"}),s.jsxs("div",{className:"space-y-2",children:[m.map(e=>{const t=e.alert_type==="likely_sold_active_listing",n=t?"Likely Sold":"Sold",j=t?"bg-amber-500/15 text-amber-200 border-amber-500/30":"bg-red-500/15 text-red-200 border-red-500/30";return s.jsxs(N,{className:"p-3 bg-white/[0.03] border-white/10 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(x,{variant:"outline",className:`text-xs ${j}`,children:n}),s.jsx(x,{variant:"outline",className:"text-xs",children:e.severity}),s.jsx("span",{className:"text-sm font-medium text-white",children:e.title})]}),s.jsx("div",{className:"text-xs text-[#9FB3C8] mt-1",children:e.message}),e.m360_vehicles&&s.jsxs("div",{className:"text-xs text-[#B8C7D9] mt-1",children:[e.m360_vehicles.year," ",e.m360_vehicles.make," ",e.m360_vehicles.model," · ",e.m360_vehicles.vin]})]}),s.jsxs(u,{size:"sm",variant:"outline",onClick:()=>g(e.id),children:[s.jsx(y,{className:"h-3.5 w-3.5 mr-1.5"}),"Snooze"]}),s.jsxs(u,{size:"sm",onClick:()=>v(e.id),className:"bg-gradient-to-r from-[#2F80ED] to-[#1C5ED6]",children:[s.jsx(b,{className:"h-3.5 w-3.5 mr-1.5"}),"Mark Removed"]})]},e.id)}),m.length===0&&s.jsx("div",{className:"text-sm text-[#9FB3C8]",children:"No open alerts."})]})]})}export{I 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.