import{T as $,a as M,c as r,o as n,b as i,d as s,k as b,t,F as m,h as _,g as p,w,e as j,j as h,u as o,f as g,v as k,I as f}from"./app-fEKA3BkQ.js";import{_ as B}from"./PageHeader-DmRLoM5E.js";import{_ as D}from"./Paginate-D_g9VFI3.js";import{_ as I}from"./NoDataFound-Xi4CpDbx.js";import{_ as P}from"./SpinnerBtn-BezRkGQj.js";import{u as x,s as F}from"./assetStore-BSVLrDIW.js";import{_ as G}from"./UserLayout-D_lxcpvH.js";import{_ as L}from"./FilterDropdown-zriyDhiF.js";import"./ValidationErrors-B24rcOPH.js";const T={class:"table-responsive mt-4 w-full"},A={class:"table"},E={class:"!text-right"},O={key:0,class:"tbody"},U={class:"flex items-center gap-2"},R=["src"],q={class:"flex justify-end"},z={class:"dropdown","data-placement":"bottom-start"},H={class:"dropdown-toggle"},J={class:"dropdown-content w-56"},K={class:"dropdown-list"},Q={class:"dropdown-list-item"},W={class:"dropdown-list-item"},X=["onClick"],Y={class:"w-full"},Z={class:"w-full"},ss={class:"label mb-1"},ts={href:"/assets/whatsapp-customers-sample.csv",download:""},es={key:0,class:"text-red-600"},os={class:"w-full"},ls={class:"label mb-1"},as={value:""},ns=["value"],rs={key:0,class:"text-red-600"},is={class:"w-full"},ds={class:"label mb-1"},cs={value:""},us=["value"],ms={key:0,class:"text-red-600"},ps={class:"mt-2"},Cs=Object.assign({layout:G},{__name:"Index",props:["groups","dialCodes","customers","platforms"],setup(d){const y=x(),{deleteRow:C}=F(),l=$({csv_file:null,group_id:"",platform_id:""}),S=()=>{l.post(route("user.whatsapp.customers.bulk-import"),{onSuccess:()=>{y.close("importModal"),l.reset()}})},N=[{label:"Name",value:"name"},{label:"Phone",value:"uuid"}];return(a,c)=>{const V=M("Link");return n(),r(m,null,[i(L,{options:N}),s("div",T,[s("table",A,[s("thead",null,[s("tr",null,[s("th",null,t(a.trans("Name")),1),s("th",null,t(a.trans("Phone")),1),s("th",null,t(a.trans("Groups")),1),s("th",E,t(a.trans("Action")),1)])]),d.customers.data.length?(n(),r("tbody",O,[(n(!0),r(m,null,_(d.customers.data,(e,u)=>(n(),r("tr",{key:u},[s("td",null,[s("div",U,[s("img",{src:e.picture??"https://ui-avatars.com/api/?name="+e.name,class:"h-8 w-8 rounded-full"},null,8,R),s("span",null,t(e.name),1)])]),s("td",null,t(e.uuid),1),s("td",null,t(e.groups.map(v=>v.name).join(", ")||"N/A"),1),s("td",null,[s("div",q,[s("div",z,[s("div",H,[i(o(f),{class:"h-5 text-3xl text-slate-400",icon:"bx:dots-vertical-rounded"})]),s("div",J,[s("ul",K,[s("li",Q,[i(V,{href:a.route("user.whatsapp.customers.edit",e),class:"dropdown-link"},{default:w(()=>[i(o(f),{icon:"bx:edit"}),h(" "+t(a.trans("Edit")),1)]),_:2},1032,["href"])]),s("li",W,[s("button",{class:"dropdown-link delete-confirm",onClick:v=>o(C)(a.route("user.whatsapp.customers.destroy",e.id))},[i(o(f),{icon:"bx:trash"}),h(" "+t(a.trans("Delete")),1)],8,X)])])])])])])]))),128))])):(n(),b(I,{key:1,forTable:!0}))]),s("div",Y,[d.customers.data.length?(n(),b(D,{key:0,links:d.customers.links},null,8,["links"])):p("",!0)])]),i(B,{state:"importModal","header-state":!0,"header-title":"Import customers"},{default:w(()=>[s("form",{onSubmit:j(S,["prevent"])},[s("div",Z,[s("label",ss,[h(t(a.trans("Select CSV"))+" ",1),s("a",ts,t(a.trans("(Download Sample)")),1)]),s("input",{type:"file",accept:".csv",onChange:c[0]||(c[0]=e=>o(l).csv_file=e.target.files[0]),class:"input"},null,32),o(l).errors.csv_file?(n(),r("small",es,t(o(l).errors.csv_file),1)):p("",!0)]),s("div",os,[s("label",ls,t(a.trans("Platforms")),1),g(s("select",{"onUpdate:modelValue":c[1]||(c[1]=e=>o(l).platform_id=e),class:"select"},[s("option",as,t(a.trans("Select Platform")),1),(n(!0),r(m,null,_(d.platforms,(e,u)=>(n(),r("option",{key:u,value:e.id},t(e.name),9,ns))),128))],512),[[k,o(l).platform_id]]),o(l).errors.group_id?(n(),r("small",rs,t(o(l).errors.group_id),1)):p("",!0)]),s("div",is,[s("label",ds,t(a.trans("Group")),1),g(s("select",{"onUpdate:modelValue":c[2]||(c[2]=e=>o(l).group_id=e),class:"select"},[s("option",cs,t(a.trans("Select Group")),1),(n(!0),r(m,null,_(d.groups,(e,u)=>(n(),r("option",{key:u,value:e.id},t(e.name),9,us))),128))],512),[[k,o(l).group_id]]),o(l).errors.group_id?(n(),r("small",ms,t(o(l).errors.group_id),1)):p("",!0)]),s("div",ps,[i(P,{classes:"btn btn-primary w-full",processing:o(l).processing},null,8,["processing"])])],32)]),_:1})],64)}}});export{Cs as default};
