import{bH as v,by as L,ck as P,cG as T,r as c,aC as w,aD as E,ar as C,d6 as k,j as e,D,b as F,$ as s,cB as N,bU as h,f as p,b2 as b,aN as g,b1 as _,d7 as j,cX as y,bw as I,bx as R,ax as V}from"./index-46ma1THH.js";const $=C().shape({firstname:j.label("First name"),lastname:j.label("Last name")}),G=({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}=w({defaultValues:{firstname:a.firstname,lastname:a.lastname},shouldUnregister:!1,resolver:E($),reValidateMode:"onChange",mode:"onChange"}),o=a.accountType!==k.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(F,{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(_,{disabled:!r.firstname&&!r.lastname,onClick:S(U),mt:"20px",alignSelf:"flex-end",children:"Save"})]})})},M=C().shape({name:y.label("Name"),login:y.label("Description")}),Q=()=>{I(R.accountSettings);const{currentData:a,isLoading:n}=V();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};
