import{a7 as C,cF as h,b0 as T,aZ as U,c8 as P,aK as v,r as c,am as E,an as F,cG as w,j as e,a_ as D,K as _,a as s,cr as k,be as p,f as g,aG as j,ax as b,aT as G,cx as y,aX as N,cH as R,aY as V}from"./index-d6499a22.js";const Y=C().shape({firstname:h.label("First name"),lastname:h.label("Last name")}),I=({user:a})=>{const n=T(),m=U(),{isServiceUser:l}=P(),{data:d,isLoading:i}=v("saas_profile_url",{skip:!l}),[r,u]=c.useState({firstname:!1,lastname:!1}),{formState:{errors:f},register:x,handleSubmit:L}=E({defaultValues:{firstname:a.firstname,lastname:a.lastname},shouldUnregister:!1,resolver:F(Y),reValidateMode:"onChange",mode:"onChange"}),o=a.accountType!==w.M_ACCOUNT_TYPE,S=c.useCallback(async t=>{await n.auth.updateData({data:t}),m.success({title:"Info updated",content:"Your information has been successfully updated."})},[n.auth,m]);return c.useEffect(()=>{l&&!i&&(window.location.href=d||"https://managed.hopsworks.ai/settings")},[d,i,l]),!a.email||i?e.jsx(D,{}):l?null:e.jsx(_,{width:"100%",title:"Edit profile",children:e.jsxs(s,{flexDirection:"column",children:[e.jsxs(s,{children:[e.jsx(k,{firstName:a.firstname,lastName:a.lastname}),e.jsxs(s,{mt:"3px",flexDirection:"column",ml:"20px",children:[e.jsx(p,{mb:"3px",gray:!0,children:"Username"}),e.jsx(g,{primary:!0,children:a.username})]}),e.jsxs(s,{mt:"3px",flexDirection:"column",ml:"20px",children:[e.jsx(p,{mb:"3px",gray:!0,children:"Email"}),e.jsx(g,{primary:!0,children:a.email})]})]}),e.jsxs(s,{mt:"30px",children:[e.jsx(j,{label:"First name",...x("firstname"),labelProps:{mr:"20px"},disabled:o,placeholder:"First name",onChange:t=>u({...r,firstname:a.firstname!==t.target.value}),...b("firstname",f)}),e.jsx(j,{label:"Last name",...x("lastname"),disabled:o,labelProps:{mr:"20px"},placeholder:"Last name",onChange:t=>u({...r,lastname:a.lastname!==t.target.value}),...b("lastname",f)})]}),!o&&e.jsx(G,{disabled:!r.firstname&&!r.lastname,onClick:L(S),mt:"20px",alignSelf:"flex-end",children:"Save"})]})})},A=C().shape({name:y.label("Name"),login:y.label("Description")}),M=()=>{N(V.accountSettings);const{currentData:a,isLoading:n}=R();return n?e.jsx(D,{}):e.jsx(s,{flexDirection:"column",alignItems:"center",children:e.jsx(I,{user:a})})};export{M as default,A as schema};
