import{c as A,r as o,j as t,ir as x,T as E,E as I}from"./index-6fe66247.js";import{u as O}from"./index.esm-8dc7c617.js";import"./CustomDatepicker-8082706c.js";import"./index-b6aec95e.js";import"./ScrollableList-0f8e556e.js";import{c as V,f as b}from"./index.esm-34c2a639.js";import{o as w}from"./yup-ef931f05.js";import"./SectionDivider-ea552de1.js";import{C as z}from"./Switch-e0ef0768.js";import{P as B}from"./Menu-e61076f9.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,s]=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(),s(null),m(!1))};o.useEffect(()=>{console.log(e,"handleconfirm")},[e]);const g=()=>{m(!1),s(null),h(null),i("activeInactive",n)};return t.jsxs(t.Fragment,{children:[t.jsx(z,{name:"activeInactive",control:C,label:"",onChange:c=>{const r=c.target.checked;n&&!r?(s(r),h(c.currentTarget)):(i("activeInactive",r),p(x({data:{is_active:r},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};
