import{r as i,a as x,b as h,j as t,E as j,l as d,G as p,J as v}from"./index-7c7a558c.js";import{S as T,a as F}from"./Switch-6e983219.js";function k(){const[n,u]=i.useState("on"),[r,f]=i.useState(""),{isLoading:b,data:e}=x("getTwoFactorStatus",()=>j()),{isLoading:l,mutate:m}=h(p,{onSuccess:a=>{var s,o;(s=a==null?void 0:a.data)!=null&&s.success&&d.success((o=a==null?void 0:a.data)==null?void 0:o.success)},onError:a=>{var s,o,w,g;(o=(s=a==null?void 0:a.response)==null?void 0:s.data)!=null&&o.message?d.error((g=(w=a==null?void 0:a.response)==null?void 0:w.data)==null?void 0:g.message):d.error("something went wrong. Please try again")}}),{isLoading:c,mutate:_}=h(v);return i.useEffect(()=>{var a;(a=e==null?void 0:e.data)!=null&&a.two_fa_status&&(u(e.data.two_fa_status=="Enabled"?"on":"off"),f(e.data.two_fa_method))},[e]),t.jsx(T,{visible:b,children:t.jsx("div",{className:"w-full rounded-lg shadow dark:border md:mt-0 xl:p-0 dark:border-gray-700",children:t.jsxs("div",{className:"p-6 space-y-4 md:space-y-6 sm:p-8",children:[t.jsx("div",{className:"relative z-0 w-full mb-6 group",children:t.jsx(F,{size:"lg",onLabel:"ON",offLabel:"OFF",label:"Two Factor Authentication",withAsterisk:!0,styles:{track:"background: white",label:"color: white"},checked:n=="on",disabled:l||c,onChange:a=>{l||c||(u(a.currentTarget.checked?"on":"off"),a.currentTarget.checked?m({formdata:{two_fa_status:"Enabled",two_fa_method:r}}):_({formdata:{two_fa_status:"Disabled"}}))}})}),n=="on"?t.jsxs("div",{className:"relative z-0 w-full mb-6 group",children:[t.jsx("p",{className:"text-sm font-medium text-white",children:"Two Factor Authentication Method"}),t.jsxs("select",{onChange:a=>{f(a.target.value),m({formdata:{two_fa_status:"Enabled",two_fa_method:a.target.value}})},value:r,disabled:l||c,className:"w-full px-4 py-2 mt-2 text-gray-700 bg-second border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[t.jsx("option",{value:"email",children:"Email"}),t.jsx("option",{value:"mobile",children:"SMS"})]})]}):null]})})})}export{k as T};
