import{a as g,b as x,r as S,j as n,n as s}from"./index-7c7a558c.js";import{B as h}from"./Breadcrumb-21e99ae5.js";import{a as j,b as F}from"./settingsApi-5a4df441.js";import{G as w}from"./GeneralSettingsSkeleton-aed31d86.js";import{F as G}from"./FormGenerator-3d4cd06b.js";import{o as H}from"./ObjectToFormData-bf0af219.js";import"./ImageUpload-16444a76.js";import"./user_image-87dc2d58.js";function M(){const{isLoading:m,refetch:_}=g("getHomeSettings",j,{onSuccess:e=>{var t,a,l,i,o;(a=(t=e==null?void 0:e.data)==null?void 0:t.data)!=null&&a.home&&((o=Object.entries((i=(l=e==null?void 0:e.data)==null?void 0:l.data)==null?void 0:i.home))==null||o.map(([r,f])=>{u(c=>({...c,[r]:{...c[r],value:f}}))}))},refetchOnWindowFocus:!1}),{isLoading:p,mutate:d}=x(F,{onSuccess:()=>{s.success("Successfully Saved!"),_()},onError:e=>{var t,a,l;(t=e==null?void 0:e.response)!=null&&t.data?s.error(`${(l=(a=e==null?void 0:e.response)==null?void 0:a.data)==null?void 0:l.error}`):s.error("something went wrong")}}),y=e=>{s.dismiss(),p||d({formdata:H(e)})},[v,u]=S.useState({banner_mini_words_title:{type:"text",value:null},banner_first_line_title:{type:"text",value:null},banner_second_line_title:{type:"text",value:null},banner_second_line_changeable_words:{type:"text",value:null},banner_third_line_title:{type:"text",value:null},banner_subtitle:{type:"text",value:null},banner_first_button_name:{type:"text",value:null},banner_first_button_link:{type:"text",value:null},banner_second_button_name:{type:"text",value:null},banner_second_button_link:{type:"text",value:null},banner_image:{type:"image",value:null},special_feature_area:{type:"select",value:null},courses_area:{type:"select",value:null},bundle_area:{type:"select",value:null},top_category_area:{type:"select",value:null},consultation_area:{type:"select",value:null},instructor_area:{type:"select",value:null},video_area:{type:"select",value:null},customer_says_area:{type:"select",value:null},achievement_area:{type:"select",value:null},faq_area:{type:"select",value:null},instructor_support_area:{type:"select",value:null}}),b=e=>{const{name:t,files:a}=e.target;u(l=>({...l,[t]:{type:"image",value:a[0]}}))};return n.jsxs(n.Fragment,{children:[n.jsx(h,{title:"Home Settings"}),n.jsx("div",{className:"my-12",children:m?n.jsx(w,{}):n.jsx(G,{formData:v,setterFormDataImage:b,onSubmit:y})})]})}export{M as default};
