mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
2 lines
6.2 KiB
JavaScript
2 lines
6.2 KiB
JavaScript
import{G as K,aN as Q,J as W,a0 as j,B as X,ah as Y,k as h,C as Z,A as ee,r as i,o as c,l as f,w as o,f as a,h as l,u as r,i as C,t as _,j as k,e as S,y as te,m as ae,F as se}from"./vendor.01d0adc5.js";import{j as oe,u as re,w as V,x as le}from"./main.7517962b.js";import{u as ne}from"./estimate.69889543.js";import{u as ie}from"./global.1a4e4b86.js";import"./auth.b209127f.js";const de={class:"mr-3 text-sm"},me={class:"fixed top-0 left-0 hidden h-full pt-16 pb-4 bg-white w-88 xl:block"},ce={class:"flex items-center justify-between px-4 pt-8 pb-6 border border-gray-200 border-solid"},ue={class:"flex ml-3",role:"group","aria-label":"First group"},_e={class:"px-4 py-1 pb-2 mb-2 text-sm border-b border-gray-200 border-solid"},pe={class:"px-2"},fe={class:"px-2"},ye={class:"px-2"},be={class:"h-full pb-32 overflow-y-scroll border-l border-gray-200 border-solid sw-scroll"},he={class:"flex-2"},ge={class:"mb-1 text-md not-italic font-medium leading-5 text-gray-500 capitalize"},Be={class:"flex-1 whitespace-nowrap right"},ve={class:"text-sm text-right text-gray-500 non-italic"},xe={key:0,class:"flex justify-center px-4 mt-5 text-sm text-gray-600"},we={class:"flex flex-col min-h-0 mt-8 overflow-hidden",style:{height:"75vh"}},ke=["src"],je={setup(Se){const u=K(),D=Q(),d=ne(),p=ie(),N=oe(),{tm:F,t:y}=W();let g=j({}),e=j({orderBy:"",orderByField:"",estimate_number:""}),B=X(!1);Y("utils"),re();const z=h(()=>d.selectedViewEstimate),E=h(()=>e.orderBy==="asc"||e.orderBy==null);h(()=>E.value?F("general.ascending"):F("general.descending"));const I=h(()=>g.unique_hash?`/estimates/pdf/${g.unique_hash}`:!1);Z(u,()=>{$()}),L(),$(),m=ee.exports.debounce(m,500);function A(t){return u.params.id==t}async function L(){await d.fetchEstimate({limit:"all"},p.companySlug),setTimeout(()=>{R()},500)}async function $(){if(u&&u.params.id){let t=await d.fetchViewEstimate({id:u.params.id},p.companySlug);t.data&&Object.assign(g,t.data.data)}}function R(){const t=document.getElementById(`estimate-${u.params.id}`);t&&(t.scrollIntoView({behavior:"smooth"}),t.classList.add("shake"))}async function m(){let t={};e.estimate_number!==""&&e.estimate_number!==null&&e.estimate_number!==void 0&&(t.estimate_number=e.estimate_number),e.orderBy!==null&&e.orderBy!==void 0&&(t.orderBy=e.orderBy),e.orderByField!==null&&e.orderByField!==void 0&&(t.orderByField=e.orderByField),B.value=!0;try{let n=await d.searchEstimate(t,p.companySlug);B.value=!1,n.data.data&&(d.estimates=n.data.data)}catch{B.value=!1}}function T(){return e.orderBy==="asc"?(e.orderBy="desc",m(),!0):(e.orderBy="asc",m(),!0)}async function U(){N.openDialog({title:y("general.are_you_sure"),message:y("estimates.confirm_mark_as_accepted",1),yesLabel:y("general.ok"),noLabel:y("general.cancel"),variant:"primary",size:"lg",hideNoButton:!1}).then(async t=>{t&&(d.acceptEstimate(p.companySlug,u.params.id),D.push({name:"estimates.dashboard"}))})}return(t,n)=>{const v=i("BaseButton"),G=i("BasePageHeader"),b=i("BaseIcon"),P=i("BaseInput"),x=i("BaseRadio"),w=i("BaseInputGroup"),q=i("BaseEstimateStatusBadge"),H=i("BaseFormatMoney"),M=i("router-link"),O=i("BasePage");return c(),f(O,{class:"xl:pl-96"},{default:o(()=>[a(G,{title:r(z).estimate_number},{actions:o(()=>[l("div",de,[r(d).selectedViewEstimate.status==="DRAFT"?(c(),f(v,{key:0,variant:"primary-outline",onClick:U},{default:o(()=>[C(_(t.$t("estimates.accept_estimate")),1)]),_:1})):k("",!0)])]),_:1},8,["title"]),l("div",me,[l("div",ce,[a(P,{modelValue:r(e).estimate_number,"onUpdate:modelValue":n[0]||(n[0]=s=>r(e).estimate_number=s),placeholder:t.$t("general.search"),type:"text",variant:"gray",onInput:m},{right:o(()=>[a(b,{name:"SearchIcon",class:"h-5 text-gray-400"})]),_:1},8,["modelValue","placeholder"]),l("div",ue,[a(le,{position:"bottom-start","width-class":"w-50","position-class":"left-0"},{activator:o(()=>[a(v,{variant:"gray"},{default:o(()=>[a(b,{name:"FilterIcon",class:"h-5"})]),_:1})]),default:o(()=>[l("div",_e,_(t.$t("general.sort_by")),1),l("div",pe,[a(V,{class:"rounded-md pt-3 hover:rounded-md"},{default:o(()=>[a(w,{class:"-mt-3 font-normal"},{default:o(()=>[a(x,{id:"filter_estimate_date",modelValue:r(e).orderByField,"onUpdate:modelValue":n[1]||(n[1]=s=>r(e).orderByField=s),label:t.$t("reports.estimates.estimate_date"),size:"sm",name:"filter",value:"estimate_date",onChange:m},null,8,["modelValue","label"])]),_:1})]),_:1})]),l("div",fe,[a(V,{class:"rounded-md pt-3 hover:rounded-md"},{default:o(()=>[a(w,{class:"-mt-3 font-normal"},{default:o(()=>[a(x,{id:"filter_due_date",modelValue:r(e).orderByField,"onUpdate:modelValue":[n[2]||(n[2]=s=>r(e).orderByField=s),m],label:t.$t("estimates.due_date"),value:"expiry_date",size:"sm",name:"filter"},null,8,["modelValue","label"])]),_:1})]),_:1})]),l("div",ye,[a(V,{class:"rounded-md pt-3 hover:rounded-md"},{default:o(()=>[a(w,{class:"-mt-3 font-normal"},{default:o(()=>[a(x,{id:"filter_estimate_number",modelValue:r(e).orderByField,"onUpdate:modelValue":[n[3]||(n[3]=s=>r(e).orderByField=s),m],label:t.$t("estimates.estimate_number"),value:"estimate_number",size:"sm",name:"filter"},null,8,["modelValue","label"])]),_:1})]),_:1})])]),_:1}),a(v,{class:"ml-1",variant:"white",onClick:T},{default:o(()=>[r(E)?(c(),f(b,{key:0,name:"SortAscendingIcon",class:"h-5"})):(c(),f(b,{key:1,name:"SortDescendingIcon",class:"h-5"}))]),_:1})])]),l("div",be,[(c(!0),S(se,null,te(r(d).estimates,(s,J)=>(c(),f(M,{id:"estimate-"+s.id,key:J,to:`/${r(p).companySlug}/customer/estimates/${s.id}/view`,class:ae(["flex justify-between p-4 items-center cursor-pointer hover:bg-gray-100 border-l-4 border-transparent",{"bg-gray-100 border-l-4 border-primary-500 border-solid":A(s.id)}]),style:{"border-bottom":"1px solid rgba(185, 193, 209, 0.41)"}},{default:o(()=>[l("div",he,[l("div",ge,_(s.estimate_number),1),a(q,{status:s.status},{default:o(()=>[C(_(s.status),1)]),_:2},1032,["status"])]),l("div",Be,[a(H,{class:"mb-2 text-xl not-italic font-semibold leading-8 text-right text-gray-900 block",amount:s.total,currency:s.currency},null,8,["amount","currency"]),l("div",ve,_(s.formatted_estimate_date),1)])]),_:2},1032,["id","to","class"]))),128)),r(d).estimates.length?k("",!0):(c(),S("p",xe,_(t.$t("estimates.no_matching_estimates")),1))])]),l("div",we,[r(I)?(c(),S("iframe",{key:0,src:r(I),class:"flex-1 border border-gray-400 border-solid rounded-md"},null,8,ke)):k("",!0)])]),_:1})}}};export{je as default};
|