import{ae as C,cn as h,bf as D,bd as P,bR as v,aU as E,r as c,au as T,av as R,co as w,j as e,L,Q as F,d as s,c8 as V,br as x,p as b,aR as g,aE as j,b6 as k,ce as y,bb as N,aq as Q,bc as _}from"./index-CK33qGU_.js";const q=C().shape({firstname:h.label("First name"),lastname:h.label("Last name")}),I=({user:a})=>{const n=D(),m=P(),{isServiceUser:l}=v(),{data:d,isLoading:i}=E("saas_profile_url",{skip:!l}),[r,u]=c.useState({firstname:!1,lastname:!1}),{formState:{errors:f},register:p,handleSubmit:S}=T({defaultValues:{firstname:a.firstname,lastname:a.lastname},shouldUnregister:!1,resolver:R(q),reValidateMode:"onChange",mode:"onChange"}),o=a.accountType!==w.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(L,{}):l?null:e.jsx(F,{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(x,{mb:"3px",gray:!0,children:"Username"}),e.jsx(b,{primary:!0,children:a.username})]}),e.jsxs(s,{mt:"3px",flexDirection:"column",ml:"20px",children:[e.jsx(x,{mb:"3px",gray:!0,children:"Email"}),e.jsx(b,{primary:!0,children:a.email})]})]}),e.jsxs(s,{mt:"30px",children:[e.jsx(g,{label:"First name",...p("firstname"),labelProps:{mr:"20px"},disabled:o,placeholder:"First name",onChange:t=>u({...r,firstname:a.firstname!==t.target.value}),...j("firstname",f)}),e.jsx(g,{label:"Last name",...p("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(k,{disabled:!r.firstname&&!r.lastname,onClick:S(U),mt:"20px",alignSelf:"flex-end",children:"Save"})]})})},A=C().shape({name:y.label("Name"),login:y.label("Description")}),G=()=>{N(_.accountSettings);const{currentData:a,isLoading:n}=Q();return n?e.jsx(L,{}):e.jsx(s,{flexDirection:"column",alignItems:"center",children:e.jsx(I,{user:a})})};export{G as default,A as schema};
