"use strict";(self["webpackChunkLightAble"]=self["webpackChunkLightAble"]||[]).push([[64],{7503:function(e,t,a){a.r(t),a.d(t,{default:function(){return L}});var o=a(6768),l=a(4232),n=a(5130);const s={class:"col-sm-12"},i={class:"col-form-label col-sm-3 text-sm-end"},u={class:"col-lg-6 col-sm-7"},r=["onChange"],d={key:0,class:"text-muted"},c=["href"],p=["onUpdate:modelValue","placeholder"],g={class:"col-lg-3 mt-2"},h={key:0},k={key:1};function m(e,t,a,m,f,v){const C=(0,o.g2)("BCardHeader"),_=(0,o.g2)("BButton"),b=(0,o.g2)("BCardBody"),y=(0,o.g2)("BCard"),F=(0,o.g2)("BRow"),L=(0,o.g2)("Layout");return(0,o.uX)(),(0,o.Wv)(L,null,{default:(0,o.k6)((()=>[(0,o.bF)(F,null,{default:(0,o.k6)((()=>[(0,o.Lk)("div",s,[(0,o.bF)(y,{"no-body":""},{default:(0,o.k6)((()=>[(0,o.bF)(C,null,{default:(0,o.k6)((()=>t[0]||(t[0]=[(0,o.Lk)("h5",null,"Site Settings",-1)]))),_:1}),(0,o.bF)(b,null,{default:(0,o.k6)((()=>[((0,o.uX)(!0),(0,o.CE)(o.FK,null,(0,o.pI)(m.settings,(e=>((0,o.uX)(),(0,o.CE)("div",{class:"mb-3 row",key:e.id},[(0,o.Lk)("label",i,(0,l.v_)(m.getFieldLabel(e.key)),1),(0,o.Lk)("div",u,[m.isImageField(e.key)?((0,o.uX)(),(0,o.CE)(o.FK,{key:0},[(0,o.Lk)("input",{type:"file",class:"form-control",onChange:t=>m.onFileChange(t,e)},null,40,r),e.value?((0,o.uX)(),(0,o.CE)("small",d,[t[1]||(t[1]=(0,o.eW)(" عکس کنونی: ")),(0,o.Lk)("a",{href:m.getFileUrl(e.value),target:"_blank"},"مشاهده",8,c)])):(0,o.Q3)("",!0)],64)):(0,o.bo)(((0,o.uX)(),(0,o.CE)("input",{key:1,type:"text",class:"form-control","onUpdate:modelValue":t=>e.value=t,placeholder:`Enter ${e.key}`},null,8,p)),[[n.Jo,e.value]])]),(0,o.Lk)("div",g,[(0,o.bF)(_,{variant:"primary",size:"sm",disabled:m.loadingIds.includes(e.id),onClick:t=>m.updateSetting(e)},{default:(0,o.k6)((()=>[m.loadingIds.includes(e.id)?((0,o.uX)(),(0,o.CE)("span",h," ویرایش... ")):((0,o.uX)(),(0,o.CE)("span",k,"ویرایش"))])),_:2},1032,["disabled","onClick"])])])))),128))])),_:1})])),_:1})])])),_:1})])),_:1})}a(4114);var f=a(3148),v=a(144),C=a(4373),_=a(4084),b={name:"SETTING",components:{Layout:f.A},setup(){const e=localStorage.getItem("token"),t="https://api.nghsco.com/api",a=(0,v.KR)([]),l=(0,v.KR)([]),n=()=>{C.A.get(`${t}/admin/settings`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}}).then((e=>{a.value=e.data.data})).catch((e=>{console.error("Failed to fetch settings:",e)}))},s=e=>"logo"===e||"about_us_image"===e,i=e=>`https://api.nghsco.com/storage/statics/${e}`,u=(e,t)=>{const a=e.target.files[0];a&&(t.file=a)},r=a=>{if(l.value.push(a.id),s(a.key)&&a.file){const o=new FormData;o.append("value",a.file),o.append("_method","put"),C.A.post(`${t}/admin/settings/${a.id}`,o,{headers:{Authorization:`Bearer ${e}`}}).then((()=>{_.oR.success("تنظیمات با موفقیت ویرایش شد",{position:"top-right",autoClose:1e3}),n()})).catch((()=>{_.oR.error("مشکلی در ویرایش تنظیمات پیش آمد",{position:"top-right",autoClose:1e3})})).finally((()=>{l.value=l.value.filter((e=>e!==a.id))}))}else{const o=new FormData;o.append("value",a.value),o.append("_method","put"),C.A.post(`${t}/admin/settings/${a.id}`,o,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}}).then((()=>{_.oR.success("تنظیمات با موفقیت ویرایش شد",{position:"top-right",autoClose:1e3}),n()})).catch((()=>{_.oR.error("مشکلی در ویرایش تنظیمات پیش آمد",{position:"top-right",autoClose:1e3})})).finally((()=>{l.value=l.value.filter((e=>e!==a.id))}))}},d=e=>{const t={logo:"لوگو",about_us_description_fa:"درباره ما (فارسی)",about_us_description_en:"درباره ما(انگلیسی)",app_version_fa:"ورژن اپلیکیشن(فارسی)",app_version_en:"ورژن اپلیکیشن(انگلیسی)",about_us_image:"عکس در باره ما"};return t[e]||e};return(0,o.sV)((()=>{n()})),{settings:a,loadingIds:l,getSettings:n,updateSetting:r,getFieldLabel:d,isImageField:s,getFileUrl:i,onFileChange:u}}},y=a(1241);const F=(0,y.A)(b,[["render",m]]);var L=F}}]); //# sourceMappingURL=64.f8868a8d.js.map