import{K as W,Z as E,ag as S,ac as U,S as r,L as _,P as u,b as e,M as n,U as i,V as a,T as o,X as p,W as l,a7 as m,N as H,O as K}from"./vendor-bSWkQivH.js";import{y as M,i as R}from"./index-Dqv5IkpS.js";import{u as X}from"./useBreadcrumbs-Bvh8-Tkx.js";import{u as Z,_ as j}from"./quote-line-items.vue_vue_type_style_index_0_lang-BwdflVss.js";import{_ as k}from"./address-info.vue_vue_type_script_setup_true_lang-NeLSyVv_.js";import{d as G}from"./index-D-4abmdp.js";import{_ as J}from"./quote-status.vue_vue_type_style_index_0_lang-D0trdr7i.js";import{_ as Y}from"./quote-summary.vue_vue_type_script_setup_true_lang-C9wjg8iU.js";import"./getQuotesQuery-C9NfC5i7.js";const tt={key:0},et={class:"space-y-3"},st={key:0,class:"flex flex-wrap gap-3 max-md:mt-5"},at={class:"text-base"},ot={class:"space-y-2 rounded border border-neutral-200 px-3 py-4"},nt={class:"space-y-1"},it={class:"flex text-base"},rt={class:"mr-2 font-bold"},lt={class:"flex items-center gap-2"},ct={class:"text-base font-bold"},vt=W({__name:"view-quote",props:{quoteId:{}},setup(w){var v;const f=w,{t:c}=E(),{quote:s,billingAddress:b,approveItem:B,declineItem:x,shippingAddress:h,fetchQuote:y}=Z(),g=M(),I=S();R({title:c("quote_details.title",[(v=s.value)==null?void 0:v.number])});async function C(){try{const t=await B(s.value.id);await I.push({name:"OrderDetails",params:{orderId:t.orderId}})}catch{g.error({text:c("quote_details.error.approve")})}}async function L(){try{await x(s.value.id),await y({id:f.quoteId})}catch{g.error({text:c("quote_details.error.decline")})}}const N=X(()=>{var t;return[{title:c("common.links.account"),route:{name:"Account"}},{title:c("quotes.navigation.route_name"),route:{name:"Quotes"}},{title:c("quote_details.title",[(t=s==null?void 0:s.value)==null?void 0:t.number])}]});U(async()=>{await y({id:f.quoteId})});function F(t){return{...t,status:"attached"}}function z(t){G(t.url,t.name)}return(t,dt)=>{const D=r("VcBreadcrumbs"),O=r("VcTypography"),q=r("VcButton"),V=r("VcLayout"),d=r("VcWidget"),T=r("VcFile"),A=r("VcLoaderOverlay");return e(s)?(n(),_("div",tt,[i("div",et,[a(D,{items:e(N)},null,8,["items"])]),a(V,{"sidebar-position":"right"},{sidebar:o(()=>[e(s).status==="Proposal sent"?(n(),_("div",st,[a(q,{class:"grow",variant:"outline",onClick:L},{default:o(()=>[p(l(t.$t("common.buttons.decline")),1)]),_:1}),a(q,{class:"grow",onClick:C},{default:o(()=>[p(l(t.$t("common.buttons.approve")),1)]),_:1})])):m("",!0)]),default:o(()=>[a(O,{tag:"h1"},{default:o(()=>[p(l(t.$t("quote_details.title",[e(s).number])),1)]),_:1})]),_:1}),a(V,{"sidebar-position":"right"},{sidebar:o(()=>[a(Y,{quote:e(s),class:"mb-5 max-md:mt-5"},null,8,["quote"]),a(d,{title:t.$t("quote_details.quote_data"),class:"mb-5 max-md:order-first"},{default:o(()=>[i("div",nt,[i("div",it,[i("span",rt,l(t.$t("quote_details.created"))+":",1),i("span",null,l(t.$d(e(s).createdDate)),1)]),i("div",lt,[i("span",ct,l(t.$t("quote_details.status"))+":",1),a(J,{size:"sm",status:e(s).status},null,8,["status"])])])]),_:1},8,["title"]),e(h)?(n(),u(d,{key:0,title:t.$t("quote_details.shipping_address"),class:"mb-5"},{default:o(()=>[a(e(k),{address:e(h)},null,8,["address"])]),_:1},8,["title"])):m("",!0),e(b)?(n(),u(d,{key:1,title:t.$t("quote_details.billing_address")},{default:o(()=>[a(e(k),{address:e(b)},null,8,["address"])]),_:1},8,["title"])):m("",!0)]),default:o(()=>{var $;return[a(d,{size:"lg"},{default:o(()=>[a(j,{items:e(s).items,readonly:""},null,8,["items"])]),_:1}),e(s).comment?(n(),u(d,{key:0,title:t.$t("quote_details.comment"),"prepend-icon":"document-text",size:"lg",class:"mt-5"},{default:o(()=>[i("div",at,l(e(s).comment),1)]),_:1},8,["title"])):m("",!0),($=e(s).attachments)!=null&&$.length?(n(),u(d,{key:1,title:t.$t("quote_details.files"),size:"lg","prepend-icon":"document-text",class:"mt-5"},{default:o(()=>[i("ul",ot,[(n(!0),_(H,null,K(e(s).attachments,(P,Q)=>(n(),_("li",{key:Q},[a(T,{file:F(P),onDownload:z},null,8,["file"])]))),128))])]),_:1},8,["title"])):m("",!0)]}),_:1})])):(n(),u(A,{key:1,"no-bg":""}))}}});export{vt as default};
//# sourceMappingURL=view-quote-DjC1p3qE.js.map
