PageSourceSearch

https://os.sosme.ai/assets/EvaluateQuotationsPage-D0nzVwcZ.js

js sosme.ai collected 2026-10-05 15:13:17 UTC 8,509 bytes, 1 lines download raw bytes

1import{u as D,a as k,r as N,j as e,L as $,W as u,g as R,l as b,b4 as T,aA as y}from"./index-DelWp-6b.js";import{u as U,a as E,h as F}from"./useSourcingRequests-BqcJw0t0.js";import{C as Q}from"./ConfirmDialog-BhY8nNq0.js";import{S as I}from"./StatusBadge-akHmAz-X.js";import{C as M}from"./circle-check-big-BNy0DKH2.js";import"./useQuery-B9eAwr7I.js";import"./useMutation-CwYdRQCa.js";import"./purchase.service-B2GUOycb.js";import"./axios-B9iLQH_W.js";import"./clsx-B-dksMZM.js";import"./bundle-mjs-BvL7hA86.js";function _(){const{rfqId:l}=D(),v=k(),{data:o,isLoading:w}=U(l),{data:h,isLoading:S}=E(l),p=F(),[d,m]=N.useState(null),r=Array.isArray(h)?h:[],{itemRows:g,vendorTotals:P}=N.useMemo(()=>{const t=new Map;r.forEach(s=>{s.items.forEach(i=>{t.has(i.description)||t.set(i.description,{uom:i.uom,quantity:i.quantity})})});const x=Array.from(t.entries()).map(([s,i])=>{const j=r.map(n=>{const c=n.items.find(A=>A.description===s);return{quotationId:n.id,vendorName:n.vendorName,unitPrice:c==null?void 0:c.unitPrice,totalPrice:c==null?void 0:c.totalPrice}}),f=j.filter(n=>n.totalPrice!=null).map(n=>n.totalPrice),L=f.length>0?Math.min(...f):null;return{description:s,uom:i.uom,prices:j,lowestPrice:L}}),a=r.map(s=>({id:s.id,vendorName:s.vendorName,total:s.totalAmount,currency:s.currency,isSelected:s.isSelected,status:s.statusDisplay}));return{itemRows:x,vendorTotals:a}},[r]),C=()=>{d&&p.mutate(d,{onSuccess:()=>{y.success("Vendor selected as winner!"),m(null),v(`/purchasing/rfqs/${l}`)},onError:()=>y.error("Failed to select vendor")})};return w||S?e.jsx("div",{className:"p-10 flex justify-center",children:e.jsx($,{className:"w-8 h-8 animate-spin text-[var(--primary-500)]"})}):o?e.jsxs("div",{className:"max-w-7xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(u,{to:`/purchasing/rfqs/${l}`,className:"w-10 h-10 flex items-center justify-center bg-white rounded-full shadow-sm text-slate-500 hover:text-slate-900 transition-colors",children:e.jsx(R,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-900",children:"Quotation Comparison"}),e.jsxs("p",{className:"text-sm text-slate-500 mt-1",children:[o.sourcingRequestNumber,o.description?` • ${o.description}`:""]})]})]}),r.length===0?e.jsxs("div",{className:"bg-white rounded-xl shadow-card p-16 text-center text-slate-400",children:[e.jsx(b,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"font-medium",children:"No quotations to compare"}),e.jsx("p",{className:"text-sm mt-1",children:"Add vendor quotations from the sourcing request detail page first."}),e.jsx(u,{to:`/purchasing/rfqs/${l}`,className:"inline-block mt-4 px-4 py-2 bg-[var(--primary-500)] text-white rounded-lg text-sm font-medium hover:bg-[var(--primary-600)] transition-colors",children:"Back to Sourcing Request"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-white rounded-xl shadow-card overflow-x-auto",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-700",children:"Price Comparison Matrix"}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Green cells indicate the lowest price per line item"})]}),e.jsxs("table",{className:"w-full text-sm text-left",children:[e.jsx("thead",{className:"bg-slate-50 border-b border-slate-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 font-medium text-slate-500 sticky left-0 bg-slate-50 z-10 w-64 min-w-[200px]",children:"Item Description"}),e.jsx("th",{className:"px-4 py-3 font-medium text-slate-500 text-center w-20",children:"UOM"}),r.map(t=>e.jsxs("th",{className:"px-4 py-3 font-semibold text-slate-800 text-right min-w-[160px]",children:[e.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[t.isSelected&&e.jsx(b,{className:"w-4 h-4 text-green-500 shrink-0"}),e.jsx("span",{className:"truncate",children:t.vendorName})]}),e.jsx("div",{className:"text-xs font-normal text-slate-400 mt-0.5",children:t.quotationNumber})]},t.id))]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:g.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:2+r.length,className:"px-4 py-8 text-center text-slate-400 text-sm",children:"Quotations have no line items"})}):g.map((t,x)=>e.jsxs("tr",{className:"hover:bg-[var(--primary-50)]/30",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-slate-900 sticky left-0 bg-white z-10 max-w-[200px] truncate",title:t.description,children:t.description}),e.jsx("td",{className:"px-4 py-3 text-center text-slate-500 text-xs",children:t.uom}),t.prices.map((a,s)=>{const i=a.totalPrice!=null&&a.totalPrice===t.lowestPrice;return e.jsxs("td",{className:`px-4 py-3 text-right font-medium ${i?"bg-green-50 text-green-700":a.totalPrice!=null?"text-slate-800":"text-slate-300"}
1`,children:[a.totalPrice!=null?a.totalPrice.toLocaleString("en-US",{minimumFractionDigits:2}):"—",a.unitPrice!=null&&e.jsxs("div",{className:"text-xs font-normal text-slate-400 mt-0.5",children:["@ ",a.unitPrice.toLocaleString("en-US",{minimumFractionDigits:2})," each"]})]},s)})]},x))}),e.jsx("tfoot",{className:"bg-slate-50 border-t-2 border-slate-200 font-semibold",children:e.jsxs("tr",{children:[e.jsx("td",{colSpan:2,className:"px-4 py-4 text-right text-slate-600",children:"Grand Total"}),P.map(t=>e.jsx("td",{className:"px-4 py-4 text-right",children:t.total!=null?e.jsxs("span",{className:"text-lg text-[var(--primary-500)]",children:[t.total.toLocaleString("en-US",{minimumFractionDigits:2})," ",t.currency]}):e.jsx("span",{className:"text-slate-400",children:"—"})},t.id))]})})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:r.map(t=>e.jsxs("div",{className:`bg-white p-5 rounded-xl shadow-card border-2 relative ${t.isSelected?"border-green-500":"border-transparent"}`,children:[t.isSelected&&e.jsx("div",{className:"absolute top-0 right-0 bg-green-500 text-white text-xs font-bold px-3 py-1 rounded-bl-lg rounded-tr-xl",children:"WINNER"}),e.jsx("h3",{className:"font-bold text-slate-900 mb-1 pr-16 truncate",children:t.vendorName}),e.jsx("p",{className:"text-xs text-slate-400 mb-3",children:t.quotationNumber}),e.jsxs("div",{className:"space-y-1.5 text-sm mb-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-500",children:"Status"}),e.jsx(I,{status:t.statusDisplay})]}),e.jsxs("div",{className:"flex justify-between border-t border-slate-100 pt-1.5",children:[e.jsx("span",{className:"text-slate-500",children:"Total Amount"}),e.jsx("span",{className:"font-bold text-[var(--primary-500)]",children:t.totalAmount!=null?`${t.totalAmount.toLocaleString("en-US",{minimumFractionDigits:2})} ${t.currency||""}`:"—"})]}),t.paymentTerms&&e.jsxs("div",{className:"flex justify-between border-t border-slate-100 pt-1.5",children:[e.jsx("span",{className:"text-slate-500",children:"Payment"}),e.jsx("span",{className:"text-slate-700 text-xs",children:t.paymentTerms})]}),t.validUntil&&e.jsxs("div",{className:"flex justify-between border-t border-slate-100 pt-1.5",children:[e.jsx("span",{className:"text-slate-500",children:"Valid Until"}),e.jsx("span",{className:"text-slate-700 text-xs",children:new Date(t.validUntil).toLocaleDateString()})]})]}),e.jsxs("div",{className:"space-y-2",children:[!t.isSelected&&o.statusDisplay!=="Closed"&&o.statusDisplay!=="Cancelled"&&e.jsxs("button",{onClick:()=>m(t.id),className:"w-full py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium flex items-center justify-center gap-2 transition-colors",children:[e.jsx(M,{className:"w-4 h-4"}),"Select Winner"]}),t.isSelected&&e.jsxs(u,{to:`/purchasing/purchase-orders/new?sourcingId=${l}&quotationId=${t.id}`,className:"w-full py-2 bg-[var(--primary-500)] hover:bg-[var(--primary-600)] text-white rounded-lg text-sm font-medium flex items-center justify-center gap-2 transition-colors",children:[e.jsx(T,{className:"w-4 h-4"}),"Create Purchase Order"]})]})]},t.id))})]}),e.jsx(Q,{isOpen:!!d,title:"Select Vendor as Winner",message:"Selecting this vendor will mark them as the winner for this sourcing request. All other quotations will be marked as not selected. Are you sure?",confirmText:p.isPending?"Selecting...":"Select Winner",onConfirm:C,onCancel:()=>m(null)})]}):e.jsx("div",{className:"p-10 text-center text-red-500",children:"Failed to load sourcing request"})}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.