import{d as y,op as f,r as k,j as e,I as D,ax as L,B as A,T as C,z as m,oq as F,n3 as S,or as v,os as w}from"./index-c5c88b67.js";import{c as T,b as d,u as I}from"./index.esm-81620445.js";import{o as z}from"./yup-41605283.js";import"./GenericThumbnailView-43782201.js";import{F as B}from"./FormInput-86f14880.js";import"./componentStyles-a5e5a830.js";import{L as E}from"./ScrollableList-21ab2b9c.js";import{T as M}from"./TextArea-aad9dffe.js";import{D as q,a as P}from"./DialogContent-1350b249.js";import{D as R}from"./DialogTitle-da236dcc.js";import{D as $}from"./DialogContentText-659ecbc3.js";import{G as l}from"./Grid2-0ff60c92.js";import{D as G}from"./DialogActions-1232a7fa.js";const oe=()=>{const o=y(),{departments:{selectedData:r,loading:x,isModelVisible:h,pageParams:c},mini:{miniLocationList:U,miniLocationLoading:V,miniLocationParams:N},system:{userAccessList:W}}=f(),s=()=>{o(F({})),b(),o(S(!1))},t=r==null?void 0:r.id,u=T().shape({name:d().required("Please enter your department name").trim(),remarks:d().trim().matches(/^[a-zA-Z0-9 ]*$/,"remarks should not contain special characters")});k.useEffect(()=>{s()},[]);const{control:p,handleSubmit:j,reset:b}=I({resolver:z(u),values:{name:r!=null&&r.name?r==null?void 0:r.name:"",remarks:r!=null&&r.remarks?r==null?void 0:r.remarks:""}}),g=a=>{if(t){const n={obj:{id:t,name:a.name,remarks:a.remarks},pageParams:c,clearDataFn:()=>{s()}};o(w(n))}else{const n={obj:{name:a.name,remarks:a.remarks},pageParams:c,clearDataFn:()=>{s()}};o(v(n))}};return e.jsx(e.Fragment,{children:e.jsxs(q,{open:h,onClose:(a,i)=>{i!=="backdropClick"&&s()},"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(D,{onClick:s,children:e.jsx(L,{color:"white"})})]}),e.jsx(P,{sx:{px:"24px",pt:"12px !important",pb:0},children:x?e.jsxs(A,{children:[e.jsx(E,{}),e.jsx(C,{textAlign:"center",children:"Loading..."})]}):e.jsx($,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:j(g),children:[e.jsxs(l,{container:!0,spacing:2,children:[e.jsx(l,{size:{xs:24},children:e.jsx(B,{required:!0,name:"name",label:"Name",type:"text",placeholder:"Enter Departments here...",control:p})}),e.jsx(l,{size:{xs:12},children:e.jsx(M,{name:"remarks",label:"Description",type:"text",placeholder:"Write description here...",minRows:3,maxRows:5,containerSx:{display:"grid",gap:1},control:p})})]}),e.jsxs(G,{sx:{p:2},children:[e.jsx(m,{onClick:s,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};
