import{aj as y,cN as h,aD as U,aE as v,cf as E,bp as P,r as m,az as T,aA as F,cO as w,j as e,L as D,m as N,B as s,aU as V,bS as x,Q as b,aM as j,b8 as g,aG as k,cE as C,bC as Q,av as R,bD as _}from"./index-dP1W1_bd.js";const A=y().shape({firstname:h.label("First name"),lastname:h.label("Last name")}),G=({user:a})=>{const n=U(),c=v(),{isServiceUser:l}=E(),{data:d,isLoading:i}=P("saas_profile_url",{skip:!l}),[r,u]=m.useState({firstname:!1,lastname:!1}),{formState:{errors:f},register:p,handleSubmit:L}=T({defaultValues:{firstname:a.firstname,lastname:a.lastname},shouldUnregister:!1,resolver:F(A),reValidateMode:"onChange",mode:"onChange"}),o=a.accountType!==w.M_ACCOUNT_TYPE,S=m.useCallback(async t=>{await n.auth.updateData({data:t}),c.success({title:"Info updated",content:"Your information has been successfully updated."})},[n.auth,c]);return m.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(N,{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(j,{label:"First name",...p("firstname"),labelProps:{mr:"20px"},disabled:o,placeholder:"First name",onChange:t=>u({...r,firstname:a.firstname!==t.target.value}),...g("firstname",f)}),e.jsx(j,{label:"Last name",...p("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(k,{disabled:!r.firstname&&!r.lastname,onClick:L(S),mt:"20px",alignSelf:"flex-end",children:"Save"})]})})},M=y().shape({name:C.label("Name"),login:C.label("Description")}),q=()=>{Q(_.accountSettings);const{currentData:a,isLoading:n}=R();return n?e.jsx(D,{}):e.jsx(s,{flexDirection:"column",alignItems:"center",children:e.jsx(G,{user:a})})};export{q as default,M as schema};
