import{q as S,r as v,S as P,j as e}from"./app-Bup04Qnx.js";import{I as r}from"./Input-Bs1ncZB7.js";import"./format-CisCU4Rs.js";import"./BaseForm-wkPKZ5Eg.js";function L({className:p=""}){const{auth:U,flash:s,user:a}=S().props,[i,d]=v.useState((a==null?void 0:a.picture)??null),{data:u,setData:x,post:h,errors:j,processing:o,recentlySuccessful:w}=P({name:a.name,username:a.username,email:a.email,phone:a.phone,picture:a.picture});function f(l){const{name:n,value:b,files:c}=l.target,N=["picture"];let m=b;N.includes(n)&&(m=c[0],d(URL.createObjectURL(c[0]))),x(y=>({...y,[n]:m}))}const g=l=>{l.preventDefault();const n=new URLSearchParams(window.location.search);h(`/app/profile?${n.toString()}`,{preserveScroll:!0})},t={handleChange:f,data:u,errors:j};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"}),s!=null&&s.error?e.jsx("p",{className:"mt-1 text-sm text-red-600",children:s==null?void 0:s.error}):null]}),e.jsxs("form",{onSubmit:g,className:"space-y-8 mt-6",children:[e.jsxs("div",{className:"grid gap-4 p-4 bg-gray-50 rounded-lg",children:[e.jsx("h3",{className:"font-semibold text-gray-700",children:"Informasi Dasar"}),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:"email",name:"email",label:"Email",...t}),e.jsx(r,{type:"tel",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.jsx("div",{className:"flex items-center gap-4 pt-4 border-t border-gray-200",children:e.jsxs("button",{disabled:o,className:"btn btn-primary",children:[o&&e.jsx("span",{className:"loading"}),e.jsx("span",{children:"Simpan Perubahan"})]})})]})]})}export{L as default};
