import{q as v,r as P,S as U,j as e}from"./app-DB4YCWeF.js";import{I as r}from"./Input-BfNm_9oA.js";import"./BaseForm-CkSb_d40.js";function I({className:p=""}){const{auth:w,flash:a,user:s}=v().props,[i,d]=P.useState((s==null?void 0:s.picture)??null),{data:u,setData:x,post:j,errors:h,processing:c,recentlySuccessful:f}=U({name:s.name,username:s.username,email:s.email,phone:s.phone,picture:s.picture});function b(l){const{name:n,value:N,files:o}=l.target,y=["picture"];let m=N;y.includes(n)&&(m=o[0],d(URL.createObjectURL(o[0]))),x(S=>({...S,[n]:m}))}const g=l=>{l.preventDefault();const n=new URLSearchParams(window.location.search);j(`/profile?${n.toString()}`,{preserveScroll:!0})},t={handleChange:b,data:u,errors:h};return e.jsxs("section",{className:p,children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-lg font-medium text-gray-900 ",children:"Profil Saya"}),a!=null&&a.error?e.jsx("p",{className:"mt-1 text-sm text-red-600",children:a==null?void 0:a.error}):null]}),e.jsxs("form",{onSubmit:g,className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(r,{type:"text",name:"name",label:"Nama",...t}),e.jsx(r,{type:"text",name:"username",label:"Username",...t}),e.jsx(r,{type:"text",name:"email",label:"Email",...t}),e.jsx(r,{type:"text",name:"phone",label:"Nomor Whatsapp",...t}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsx(r,{type:"file",name:"picture",label:"Upload Foto",alt:"Opsional",...t}),i?e.jsx("img",{src:i,alt:"Foto Profil",className:"w-16 h-16 object-cover rounded-full"}):null]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("button",{disabled:c,className:"btn btn-primary btn-sm",children:[c&&e.jsx("span",{className:"loading"}),e.jsx("span",{children:"Simpan"})]}),f?e.jsxs("div",{className:"badge badge-success gap-2 badge-lg",children:[e.jsx("i",{className:"fas fa-check"}),e.jsx("span",{children:"Berhasil Disimpan"})]}):null]})]})]})}export{I as default};
