import{d as b,a as j,p8 as f,r as y,j as t,I as S,aK as F,R as A,p9 as C,pa as v,pb as c}from"./index-6c48ebe4.js";import{c as w,b as E,u as I}from"./index.esm-fd3369ba.js";import{o as B}from"./yup-75ac0470.js";import"./GenericThumbnailView-e18774c4.js";import{F as L}from"./FormInput-345d040e.js";import"./componentStyles-1dd5fe29.js";import"./ScrollableList-e9cb113e.js";import"./TextArea-4432195b.js";import{D as $,a as k}from"./DialogContent-2975c76a.js";import{D as q}from"./DialogTitle-6235c46a.js";import{D as P}from"./DialogContentText-928ca488.js";import{D as R}from"./DialogActions-aa83bc6c.js";import{L as l}from"./LoadingButton-5e243836.js";const Y=({modal:s,setModalOpen:T,closeModal:a})=>{const o=b(),{stages:{selectedData:r,pageParams:m,loading:p}}=j(e=>f(e)),d=w().shape({name:E().required("Please enter stage name").trim().matches(/^[a-zA-Z0-9 ]*$/,"stages name should not contain special characters")});y.useEffect(()=>{s?i({name:(r==null?void 0:r.name)||""}):i()},[s,r]);const{control:u,handleSubmit:x,reset:i}=I({resolver:B(d),values:{name:r!=null&&r.name?r==null?void 0:r.name:""}}),h=e=>{if(r!=null&&r.id){const n={obj:{id:r!=null&&r.id?r==null?void 0:r.id:"",name:e.name},pageParams:m,clearDataFn:()=>{a(),o(c({})),i()}};o(v(n))}else{const n={obj:{name:e.name},pageParams:m,clearDataFn:()=>{a(),o(c({})),i()}};o(C(n))}};return t.jsx(t.Fragment,{children:t.jsxs($,{open:s,onClose:a,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[t.jsxs(q,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[r!=null&&r.id?"Update ":"Add ","Stage",t.jsx(S,{onClick:a,children:t.jsx(F,{color:"white"})})]}),t.jsx(k,{sx:{px:"24px",pt:"12px !important",pb:0},children:t.jsx(P,{id:"alert-dialog-description",sx:{width:500},children:t.jsxs("form",{style:{width:"100%"},onSubmit:x(h),children:[t.jsx(L,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Stages here...",control:u}),t.jsxs(R,{sx:{p:2},children:[t.jsx(A,{onClick:a,variant:"outlined",color:"secondary",children:"Cancel"}),r!=null&&r.id?t.jsx(l,{variant:"contained",type:"submit",color:"primary",loading:p,autoFocus:!0,children:"Update"}):t.jsx(l,{variant:"contained",type:"submit",color:"primary",loading:p,autoFocus:!0,children:"Submit"})]})]})})})]})})};export{Y as A};
