1import{r as a,j as e,L as j,s as g,t as v}from"./index-uqmL3znt.js";import{P as N}from"./AdminShell-7ikT52km.js";import{B as _,c as y}from"./button-DXd8GFaX.js";import{I as S}from"./input-BzvGjV9I.js";import{B as C}from"./badge-Gf5DqUW7.js";import{C as b,a as w,b as k,c as L,d as T}from"./card-C2P1k4KX.js";import{S as A,a as O,b as z,c as B,d as f}from"./select-BvdggXAk.js";import{R}from"./refresh-cw-DuTOXTpl.js";import{S as V}from"./search-D8O4mZC7.js";import{F as E}from"./file-text-C_5cKME5.js";import{f as F,n as I}from"./nl-BvpigCE4.js";import{C as $}from"./chevron-right-B73ic92A.js";import"./send-B2rAm5MD.js";import"./createLucideIcon-kloMjOcl.js";import"./package-DetXK9-W.js";import"./index-C01av-CX.js";import"./Combination-S7cZKz6q.js";import"./index-BwqmJQQc.js";import"./index-D53n6Xkf.js";const i={draft:"Concept",sent:"Verzonden",accepted:"Geaccepteerd",rejected:"Afgewezen",expired:"Verlopen"},D={draft:"outline",sent:"default",accepted:"secondary",rejected:"destructive",expired:"outline"},P=new Intl.NumberFormat("nl-NL",{style:"currency",currency:"EUR"});function ce(){const[o,x]=a.useState([]),[r,m]=a.useState(!0),[c,p]=a.useState(""),[n,h]=a.useState("all");async function d(){m(!0);const{data:t,error:s}=await g.from("quotes").select("id, quote_number, status, customer_name, customer_company, customer_email, total, created_at, valid_until, request_id").order("created_at",{ascending:!1}).limit(500);s?v.error("Offertes laden mislukt",{description:s.message}):x(t??[]),m(!1)}a.useEffect(()=>{d()},[]);const l=a.useMemo(()=>{const t=c.trim().toLowerCase();return o.filter(s=>n!=="all"&&s.status!==n?!1:t?[s.quote_number,s.customer_name,s.customer_company,s.customer_email].filter(Boolean).join(" ").toLowerCase().includes(t):!0)},[o,c,n]);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(N,{title:"Offertes",description:"Opgestelde en verzonden offertes",actions:e.jsxs(_,{variant:"outline",size:"sm",onClick:d,disabled:r,children:[e.jsx(R,{className:y("mr-2 h-4 w-4",r&&"animate-spin")}),"Vernieuwen"]})}),e.jsxs(b,{children:[e.jsx(w,{children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx(k,{children:"Alle offertes"}),e.jsx(L,{children:r?"Laden...":`${l.length} van ${o.length} offertes`})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsxs("div",{className:"relative",children:[e.jsx(V,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(S,{placeholder:"Zoek op nummer of klant...",value:c,onChange:t=>p(t.target.value),className:"pl-9 sm:w-72"})]}),e.jsxs(A,{value:n,onValueChange:t=>h(t),children:[e.jsx(O,{className:"sm:w-48",children:e.jsx(z,{placeholder:"Status"})}),e.jsxs(B,{children:[e.jsx(f,{value:"all",children:"Alle statussen"}),Object.keys(i).map(t=>e.jsx(f,{value:t,children:i[t]},t))]})]})]})]})}),e.jsx(T,{children:r?e.jsx("div",{className:"py-12 text-center text-sm text-muted-foreground",children:"Offertes laden..."}):l.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center",children:[e.jsx(E,{className:"h-10 w-10 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium",children:"Nog geen offertes"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Offertes verschijnen hier zodra je ze opstelt vanuit een aanvraag."})]}):e.jsx("ul",{className:"divide-y rounded-md border",children:l.map(t=>{const s=t.customer_company||t.customer_name||t.customer_email||"Onbekende klant",u=t.request_id?{to:"/app/requests/$id",params:{id:t.request_id}}:{to:"/app/quotes"};return e.jsx("li",{children:e.jsxs(j,{...u,className:"flex items-center gap-4 px-4 py-3 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm font-medium",children:t.quote_number}),e.jsx(C,{variant:D[t.status],children:i[t.status]})]}),e.jsxs("p",{className:"mt-0.5 truncate text-sm text-muted-foreground",children:[s,t.customer_company&&t.customer_name?` · ${t.customer_name}`:""]})]}),e.jsxs("div",{className:"hidden text-right sm:block",children:[e.jsx("div",{className:"text-sm font-medium",children:P.format(Number(t.total)||0)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:F(new Date(t.created_at),{addSuffix:!0,locale:I})})]}),e.jsx($,{className:"h-4 w-4 text-muted-foreground"})]})},t.id)})})})]})]})}export{ce as component};
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.