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-def636a4.js";import{c as I,b as p}from"./index.esm-eec4f448.js";import{o as T}from"./yup-c8535458.js";import{u as q}from"./index.esm-7d9d1491.js";import"./componentStyles-41382c67.js";import{F as z}from"./FormInput-8d872744.js";/* empty css                   */import"./ScrollableList-a550bc32.js";import{L as B}from"./Loader-16c57fae.js";import{T as E}from"./TextArea-6c103c50.js";import{D as M,a as P}from"./DialogContent-0cb684b3.js";import{D as R}from"./DialogTitle-e2e75924.js";import{D as $}from"./DialogContentText-b2259947.js";import{D as V}from"./DialogActions-c4045764.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};
