mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
2 lines
4.6 KiB
JavaScript
2 lines
4.6 KiB
JavaScript
import{g as O,u as j,C as z,am as R,r as h,o as r,s as l,w as o,y as c,b as s,Z as M,al as P,v as d,x as v,A as m}from"./vendor.e9042f2c.js";import{f as F,g as U,u as H,i as W,d as q,e as f}from"./main.366b2ac6.js";const J={props:{row:{type:Object,default:null},table:{type:Object,default:null},loadData:{type:Function,default:()=>{}}},setup(a){const w=a,p=F(),$=U(),N=H(),b=W(),g=q(),{t:i}=O(),y=j(),S=z(),x=R("utils");function _(e){return(e.status=="SENT"||e.status=="VIEWED")&&y.name!=="invoices.view"&&g.hasAbilities(f.SEND_INVOICE)}function D(e){return e.status=="DRAFT"&&y.name!=="invoices.view"&&g.hasAbilities(f.SEND_INVOICE)}async function B(e){b.openDialog({title:i("general.are_you_sure"),message:i("invoices.confirm_delete"),yesLabel:i("general.ok"),noLabel:i("general.cancel"),variant:"danger",hideNoButton:!1,size:"lg"}).then(n=>{e=e,n&&p.deleteInvoice({ids:[e]}).then(t=>{t.data.success&&(S.push("/admin/invoices"),w.table&&w.table.refresh(),p.$patch(I=>{I.selectedInvoices=[],I.selectAllField=!1}))})})}async function A(e){b.openDialog({title:i("general.are_you_sure"),message:i("invoices.confirm_clone"),yesLabel:i("general.ok"),noLabel:i("general.cancel"),variant:"primary",hideNoButton:!1,size:"lg"}).then(n=>{n&&p.cloneInvoice(e).then(t=>{S.push(`/admin/invoices/${t.data.data.id}/edit`)})})}async function T(e){b.openDialog({title:i("general.are_you_sure"),message:i("invoices.invoice_mark_as_sent"),yesLabel:i("general.ok"),noLabel:i("general.cancel"),variant:"primary",hideNoButton:!1,size:"lg"}).then(n=>{const t={id:e,status:"SENT"};n&&p.markAsSent(t).then(I=>{w.table&&w.table.refresh()})})}async function E(e){$.openModal({title:i("invoices.send_invoice"),componentName:"SendInvoiceModal",id:e.id,data:e,variant:"sm"})}function V(){let e=`${window.location.origin}/invoices/pdf/${w.row.unique_hash}`;x.copyTextToClipboard(e),N.showNotification({type:"success",message:i("general.copied_pdf_url_clipboard")})}return(e,n)=>{const t=h("BaseIcon"),I=h("BaseButton"),u=h("BaseDropdownItem"),C=h("router-link"),L=h("BaseDropdown");return r(),l(L,null,{activator:o(()=>[c(y).name==="invoices.view"?(r(),l(I,{key:0,variant:"primary"},{default:o(()=>[s(t,{name:"DotsHorizontalIcon",class:"h-5 text-white"})]),_:1})):(r(),l(t,{key:1,name:"DotsHorizontalIcon",class:"h-5 text-gray-500"}))]),default:o(()=>[c(g).hasAbilities(c(f).EDIT_INVOICE)?(r(),l(C,{key:0,to:`/admin/invoices/${a.row.id}/edit`},{default:o(()=>[M(s(u,null,{default:o(()=>[s(t,{name:"PencilIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),d(" "+v(e.$t("general.edit")),1)]),_:1},512),[[P,a.row.allow_edit]])]),_:1},8,["to"])):m("",!0),c(y).name==="invoices.view"?(r(),l(u,{key:1,onClick:V},{default:o(()=>[s(t,{name:"LinkIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),d(" "+v(e.$t("general.copy_pdf_url")),1)]),_:1})):m("",!0),c(y).name!=="invoices.view"&&c(g).hasAbilities(c(f).VIEW_INVOICE)?(r(),l(C,{key:2,to:`invoices/${a.row.id}/view`},{default:o(()=>[s(u,null,{default:o(()=>[s(t,{name:"EyeIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),d(" "+v(e.$t("general.view")),1)]),_:1})]),_:1},8,["to"])):m("",!0),D(a.row)?(r(),l(u,{key:3,onClick:n[0]||(n[0]=k=>E(a.row))},{default:o(()=>[s(t,{name:"PaperAirplaneIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),d(" "+v(e.$t("invoices.send_invoice")),1)]),_:1})):m("",!0),_(a.row)?(r(),l(u,{key:4,onClick:n[1]||(n[1]=k=>E(a.row))},{default:o(()=>[s(t,{name:"PaperAirplaneIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),d(" "+v(e.$t("invoices.resend_invoice")),1)]),_:1})):m("",!0),s(C,{to:`/admin/payments/${a.row.id}/create`},{default:o(()=>[a.row.status=="SENT"&&c(y).name!=="invoices.view"?(r(),l(u,{key:0},{default:o(()=>[s(t,{name:"CreditCardIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),d(" "+v(e.$t("invoices.record_payment")),1)]),_:1})):m("",!0)]),_:1},8,["to"]),D(a.row)?(r(),l(u,{key:5,onClick:n[2]||(n[2]=k=>T(a.row.id))},{default:o(()=>[s(t,{name:"CheckCircleIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),d(" "+v(e.$t("invoices.mark_as_sent")),1)]),_:1})):m("",!0),c(g).hasAbilities(c(f).CREATE_INVOICE)?(r(),l(u,{key:6,onClick:n[3]||(n[3]=k=>A(a.row))},{default:o(()=>[s(t,{name:"DocumentTextIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),d(" "+v(e.$t("invoices.clone_invoice")),1)]),_:1})):m("",!0),c(g).hasAbilities(c(f).DELETE_INVOICE)?(r(),l(u,{key:7,onClick:n[4]||(n[4]=k=>B(a.row.id))},{default:o(()=>[s(t,{name:"TrashIcon",class:"w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500"}),d(" "+v(e.$t("general.delete")),1)]),_:1})):m("",!0)]),_:1})}}};export{J as _};
|