import{b as y,vF as f,r as k,j as e,I as v,ec as A,B as D,T as L,Q as n,K as m,vG as F,uV as S,vH as w,vI as C}from"./index-60a3c753.js";import{c as I,b as p}from"./index.esm-62d6b2f7.js";import{o as T}from"./yup-92678dde.js";import{u as q}from"./index.esm-c494934a.js";import"./componentStyles-7753bbb9.js";import{F as z}from"./FormInput-74e2c4d2.js";/* empty css                   */import"./ScrollableList-1962b023.js";import{L as B}from"./Loader-466ccb5e.js";import{T as E}from"./TextArea-b2d5bcf9.js";import{D as M,a as P}from"./DialogContent-89e21f2e.js";import{D as R}from"./DialogTitle-fe69da5c.js";import{D as $}from"./DialogContentText-6688bd59.js";import{D as V}from"./DialogActions-e754942c.js";const oe=()=>{const s=y(),{departments:{selectedData:r,loading:d,isModelVisible:x,pageParams:l},mini:{miniLocationList:G,miniLocationLoading:U,miniLocationParams:Z},system:{userAccessList:H}}=f(),a=()=>{s(F({})),j(),s(S(!1))},t=r==null?void 0:r.id,u=I().shape({name:p().required("Please enter your department name").trim().matches(/^[a-zA-Z0-9 ]*$/,"department name should not contain special characters"),remarks:p().required("Please enter your  remarks").trim().matches(/^[a-zA-Z0-9 ]*$/,"remarks should not contain special characters")});k.useEffect(()=>{a()},[]);const{control:c,handleSubmit:h,reset:j}=q({resolver:T(u),values:{name:r!=null&&r.name?r==null?void 0:r.name:"",remarks:r!=null&&r.remarks?r==null?void 0:r.remarks:""}}),b=o=>{if(t){const i={obj:{id:t,name:o.name,remarks:o.remarks},pageParams:l,clearDataFn:()=>{a()}};s(C(i))}else{const i={obj:{name:o.name,remarks:o.remarks},pageParams:l,clearDataFn:()=>{a()}};s(w(i))}};return e.jsx(e.Fragment,{children:e.jsxs(M,{open:x,onClose:a,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(R,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[t?"Update ":"Add ","Department",e.jsx(v,{onClick:a,children:e.jsx(A,{color:"white"})})]}),e.jsx(P,{sx:{px:"24px",pt:"12px !important",pb:0},children:d?e.jsxs(D,{children:[e.jsx(B,{}),e.jsx(L,{textAlign:"center",children:"Loading..."})]}):e.jsx($,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:h(b),children:[e.jsxs(n,{container:!0,spacing:2,children:[e.jsx(n,{size:{xs:24},children:e.jsx(z,{required:!0,name:"name",label:"Name",type:"text",placeholder:"Enter Departments here...",control:c})}),e.jsx(n,{size:{xs:12},children:e.jsx(E,{required:!0,name:"remarks",label:"Remarks",type:"text",placeholder:"Write remarks here...",minRows:3,maxRows:5,containerSx:{display:"grid",gap:1},control:c})})]}),e.jsxs(V,{sx:{p:2},children:[e.jsx(m,{onClick:a,variant:"outlined",color:"secondary",children:"Cancel"}),t?e.jsx(m,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"}):e.jsx(m,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"})]})]})})})]})})};export{oe as A};
