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{J as O,G as j,aN as z,ah as R,r as I,o as r,l,w as o,u as c,f as s,q as M,ag as P,i as d,t as m,j as v}from"./vendor.d12b5734.js";import{i as F,c as U,u as q,j as H,e as W,g as y}from"./main.a7fcb8c6.js";const K={props:{row:{type:Object,default:null},table:{type:Object,default:null},loadData:{type:Function,default:()=>{}}},setup(a){const f=a,p=F(),N=U(),$=q(),b=H(),g=W(),{t:i}=O(),w=j(),C=z(),x=R("utils");function _(e){return(e.status=="SENT"||e.status=="VIEWED")&&g.hasAbilities(y.SEND_INVOICE)}function D(e){return e.status=="DRAFT"&&w.name!=="invoices.view"&&g.hasAbilities(y.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&&(C.push("/admin/invoices"),f.table&&f.table.refresh(),p.$patch(h=>{h.selectedInvoices=[],h.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=>{C.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(h=>{f.table&&f.table.refresh()})})}async function E(e){N.openModal({title:i("invoices.send_invoice"),componentName:"SendInvoiceModal",id:e.id,data:e,variant:"sm"})}function V(){let e=`${window.location.origin}/invoices/pdf/${f.row.unique_hash}`;x.copyTextToClipboard(e),$.showNotification({type:"success",message:i("general.copied_pdf_url_clipboard")})}return(e,n)=>{const t=I("BaseIcon"),h=I("BaseButton"),u=I("BaseDropdownItem"),S=I("router-link"),L=I("BaseDropdown");return r(),l(L,null,{activator:o(()=>[c(w).name==="invoices.view"?(r(),l(h,{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(y).EDIT_INVOICE)?(r(),l(S,{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(" "+m(e.$t("general.edit")),1)]),_:1},512),[[P,a.row.allow_edit]])]),_:1},8,["to"])):v("",!0),c(w).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(" "+m(e.$t("general.copy_pdf_url")),1)]),_:1})):v("",!0),c(w).name!=="invoices.view"&&c(g).hasAbilities(c(y).VIEW_INVOICE)?(r(),l(S,{key:2,to:`/admin/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(" "+m(e.$t("general.view")),1)]),_:1})]),_:1},8,["to"])):v("",!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(" "+m(e.$t("invoices.send_invoice")),1)]),_:1})):v("",!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(" "+m(e.$t("invoices.resend_invoice")),1)]),_:1})):v("",!0),s(S,{to:`/admin/payments/${a.row.id}/create`},{default:o(()=>[a.row.status=="SENT"&&c(w).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(" "+m(e.$t("invoices.record_payment")),1)]),_:1})):v("",!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(" "+m(e.$t("invoices.mark_as_sent")),1)]),_:1})):v("",!0),c(g).hasAbilities(c(y).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(" "+m(e.$t("invoices.clone_invoice")),1)]),_:1})):v("",!0),c(g).hasAbilities(c(y).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(" "+m(e.$t("general.delete")),1)]),_:1})):v("",!0)]),_:1})}}};export{K as _};
|