import{j as e,bf as j,S as p,a7 as S}from"./vendor-mui-CBBEb17G.js";import{a as x,u as A}from"./vendor-react-BBazpZul.js";import{aO as h,by as i,aP as c,ao as g,J as U}from"./index-DdWwwZXu.js";import{a as m}from"./vendor-utils-BveVE6Uf.js";import"./vendor-charts-tGnAgELZ.js";const w=()=>{const[o,a]=x.useState(!1);return{getSettingAsync:async()=>{try{a(!0);const s=await m.get("AppSettingJson/Get");return s==null?void 0:s.data}finally{a(!1)}},updateSettingAsync:async s=>{try{a(!0);const n=await m.post("AppSettingJson/Update",s);return n==null?void 0:n.data}finally{a(!1)}},isLoading:o}},C={baseSmsApiUrl:"",licenseBaseUrl1:"",licenseBaseUrl2:"",prescribeUrl:"",prescribeUrl2:""},B=()=>{const{getSettingAsync:o,updateSettingAsync:a,isLoading:r}=w(),u=A(),{control:s,reset:n,handleSubmit:f,formState:{errors:l}}=h({defaultValues:C}),y=async()=>{const{data:t}=await o();t&&n(t)},b=async t=>{const{message:d}=await a(t);d&&U.success(d)};return x.useEffect(()=>{y()},[]),e.jsx(j,{className:"h-full ",children:e.jsxs(p,{justifyContent:"center",alignItems:"center",spacing:2,pt:4,children:[e.jsx(S,{component:"h1",variant:"h4",children:"تنظیمات اصلی مرکز"}),e.jsxs("form",{className:"flex flex-col gap-4 p-4 w-full min-w-[300px] max-w-[500px]",children:[e.jsx(i,{name:"prescribeUrl",control:s,rules:{required:!0},render:({field:t})=>e.jsx(c,{...t,label:"آدرس سرور نسخه نویسی اول",fullWidth:!0,error:!!l.prescribeUrl,disabled:r,inputProps:{style:{textAlign:"left"}}})}),e.jsx(i,{name:"prescribeUrl2",control:s,rules:{required:!0},render:({field:t})=>e.jsx(c,{...t,label:"آدرس سرور نسخه نویسی دوم",fullWidth:!0,error:!!l.prescribeUrl2,disabled:r,inputProps:{style:{textAlign:"left"}}})}),e.jsx(i,{name:"licenseBaseUrl1",control:s,rules:{required:!0},render:({field:t})=>e.jsx(c,{...t,label:"آدرس سرور لایسنس اول",fullWidth:!0,error:!!l.licenseBaseUrl1,disabled:r,inputProps:{style:{textAlign:"left"}}})}),e.jsx(i,{name:"licenseBaseUrl2",control:s,rules:{required:!0},render:({field:t})=>e.jsx(c,{...t,label:"آدرس سرور لایسنس دوم",fullWidth:!0,error:!!l.licenseBaseUrl2,disabled:r,inputProps:{style:{textAlign:"left"}}})}),e.jsx(i,{name:"baseSmsApiUrl",control:s,rules:{required:!0},render:({field:t})=>e.jsx(c,{...t,label:"آدرس سرور پیامک",fullWidth:!0,error:!!l.baseSmsApiUrl,disabled:r,inputProps:{style:{textAlign:"left"}}})})]}),e.jsxs(p,{direction:"row",justifyContent:"center",alignItems:"center",spacing:2,children:[e.jsx(g,{className:"w-32",color:"success",loading:r,onClick:f(b),children:"ویرایش"}),e.jsx(g,{className:"w-32",color:"primary",disabled:r,onClick:()=>u("/"),children:"بازگشت"})]})]})})},J=()=>e.jsx(B,{});export{J as default};
