import{j as r,a as C,c as T,bG as R,bo as h,bz as A,b as v,cr as y,r as i,s as P,t as u,bx as I,by as N,cs as O,ct as E}from"./index-_eM6l4Nf.js";import{P as w}from"./ProjectForm-P40vIxQJ.js";const F=({children:s})=>r.jsxs(C,{width:"100%",flexDirection:"column",alignItems:"center",children:[r.jsx(T,{bold:!0,color:"gray",fontSize:"18px",mb:"8px",children:"Building new project"}),r.jsx(R,{mb:"20px",children:"Project creation"}),s]}),G=()=>{const s=h(),l=A(),{currentData:c,isLoading:S}=v(),[j]=y(),[f,n]=i.useState({isProgressing:!1,isSuccess:!1,isError:!1}),g=i.useCallback(e=>{s(P(u.project.prj.view,u.project.value,{id:e}))},[s]),p=i.useCallback(async e=>{n(o=>({...o,isProgressing:!1,isSuccess:!0})),setTimeout(()=>{e?g(e):s(P(u.project.list))},1e3)},[s,g]),b=i.useCallback(async e=>{var o;try{n(a=>({...a,isProgressing:!0,isError:!1}));const t=await j({services:["JOBS","JUPYTER","HIVE","KAFKA","FEATURESTORE","SERVING","AIRFLOW"],projectName:e.projectName,namespace:e.namespace,description:e.description,featureStoreTopic:e.featureStoreTopic}).unwrap();p(t.data)}catch(t){n(d=>({...d,isProgressing:!1,isError:!0}));const a=(o=t==null?void 0:t.response)==null?void 0:o.data;l.error({title:"Error",content:`${a.errorMsg||""} ${a.usrMsg||""}`})}},[j,p,l]),{isProgressing:m,isSuccess:x}=f;return I(N.createProject),r.jsx(w,{projectsNames:c==null?void 0:c.map(({projectName:e})=>e),isLoading:S,onSubmit:b,isProgressingSubmit:m,isSuccessSubmit:x,progressElement:r.jsx(F,{children:r.jsx(O,{isAnimating:m,animationDuration:E/100,incrementDuration:E/25})})})};export{G as default};
