import{T as _,c as u,o as i,b as a,d as t,k as h,t as n,F as f,h as F,g as T,w as b,e as g,f as v,u as e,i as w,I as p,j as B}from"./app-fEKA3BkQ.js";import{_ as k}from"./PageHeader-DmRLoM5E.js";import{_ as j}from"./Paginate-D_g9VFI3.js";import{_ as D}from"./NoDataFound-Xi4CpDbx.js";import{_ as x}from"./SpinnerBtn-BezRkGQj.js";import{u as G,s as I}from"./assetStore-BSVLrDIW.js";import{_ as M}from"./UserLayout-D_lxcpvH.js";import{_ as O}from"./FilterDropdown-zriyDhiF.js";import"./ValidationErrors-B24rcOPH.js";const U={class:"table-responsive mt-4 w-full"},q={class:"table"},A={class:"w-[40%]"},L={class:"w-[50%] !text-right"},R={class:"w-[10%] !text-right"},z={key:0,class:"tbody"},H={class:"flex items-center gap-2"},J=["src"],K={class:"!text-right"},P={class:"flex justify-end"},Q={class:"dropdown","data-placement":"bottom-start"},W={class:"dropdown-toggle"},X={class:"dropdown-content w-56"},Y={class:"dropdown-list"},Z={class:"dropdown-list-item"},tt=["onClick"],st={class:"dropdown-list-item"},et=["onClick"],ot={class:"w-full"},nt={class:"mb-2"},at={class:"mt-2 text-end"},lt={class:"mb-2"},it={class:"mt-2 text-end"},bt=Object.assign({layout:M},{__name:"Index",props:["device","groups"],setup(d){const m=G(),{deleteRow:y}=I(),r=_({name:""}),C=()=>{r.post(route("user.whatsapp.groups.store"),{onSuccess:()=>{m.close("groupCreate"),r.reset()}})},l=_({id:null,name:""}),N=()=>{l.put(route("user.whatsapp.groups.update",{group:l.id}),{onSuccess:()=>m.close("groupEdit")})},$=s=>{l.id=s.id,l.name=s.name,m.open("groupEdit")},E=[{label:"Name",value:"name"}];return(s,c)=>(i(),u(f,null,[a(O,{options:E}),t("div",U,[t("table",q,[t("thead",null,[t("tr",null,[t("th",A,n(s.trans("Group Name")),1),t("th",L,n(s.trans("Total Customers")),1),t("th",R,n(s.trans("Action")),1)])]),d.groups.data.length?(i(),u("tbody",z,[(i(!0),u(f,null,F(d.groups.data,(o,S)=>(i(),u("tr",{key:S},[t("td",null,[t("div",H,[t("img",{src:"https://ui-avatars.com/api/?name="+o.name,class:"h-8 w-8"},null,8,J),t("span",null,n(o.name),1)])]),t("td",K,n(o.customers_count),1),t("td",null,[t("div",P,[t("div",Q,[t("div",W,[a(e(p),{class:"h-5 text-3xl text-slate-400",icon:"bx:dots-vertical-rounded"})]),t("div",X,[t("ul",Y,[t("li",Z,[t("a",{class:"dropdown-link",href:"#",onClick:V=>$(o)},[a(e(p),{icon:"bx:bxs-edit-alt"}),t("span",null,n(s.trans("Edit")),1)],8,tt)]),t("li",st,[t("button",{class:"dropdown-link delete-confirm",href:"#",onClick:V=>e(y)(s.route("user.whatsapp.groups.destroy",o.id))},[a(e(p),{icon:"bx:trash"}),B(" "+n(s.trans("Delete")),1)],8,et)])])])])])])]))),128))])):(i(),h(D,{key:1,forTable:!0}))]),t("div",ot,[d.groups.data.length?(i(),h(j,{key:0,links:d.groups.links},null,8,["links"])):T("",!0)])]),a(k,{state:"groupCreate"},{default:b(()=>[t("form",{onSubmit:g(C,["prevent"])},[t("div",nt,[t("label",null,n(s.trans("Name")),1),v(t("input",{type:"text","onUpdate:modelValue":c[0]||(c[0]=o=>e(r).name=o),class:"input",placeholder:"Group Name",required:""},null,512),[[w,e(r).name]])]),t("div",at,[a(x,{classes:"btn btn-primary",processing:e(r).processing,"btn-text":s.trans("Create")},null,8,["processing","btn-text"])])],32)]),_:1}),a(k,{state:"groupEdit"},{default:b(()=>[t("form",{onSubmit:g(N,["prevent"])},[t("div",lt,[t("label",null,n(s.trans("Name")),1),v(t("input",{type:"text","onUpdate:modelValue":c[1]||(c[1]=o=>e(l).name=o),class:"input"},null,512),[[w,e(l).name]])]),t("div",it,[a(x,{classes:"btn btn-primary",processing:e(l).processing,"btn-text":s.trans("Save Changes")},null,8,["processing","btn-text"])])],32)]),_:1})],64))}});export{bt as default};
