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,W as I,a as s,cC as V,bV as h,f as p,aH as b,aY as j,aJ as Y,d8 as g,cY as y,bx as k,by as N,ax as R}from"./index-_eM6l4Nf.js";const _=C().shape({firstname:g.label("First name"),lastname:g.label("Last name")}),A=({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(V,{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}),...j("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}),...j("lastname",f)})]}),!o&&e.jsx(Y,{disabled:!r.firstname&&!r.lastname,onClick:S(U),mt:"20px",alignSelf:"flex-end",children:"Save"})]})})},H=C().shape({name:y.label("Name"),login:y.label("Description")}),J=()=>{k(N.accountSettings);const{currentData:a,isLoading:n}=R();return n?e.jsx(D,{}):e.jsx(s,{flexDirection:"column",alignItems:"center",children:e.jsx(A,{user:a})})};export{J as default,H as schema};
