mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
2 lines
5.5 KiB
JavaScript
2 lines
5.5 KiB
JavaScript
import{j as R,g as z,u as P,i as V,d as O,e as E}from"./main.f55cd568.js";import{am as U,g as H,u as J,C as W,r as T,o as i,s as l,w as r,y as n,b as m,v as u,x as d,A as g}from"./vendor.e9042f2c.js";const X={props:{row:{type:Object,default:null},table:{type:Object,default:null}},setup(o){const y=o,S=U("utils"),v=R(),C=z(),D=P(),p=V(),f=O(),{t:s}=H(),k=J(),b=W();async function _(e){p.openDialog({title:s("general.are_you_sure"),message:s("estimates.confirm_delete"),yesLabel:s("general.ok"),noLabel:s("general.cancel"),variant:"danger",hideNoButton:!1,size:"lg"}).then(t=>{e=e,t&&v.deleteEstimate({ids:[e]}).then(a=>{a&&(y.table&&y.table.refresh(),a.data&&b.push("/admin/estimates"),v.$patch(h=>{h.selectedEstimates=[],h.selectAllField=!1}))})})}function $(e){p.openDialog({title:s("general.are_you_sure"),message:s("estimates.confirm_conversion"),yesLabel:s("general.ok"),noLabel:s("general.cancel"),variant:"primary",hideNoButton:!1,size:"lg"}).then(t=>{t&&v.convertToInvoice(e).then(a=>{a.data&&b.push(`/admin/invoices/${a.data.data.id}/edit`)})})}async function x(e){p.openDialog({title:s("general.are_you_sure"),message:s("estimates.confirm_mark_as_sent"),yesLabel:s("general.ok"),noLabel:s("general.cancel"),variant:"primary",hideNoButton:!1,size:"lg"}).then(t=>{const a={id:e,status:"SENT"};t&&v.markAsSent(a).then(h=>{y.table&&y.table.refresh()})})}function N(e){return(e.status=="SENT"||e.status=="VIEWED")&&k.name!=="estimates.view"&&f.hasAbilities(E.SEND_ESTIMATE)}async function I(e){C.openModal({title:s("estimates.send_estimate"),componentName:"SendEstimateModal",id:e.id,data:e,variant:"lg"})}async function B(e){p.openDialog({title:s("general.are_you_sure"),message:s("estimates.confirm_mark_as_accepted"),yesLabel:s("general.ok"),noLabel:s("general.cancel"),variant:"primary",hideNoButton:!1,size:"lg"}).then(t=>{const a={id:e,status:"ACCEPTED"};t&&v.markAsAccepted(a).then(h=>{y.table&&y.table.refresh()})})}async function M(e){p.openDialog({title:s("general.are_you_sure"),message:s("estimates.confirm_mark_as_rejected"),yesLabel:s("general.ok"),noLabel:s("general.cancel"),variant:"primary",hideNoButton:!1,size:"lg"}).then(t=>{const a={id:e,status:"REJECTED"};t&&v.markAsRejected(a).then(h=>{y.table&&y.table.refresh()})})}function L(){let e=`${window.location.origin}/estimates/pdf/${y.row.unique_hash}`;S.copyTextToClipboard(e),D.showNotification({type:"success",message:s("general.copied_pdf_url_clipboard")})}return(e,t)=>{const a=T("BaseIcon"),h=T("BaseButton"),c=T("BaseDropdownItem"),A=T("router-link"),j=T("BaseDropdown");return i(),l(j,null,{activator:r(()=>[n(k).name==="estimates.view"?(i(),l(h,{key:0,variant:"primary"},{default:r(()=>[m(a,{name:"DotsHorizontalIcon",class:"text-white"})]),_:1})):(i(),l(a,{key:1,class:"text-gray-500",name:"DotsHorizontalIcon"}))]),default:r(()=>[n(k).name==="estimates.view"?(i(),l(c,{key:0,onClick:L},{default:r(()=>[m(a,{name:"LinkIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),u(" "+d(e.$t("general.copy_pdf_url")),1)]),_:1})):g("",!0),n(f).hasAbilities(n(E).EDIT_ESTIMATE)?(i(),l(A,{key:1,to:`/admin/estimates/${o.row.id}/edit`},{default:r(()=>[m(c,null,{default:r(()=>[m(a,{name:"PencilIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),u(" "+d(e.$t("general.edit")),1)]),_:1})]),_:1},8,["to"])):g("",!0),n(f).hasAbilities(n(E).DELETE_ESTIMATE)?(i(),l(c,{key:2,onClick:t[0]||(t[0]=w=>_(o.row.id))},{default:r(()=>[m(a,{name:"TrashIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),u(" "+d(e.$t("general.delete")),1)]),_:1})):g("",!0),n(k).name!=="estimates.view"&&n(f).hasAbilities(n(E).VIEW_ESTIMATE)?(i(),l(A,{key:3,to:`estimates/${o.row.id}/view`},{default:r(()=>[m(c,null,{default:r(()=>[m(a,{name:"EyeIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),u(" "+d(e.$t("general.view")),1)]),_:1})]),_:1},8,["to"])):g("",!0),n(f).hasAbilities(n(E).CREATE_INVOICE)?(i(),l(c,{key:4,onClick:t[1]||(t[1]=w=>$(o.row.id))},{default:r(()=>[m(a,{name:"DocumentTextIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),u(" "+d(e.$t("estimates.convert_to_invoice")),1)]),_:1})):g("",!0),o.row.status!=="SENT"&&n(k).name!=="estimates.view"&&n(f).hasAbilities(n(E).SEND_ESTIMATE)?(i(),l(c,{key:5,onClick:t[2]||(t[2]=w=>x(o.row.id))},{default:r(()=>[m(a,{name:"CheckCircleIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),u(" "+d(e.$t("estimates.mark_as_sent")),1)]),_:1})):g("",!0),o.row.status!=="SENT"&&n(k).name!=="estimates.view"&&n(f).hasAbilities(n(E).SEND_ESTIMATE)?(i(),l(c,{key:6,onClick:t[3]||(t[3]=w=>I(o.row))},{default:r(()=>[m(a,{name:"PaperAirplaneIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),u(" "+d(e.$t("estimates.send_estimate")),1)]),_:1})):g("",!0),N(o.row)?(i(),l(c,{key:7,onClick:t[4]||(t[4]=w=>I(o.row))},{default:r(()=>[m(a,{name:"PaperAirplaneIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),u(" "+d(e.$t("estimates.resend_estimate")),1)]),_:1})):g("",!0),o.row.status!=="ACCEPTED"&&n(f).hasAbilities(n(E).EDIT_ESTIMATE)?(i(),l(c,{key:8,onClick:t[5]||(t[5]=w=>B(o.row.id))},{default:r(()=>[m(a,{name:"CheckCircleIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),u(" "+d(e.$t("estimates.mark_as_accepted")),1)]),_:1})):g("",!0),o.row.status!=="REJECTED"&&n(f).hasAbilities(n(E).EDIT_ESTIMATE)?(i(),l(c,{key:9,onClick:t[6]||(t[6]=w=>M(o.row.id))},{default:r(()=>[m(a,{name:"XCircleIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),u(" "+d(e.$t("estimates.mark_as_rejected")),1)]),_:1})):g("",!0)]),_:1})}}};export{X as _};
|