import{b as y,vA as f,r as k,j as e,I as A,ec as D,B as v,T as L,Q as n,K as m,vB as C,uQ as F,vC as S,vD as w}from"./index-76d4793e.js";import{c as T,b as p}from"./index.esm-ad8a7c9f.js";import{o as B}from"./yup-688ec4f6.js";import{u as I}from"./index.esm-3adfd9f7.js";import"./componentStyles-0803b39e.js";import{F as q}from"./FormInput-8f40ded1.js";/* empty css                   */import"./ScrollableList-4dae3697.js";import{L as z}from"./Loader-9f443a4c.js";import{T as E}from"./TextArea-f4ef1e8b.js";import{D as M,a as P}from"./DialogContent-7bd8dd8f.js";import{D as R}from"./DialogTitle-71dd5b3a.js";import{D as $}from"./DialogContentText-7642f81f.js";import{D as Q}from"./DialogActions-5a5e1db9.js";const oe=()=>{const s=y(),{departments:{selectedData:r,loading:d,isModelVisible:x,pageParams:l},mini:{miniLocationList:U,miniLocationLoading:V,miniLocationParams:Z},system:{userAccessList:G}}=f(),a=()=>{s(C({})),j(),s(F(!1))},t=r==null?void 0:r.id,u=T().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}=I({resolver:B(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(w(i))}else{const i={obj:{name:o.name,remarks:o.remarks},pageParams:l,clearDataFn:()=>{a()}};s(S(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(A,{onClick:a,children:e.jsx(D,{color:"white"})})]}),e.jsx(P,{sx:{px:"24px",pt:"12px !important",pb:0},children:d?e.jsxs(v,{children:[e.jsx(z,{}),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(q,{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(Q,{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};
