import{d as b,a as f,pk as k,r as y,j as a,I as S,aK as A,R as F,pl as w,pm as C,pn as c}from"./index-5ae5cc5e.js";import{c as v,b as x,u as R}from"./index.esm-bd37e938.js";import{o as E}from"./yup-86a48159.js";import"./GenericThumbnailView-fac7773c.js";import{F as I}from"./FormInput-77541d96.js";import"./componentStyles-7d84c389.js";import"./ScrollableList-2ee889f8.js";import{T}from"./TextArea-20f097f8.js";import{D as B,a as L}from"./DialogContent-e2578cbd.js";import{D as $}from"./DialogTitle-4a5aec12.js";import{D as q}from"./DialogContentText-bc10bf8d.js";import{D as P}from"./DialogActions-ad26e3d6.js";import{L as u}from"./LoadingButton-d465030d.js";const _=({modal:n,setModalOpen:U,closeModal:i})=>{const o=b(),{stages:{selectedData:r,pageParams:m,loading:p}}=f(s=>k(s)),d=v().shape({name:x().required("Please enter stage name").trim().matches(/^[a-zA-Z0-9 ]*$/,"stages name should not contain special characters"),remarks:x().trim()});y.useEffect(()=>{n?e({name:(r==null?void 0:r.name)||"",remarks:(r==null?void 0:r.remarks)||""}):e()},[n,r]);const{control:l,handleSubmit:h,reset:e}=R({resolver:E(d),values:{name:r!=null&&r.name?r==null?void 0:r.name:"",remarks:r!=null&&r.remarks?r==null?void 0:r.remarks:""}}),g=s=>{if(r!=null&&r.id){const t={obj:{id:r!=null&&r.id?r==null?void 0:r.id:"",name:s.name,remarks:s.remarks},pageParams:m,clearDataFn:()=>{i(),o(c({})),e()}};o(C(t))}else{const t={obj:{name:s.name,remarks:s.remarks},pageParams:m,clearDataFn:()=>{i(),o(c({})),e()}};o(w(t))}};return a.jsx(a.Fragment,{children:a.jsxs(B,{open:n,onClose:i,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[a.jsxs($,{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",a.jsx(S,{onClick:i,children:a.jsx(A,{color:"white"})})]}),a.jsx(L,{sx:{px:"24px",pt:"12px !important",pb:0},children:a.jsx(q,{id:"alert-dialog-description",sx:{width:500},children:a.jsxs("form",{style:{width:"100%"},onSubmit:h(g),children:[a.jsx(I,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Stages here...",control:l}),a.jsx(T,{name:"remarks",label:"Remarks",type:"text",placeholder:"Write remarks here...",minRows:3,maxRows:5,containerSx:{display:"grid",gap:1},control:l}),a.jsxs(P,{sx:{p:2},children:[a.jsx(F,{onClick:i,variant:"outlined",color:"secondary",children:"Cancel"}),r!=null&&r.id?a.jsx(u,{variant:"contained",type:"submit",color:"primary",loading:p,autoFocus:!0,children:"Update"}):a.jsx(u,{variant:"contained",type:"submit",color:"primary",loading:p,autoFocus:!0,children:"Submit"})]})]})})})]})})};export{_ as A};
