import{bI as v,bz as L,cl as P,cH as T,r as c,aC as E,aD as w,ar as C,d7 as F,j as e,D,b as I,$ as s,cC as N,bV as h,f as p,b2 as b,aN as g,b1 as V,d8 as j,cY as y,bx as _,by as k,ax as R}from"./index-ljTaFLaB.js";const $=C().shape({firstname:j.label("First name"),lastname:j.label("Last name")}),Y=({user:a})=>{const n=v(),m=L(),{isServiceUser:l}=P(),{data:d,isLoading:i}=T("saas_profile_url",{skip:!l}),[r,u]=c.useState({firstname:!1,lastname:!1}),{formState:{errors:f},register:x,handleSubmit:S}=E({defaultValues:{firstname:a.firstname,lastname:a.lastname},shouldUnregister:!1,resolver:w($),reValidateMode:"onChange",mode:"onChange"}),o=a.accountType!==F.M_ACCOUNT_TYPE,U=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(I,{width:"100%",title:"Edit profile",children:e.jsxs(s,{flexDirection:"column",children:[e.jsxs(s,{children:[e.jsx(N,{firstName:a.firstname,lastName:a.lastname}),e.jsxs(s,{mt:"3px",flexDirection:"column",ml:"20px",children:[e.jsx(h,{mb:"3px",gray:!0,children:"Username"}),e.jsx(p,{primary:!0,children:a.username})]}),e.jsxs(s,{mt:"3px",flexDirection:"column",ml:"20px",children:[e.jsx(h,{mb:"3px",gray:!0,children:"Email"}),e.jsx(p,{primary:!0,children:a.email})]})]}),e.jsxs(s,{mt:"30px",children:[e.jsx(b,{label:"First name",...x("firstname"),labelProps:{mr:"20px"},disabled:o,placeholder:"First name",onChange:t=>u({...r,firstname:a.firstname!==t.target.value}),...g("firstname",f)}),e.jsx(b,{label:"Last name",...x("lastname"),disabled:o,labelProps:{mr:"20px"},placeholder:"Last name",onChange:t=>u({...r,lastname:a.lastname!==t.target.value}),...g("lastname",f)})]}),!o&&e.jsx(V,{disabled:!r.firstname&&!r.lastname,onClick:S(U),mt:"20px",alignSelf:"flex-end",children:"Save"})]})})},G=C().shape({name:y.label("Name"),login:y.label("Description")}),M=()=>{_(k.accountSettings);const{currentData:a,isLoading:n}=R();return n?e.jsx(D,{}):e.jsx(s,{flexDirection:"column",alignItems:"center",children:e.jsx(Y,{user:a})})};export{M as default,G as schema};
