import{c as A,r as o,j as t,it as x,T as E,E as I}from"./index-7d3dbb9c.js";import{u as O}from"./index.esm-12cc9f7b.js";import"./CustomDatepicker-6d5ad1ab.js";import"./index-b5c17d61.js";import"./ScrollableList-ffeab0b0.js";import{c as V,f as b}from"./index.esm-9d396c5f.js";import{o as w}from"./yup-55e79238.js";import"./SectionDivider-be0a23cf.js";import{C as z}from"./Switch-50c04511.js";import{P as B}from"./Menu-5245abf0.js";const U=({app_label:l,model_name:u,instance_id:d,is_active:n,callback:a})=>{const p=A(),[P,m]=o.useState(!1),[e,r]=o.useState(null);let j=V({activeInactive:b().notRequired()});const[v,h]=o.useState(null),y=!!v,[f,T]=o.useState(null),{control:C,handleSubmit:F,register:R,reset:$,setValue:i,watch:q}=O({resolver:w(j),values:{activeInactive:n}}),S=()=>{e!==null&&(i("activeInactive",e),p(x({data:{is_active:e},app_label:l,model_name:u,instance_id:d,callback:a})),a(),r(null),m(!1))};o.useEffect(()=>{console.log(e,"handleconfirm")},[e]);const g=()=>{m(!1),r(null),h(null),i("activeInactive",n)};return t.jsxs(t.Fragment,{children:[t.jsx(z,{name:"activeInactive",control:C,label:"",onChange:c=>{const s=c.target.checked;n&&!s?(r(s),h(c.currentTarget)):(i("activeInactive",s),p(x({data:{is_active:s},app_label:l,model_name:u,instance_id:d,callback:a})),a())},disabled:!n}),t.jsx(B,{id:f?String(f):void 0,open:y,anchorEl:v,onClose:g,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(E,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to inactivate this record? Once it is inactivated, it cannot be reactivated."}),t.jsx(I,{variant:"contained",type:"submit",color:"success",onClick:S,children:"Yes"}),t.jsx(I,{variant:"outlined",size:"small",color:"success",onClick:g,sx:{ml:2},children:"No"})]})})]})};export{U as A};
