import{r as g,d as x,o as a,f as y,J as A,z as t,c as m,a as e,l as b,v as U,t as _,e as f,g as B}from"./app-91dba96b.js";import{u as E}from"./useSubmitForm-bd99a12d.js";import{f as F}from"./helper-7c41612f.js";import{i as T}from"./index-0653e21c.js";import{u as L}from"./urlGenerator-87d92adb.js";import"./useEmitter-cde057d4.js";import"./appFunction-1b5b1f43.js";const M={key:1},z={class:"mb-3"},I=e("label",{class:"name"},[B("Name "),e("span",{class:"text-danger"},"*")],-1),j={key:0,class:"text-danger"},G={class:"mb-3"},H=e("label",{class:"position"},"Position",-1),J={key:0,class:"text-danger"},O={class:"form-group row mb-3 mt-3"},q=e("label",{for:"image",class:"col-sm-2 col-form-label"},"Profile Picture",-1),K=e("p",null,null,-1),Q={class:"col-sm-10"},W={class:"custom-image-upload-wrapper",style:{width:"150px",height:"100px"}},X={class:"image-area d-flex",style:{width:"150px",height:"100px"}},Y=["src"],Z={class:"input-area",style:{width:"150px"}},$=e("label",{id:"upload-label",for:"profile_picture"}," Upload Picture ",-1),ee={key:0,class:"text-danger"},ne={__name:"reciterModal",props:{modalId:String,selectedUrl:String},emits:["close"],setup(u,{emit:w}){const n=u,C=w,{preloader:h,pageLoader:k,errors:s,afterSuccess:S,afterError:D,afterFinalResponse:N,formData:o,closeModal:P}=E(n,C),d=g(null),R=c=>{d.value=c.target.files[0],v.value=URL.createObjectURL(d.value)},V=()=>{var l,p;h.value=!0,s.value={},(l=o.value)==null||delete l.profile,d.value?o.value.profile_picture=d.value:(p=o.value)==null||delete p.profile_picture,n.selectedUrl&&(o.value._method="PATCH");let c=F(new FormData,o.value);T.post(n.selectedUrl?n.selectedUrl:"reciter",c,{headers:{"Content-Type":"multipart/form-data"}}).then(r=>{S(r)}).catch(({response:r})=>{D(r)}).finally(()=>N())},v=g(L("assets/img/avatar.png"));return(c,l)=>{const p=x("app-loader"),r=x("app-modal");return a(),y(r,{"modal-id":u.modalId,"modal-size":"large",title:u.selectedUrl?"Update Reciter":"Add Reciter",preloader:t(h),onSubmit:V,onClose:t(P)},{body:A(()=>[t(k)?(a(),y(p,{key:0})):(a(),m("form",M,[e("div",z,[I,b(e("input",{type:"text",id:"name","onUpdate:modelValue":l[0]||(l[0]=i=>t(o).name=i),class:"form-control",placeholder:"Enter Name"},null,512),[[U,t(o).name]]),t(s).name?(a(),m("small",j,_(t(s).name[0]),1)):f("",!0)]),e("div",G,[H,b(e("input",{type:"number",id:"position","onUpdate:modelValue":l[1]||(l[1]=i=>t(o).position=i),class:"form-control",placeholder:"Enter position"},null,512),[[U,t(o).position]]),t(s).position?(a(),m("small",J,_(t(s).position[0]),1)):f("",!0)]),e("div",O,[q,K,e("div",Q,[e("div",null,[e("div",W,[e("div",X,[e("img",{id:"bruh",style:{width:"150px"},src:v.value,alt:"profile picture",class:"img-fluid mx-auto my-auto"},null,8,Y)]),e("div",Z,[$,e("input",{id:"profile_picture",name:"profile_picture",type:"file",class:"form-control d-none",onChange:l[2]||(l[2]=i=>R(i))},null,32)])])]),t(s).profile_picture?(a(),m("small",ee,_(t(s).profile_picture[0]),1)):f("",!0)])])]))]),_:1},8,["modal-id","title","preloader","onClose"])}}};export{ne as default};
