import{i as g,Z as _,r as i,c as m,o as a,a as t,b as n,d as v,w as b,F as U,j as k,t as f,f as w,e as L}from"./app-BLo7SiiE.js";import{L as x}from"./Layout-BEAmuehS.js";import{T as C}from"./TextInput-D6G3wYlu.js";import{F as S}from"./FileInput-BvFDCdhW.js";import{S as A}from"./SelectInput-Bl1ROfev.js";import{L as F}from"./LoadingButton-fIGCYE5-.js";import{_ as j}from"./FlashMessages-DImpr6PL.js";import"./moment-C7JtfGJw.js";import"./v4-SoommWqA.js";const B={components:{FileInput:S,Head:_,Link:g,LoadingButton:F,SelectInput:A,TextInput:C},layout:x,props:{user:Object,auth:Object,countries:Array,cities:Array,title:String},remember:"form",data(){return{user_access:this.$page.props.auth.user.access,form:this.$inertia.form({_method:"put",first_name:this.user.first_name,last_name:this.user.last_name,email:this.user.email,phone:this.user.phone,city:this.user.city,address:this.user.address,country_id:this.user.country_id,password:"",photo_path:null})}},created(){},methods:{setDefaultValue(l,r,s){const p=l.find(e=>e.name.match(new RegExp(s+".*")));p&&(this.form[r]=p.id)},update(){this.form.post(this.route("customers.update",this.user.id),{onSuccess:()=>this.form.reset("password","photo")})},destroy(){confirm("Are you sure you want to delete this user?")&&this.$inertia.delete(this.route("customers.destroy",this.user.id))},restore(){confirm("Are you sure you want to restore this user?")&&this.$inertia.put(this.route("customers.restore",this.user.id))}}},E={class:"max-w-full bg-white rounded-md shadow overflow-hidden"},N={class:"flex flex-wrap -mb-8 -mr-6 p-8"},D=["value"],H={class:"w-full lg:w-1/3 flex items-center justify-start"},I=["src"],P={class:"flex items-center px-8 py-4 bg-gray-50 border-t border-gray-100"};function T(l,r,s,p,e,d){const h=i("Head"),u=i("text-input"),y=i("select-input"),c=i("file-input"),V=i("loading-button");return a(),m("div",null,[t(h,{title:s.title},null,8,["title"]),n("div",E,[n("form",{onSubmit:r[10]||(r[10]=v((...o)=>d.update&&d.update(...o),["prevent"]))},[n("div",N,[t(u,{modelValue:e.form.first_name,"onUpdate:modelValue":r[0]||(r[0]=o=>e.form.first_name=o),error:e.form.errors.first_name,class:"pb-8 pr-6 w-full lg:w-1/3",label:l.$t("First name")},null,8,["modelValue","error","label"]),t(u,{modelValue:e.form.last_name,"onUpdate:modelValue":r[1]||(r[1]=o=>e.form.last_name=o),error:e.form.errors.last_name,class:"pb-8 pr-6 w-full lg:w-1/3",label:l.$t("Last name")},null,8,["modelValue","error","label"]),t(u,{modelValue:e.form.email,"onUpdate:modelValue":r[2]||(r[2]=o=>e.form.email=o),error:e.form.errors.email,class:"pb-8 pr-6 w-full lg:w-1/3",label:l.$t("Email")},null,8,["modelValue","error","label"]),t(u,{modelValue:e.form.phone,"onUpdate:modelValue":r[3]||(r[3]=o=>e.form.phone=o),error:e.form.errors.phone,class:"pb-8 pr-6 w-full lg:w-1/3",label:l.$t("Phone")},null,8,["modelValue","error","label"]),t(u,{modelValue:e.form.city,"onUpdate:modelValue":r[4]||(r[4]=o=>e.form.city=o),error:e.form.errors.city,class:"pb-8 pr-6 w-full lg:w-1/3",label:l.$t("City")},null,8,["modelValue","error","label"]),t(u,{modelValue:e.form.address,"onUpdate:modelValue":r[5]||(r[5]=o=>e.form.address=o),error:e.form.errors.address,class:"pb-8 pr-6 w-full lg:w-1/3",label:l.$t("Address")},null,8,["modelValue","error","label"]),t(y,{modelValue:e.form.country_id,"onUpdate:modelValue":r[6]||(r[6]=o=>e.form.country_id=o),error:e.form.errors.country_id,class:"pr-6 pb-8 w-full lg:w-1/3",label:l.$t("Country")},{default:b(()=>[r[11]||(r[11]=n("option",{value:null},null,-1)),(a(!0),m(U,null,k(s.countries,o=>(a(),m("option",{key:o.id,value:o.id},f(l.$t(o.name)),9,D))),128))]),_:1,__:[11]},8,["modelValue","error","label"]),t(u,{modelValue:e.form.password,"onUpdate:modelValue":r[7]||(r[7]=o=>e.form.password=o),error:e.form.errors.password,class:"pb-8 pr-6 w-full lg:w-1/3",type:"password",autocomplete:"new-password",label:l.$t("Password")},null,8,["modelValue","error","label"]),t(c,{modelValue:e.form.photo_path,"onUpdate:modelValue":r[8]||(r[8]=o=>e.form.photo_path=o),error:e.form.errors.photo_path,class:"pb-8 pr-6 w-full lg:w-1/3",type:"file",accept:"image/*",label:"Photo"},null,8,["modelValue","error"]),n("div",H,[s.user.photo_path?(a(),m("img",{key:0,class:"block mb-2 w-8 h-8 rounded-full",src:s.user.photo_path},null,8,I)):w("",!0)])]),n("div",P,[s.user.id!==s.auth.user.id&&e.user_access.customer.delete?(a(),m("button",{key:0,class:"text-red-600 hover:underline",tabindex:"-1",type:"button",onClick:r[9]||(r[9]=(...o)=>d.destroy&&d.destroy(...o))},f(l.$t("Delete")),1)):w("",!0),t(V,{loading:e.form.processing,class:"btn-indigo ml-auto",type:"submit"},{default:b(()=>[L(f(l.$t("Update")),1)]),_:1},8,["loading"])])],32)])])}const Q=j(B,[["render",T]]);export{Q as default};
