import{b as y,vF as f,r as k,j as e,I as v,ef as A,B as D,T as L,P as n,J as m,vG as F,uV as S,vH as w,vI as C}from"./index-d2b25495.js";import{c as I,b as p}from"./index.esm-3043d6d4.js";import{o as T}from"./yup-267e586f.js";import{u as P}from"./index.esm-ce3c2c20.js";import"./componentStyles-0e851d91.js";import{F as q}from"./FormInput-d202e905.js";/* empty css                   */import"./ScrollableList-fc1de312.js";import{L as z}from"./Loader-1b927baf.js";import{T as B}from"./TextArea-7e39a6e1.js";import{D as E,a as M}from"./DialogContent-cded694d.js";import{D as R}from"./DialogTitle-a145b392.js";import{D as $}from"./DialogContentText-43575e44.js";import{D as V}from"./DialogActions-7c802cc8.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}=P({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(E,{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(M,{sx:{px:"24px",pt:"12px !important",pb:0},children:d?e.jsxs(D,{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(B,{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};
