import{r as d,j as t,H as y,L as m,a as o}from"./app-BQEFzdw6.js";import{A as g,a as j}from"./AppLayout-kozc03ce.js";import{P as f}from"./PageHeader-Bj1OQnqr.js";import{B as N}from"./Badge-CiLdjUlo.js";import{a as v}from"./formatters-ClI693-F.js";import{F as b}from"./PlusIcon-ElxOOThC.js";import"./useThemeColor-qPCpc713.js";import"./dayjs.min-BDUBcDj6.js";function p(s){return Number(s||0).toLocaleString("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2})}function k({estimations:s,filters:r}){const[i,h]=d.useState((r==null?void 0:r.search)??""),[c,u]=d.useState((r==null?void 0:r.status)??""),l=(s==null?void 0:s.data)??[];function n(e={}){const a={search:i,status:c,...e};Object.keys(a).forEach(x=>{a[x]||delete a[x]}),o.get(route("cost-estimations.index"),a,{preserveState:!0,replace:!0})}return t.jsxs(g,{children:[t.jsx(y,{title:"Cost Estimations"}),t.jsx(f,{title:"Cost Estimations",subtitle:`${(s==null?void 0:s.total)??l.length} total`,children:t.jsxs(m,{href:route("cost-estimations.create"),className:"btn btn-primary flex items-center gap-2 text-sm",children:[t.jsx(b,{className:"w-4 h-4"})," New Estimation"]})}),t.jsx("div",{className:"px-6 py-3 border-b border-gray-100 bg-gray-50",children:t.jsxs("form",{onSubmit:e=>{e.preventDefault(),n()},className:"flex items-center gap-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx(j,{className:"w-4 h-4 text-gray-400 absolute left-2.5 top-2.5"}),t.jsx("input",{type:"search",placeholder:"Search code, title…",className:"form-input pl-8 text-sm py-2 w-60",value:i,onChange:e=>h(e.target.value)})]}),t.jsxs("select",{className:"form-input text-sm py-2",value:c,onChange:e=>{u(e.target.value),n({status:e.target.value})},children:[t.jsx("option",{value:"",children:"All"}),t.jsx("option",{value:"draft",children:"Draft"}),t.jsx("option",{value:"final",children:"Final"})]}),t.jsx("button",{type:"submit",className:"btn btn-secondary text-sm",children:"Search"})]})}),t.jsx("div",{className:"p-4 sm:p-6",children:t.jsx("div",{className:"card overflow-hidden",children:t.jsxs("table",{className:"min-w-full divide-y divide-gray-200 text-sm",children:[t.jsx("thead",{className:"bg-gray-50",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Code"}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Title"}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Lead / Client"}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Status"}),t.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase",children:"Estimated Cost"}),t.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase",children:"Markup"}),t.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase",children:"Suggested Quote"}),t.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Date"})]})}),t.jsxs("tbody",{className:"divide-y divide-gray-100 bg-white",children:[l.length===0&&t.jsx("tr",{children:t.jsxs("td",{colSpan:8,className:"px-4 py-10 text-center text-gray-400",children:["No cost estimations yet."," ",t.jsx(m,{href:route("cost-estimations.create"),className:"text-primary-600 hover:underline",children:"Create one"})]})}),l.map(e=>{var a,x;return t.jsxs("tr",{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>o.get(route("cost-estimations.show",e.id)),children:[t.jsx("td",{className:"px-4 py-3 font-medium text-gray-900",children:e.code}),t.jsx("td",{className:"px-4 py-3 text-gray-700 max-w-xs truncate",children:e.title}),t.jsx("td",{className:"px-4 py-3 text-gray-600",children:((a=e.client)==null?void 0:a.name)??((x=e.lead)==null?void 0:x.name)??t.jsx("span",{className:"text-gray-300",children:"—"})}),t.jsx("td",{className:"px-4 py-3",children:t.jsx(N,{status:e.status})}),t.jsxs("td",{className:"px-4 py-3 text-right font-medium text-gray-700",children:[p(e.total_estimated),"৳"]}),t.jsxs("td",{className:"px-4 py-3 text-right text-sm text-green-600",children:[e.markup_pct,"%"]}),t.jsxs("td",{className:"px-4 py-3 text-right font-bold text-primary-700",children:[p(e.suggested_quote),"৳"]}),t.jsx("td",{className:"px-4 py-3 text-xs text-gray-400",children:v(e.created_at)})]},e.id)})]})]})})})]})}export{k as default};
