/* empty css                         */import{d as _,s as r,u as C,g as b,G as x,a as d,h as e,i as y,w as L,e as u,B as h,o as w,t as S,k as B}from"./main-FivMmpKK.js";import{S as p}from"./sweetalert2.all-Ck0oYstg.js";import{g as M}from"./vue3-datatable-DG2iuGyG.js";const j=e("ul",{class:"flex space-x-2 rtl:space-x-reverse"},[e("li",null,[e("a",{href:"javascript:;",class:"text-primary hover:underline"},"Contracts")]),e("li",{class:"before:content-['/'] ltr:before:mr-2 rtl:before:ml-2"},[e("span",null,"Credit Card Contracts")])],-1),A={class:"pt-5"},D={class:"panel pb-0 mt-6"},$=e("h5",{class:"font-semibold text-lg dark:text-white-light mb-5"},"Contract List",-1),N={class:"datatable"},R={class:"flex gap-4"},E=["disabled","onClick"],T=_({__name:"contracts",props:{contracts:Object},setup(f){const{contracts:g}=f,a=r(g);C();const l=r(null),c=r({current_page:1,pagesize:10,sort_column:"id",sort_direction:"desc"}),v=async()=>{try{const t=await h.get("/ccaf/contracts");a.value=t.data.contracts}catch(t){console.error("Error refreshing contracts:",t)}};b(()=>{l.value=setInterval(v,3e4)}),x(()=>{l.value&&clearInterval(l.value)});const m=r([{field:"order_id",title:"Order",filter:!0},{field:"name",title:"Customer",filter:!0},{field:"status",filter:!0,title:"Status",cellRenderer:t=>{if(t.status==="Signed"){if(t.signed_at)try{const i=new Date(t.signed_at);if(!isNaN(i.getTime())){const n={month:"short",day:"numeric",year:"numeric"},s=new Intl.DateTimeFormat("en-US",n).format(i);return`<span style="color: green; font-weight: bold;">${t.status}</span><br>On ${s}`}}catch{return`<span style="color: green; font-weight: bold;">${t.status}</span><br>On ${t.signed_at}`}return`<span style="color: green; font-weight: bold;">${t.status}</span>`}return t.status=="Sms"||t.status=="Emailed"?"Sent":t.status}},{field:"is_ready",filter:!1,title:"Ready",cellRenderer:t=>t.is_ready==1?`
          <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="green">
            <path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"/>
          </svg>
        `:""},{field:"actions",title:"Actions",filter:!1}])||[],o=r(!1);function k(t){o.value=!0,h.post("/ccaf/sendContract/"+t.id).then(()=>{p.fire("Success","Contract sent successfully!","success")}).catch(()=>{p.fire("Error","Failed to send contract.","error")}).finally(()=>{o.value=!1})}return(t,i)=>{var n;return w(),d("div",null,[j,e("div",A,[e("div",D,[$,e("div",N,[y(u(M),{rows:a.value,columns:u(m),totalRows:(n=a.value)==null?void 0:n.length,isServerMode:!1,skin:"whitespace-nowrap bh-table-hover",columnFilter:!0,sortDirection:c.value.sort_direction,sortColumn:c.value.sort_column,sorteable:!0,firstArrow:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="w-4.5 h-4.5 rtl:rotate-180"> <path d="M13 19L7 12L13 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> <path opacity="0.5" d="M16.9998 19L10.9998 12L16.9998 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> </svg>',lastArrow:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="w-4.5 h-4.5 rtl:rotate-180"> <path d="M11 19L17 12L11 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> <path opacity="0.5" d="M6.99976 19L12.9998 12L6.99976 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> </svg> ',previousArrow:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="w-4.5 h-4.5 rtl:rotate-180"> <path d="M15 5L9 12L15 19" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> </svg>',nextArrow:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="w-4.5 h-4.5 rtl:rotate-180"> <path d="M9 5L15 12L9 19" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> </svg>'},{actions:L(s=>[e("div",R,[s.value.status!="Cancelled"&&s.value.status!="Signed"&&s.value.status!="Viewed"?(w(),d("button",{key:0,type:"button",class:"btn btn-success !py-1",disabled:o.value,onClick:I=>k(s.value)},S(o.value?"Sending...":"Send Contract"),9,E)):B("",!0)])]),_:1},8,["rows","columns","totalRows","sortDirection","sortColumn"])])])])])}}});export{T as default};
