Files
nademitex_admin/dist/assets/BannersView-KHMLub3-.js
T
mohmdsdgandCopilot 981f4fdaf9 build: refresh admin production assets
Publish the verified admin build output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-24 20:16:16 +03:30

1 line
6.6 KiB
JavaScript

import{B as e,Dt as t,O as n,Ot as r,T as i,Tt as a,V as o,Y as s,Z as c,c as l,d as u,g as d,h as f,j as p,l as m,m as h,r as g,s as _,t as v,u as y}from"./_plugin-vue_export-helper-OaxA6A2f.js";import{N as b,R as ee,W as x,l as S,z as C}from"./index-CXa4EMLW.js";import{t as te}from"./AdminPageSkeleton-CTgUqaAu.js";import{t as w}from"./BaseSwitch-TV5Yvtf7.js";import{t as T}from"./BaseEmptyState-BmO9aDcK.js";import{t as E}from"./AdminImagePicker-C4toq7MG.js";import{t as D}from"./AdminSelect-9UfEJQzN.js";var O={class:`banners-page`},k={key:2,class:`admin-card`},A={class:`admin-table`},j={key:0,class:`banner-sub`},M={class:`actions`},N=[`onClick`],P=[`onClick`],F={class:`field`},I={class:`field`},L={class:`field__head`},R={class:`field`},z={class:`field__head`},B={class:`field`},ne={class:`field__head`},V={class:`field`},H={class:`field`},U=[`disabled`],W=v(d({__name:`BannersView`,setup(d){let v=[{value:`home_hero`,label:`خانه — بنر اصلی`},{value:`products_hero`,label:`لیست محصولات`},{value:`categories_hero`,label:`دسته‌بندی‌ها`}],W=c([]),G=c(!0),K=c(!1),q=c(!1),J=c(null),Y=C(),X=s({slot:`home_hero`,title:``,subtitle:``,ctaLabel:``,ctaLink:`/categories`,imageUrl:null,displayOrder:0,isActive:!0,showTitle:!0,showSubtitle:!0,showCta:!0}),Z=_(()=>J.value?`ویرایش بنر`:`افزودن بنر`);function re(e){return v.find(t=>t.value===e)?.label??e}async function Q(){G.value=!0;try{W.value=await S.list()}catch(e){Y.error(e instanceof b?e.message:`بارگذاری بنرها ناموفق بود.`)}finally{G.value=!1}}function $(){J.value=null,Object.assign(X,{slot:`home_hero`,title:``,subtitle:``,ctaLabel:`مشاهده کالکشن`,ctaLink:`/categories`,imageUrl:null,displayOrder:W.value.length,isActive:!0,showTitle:!0,showSubtitle:!0,showCta:!0}),q.value=!0}function ie(e){J.value=e.id,Object.assign(X,{slot:e.slot,title:e.title,subtitle:e.subtitle,ctaLabel:e.ctaLabel,ctaLink:e.ctaLink||`/categories`,imageUrl:e.imageUrl||null,displayOrder:e.displayOrder,isActive:e.isActive,showTitle:e.showTitle!==!1,showSubtitle:e.showSubtitle!==!1,showCta:e.showCta!==!1}),q.value=!0}async function ae(){if(X.title.trim()){K.value=!0;try{let e={slot:X.slot,title:X.title.trim(),subtitle:X.subtitle.trim()||null,ctaLabel:X.ctaLabel.trim()||null,ctaLink:X.ctaLink.trim()||null,imageUrl:X.imageUrl,displayOrder:X.displayOrder,isActive:X.isActive,showTitle:X.showTitle,showSubtitle:X.showSubtitle,showCta:X.showCta};J.value?await S.update(J.value,e):await S.create(e),q.value=!1,Y.success(`بنر ذخیره شد.`),await Q()}catch(e){Y.error(e instanceof b?e.message:`ذخیره بنر ناموفق بود.`)}finally{K.value=!1}}}async function oe(e){if(window.confirm(`بنر «${e.title}» حذف شود؟`))try{await S.remove(e.id),Y.success(`بنر حذف شد.`),await Q()}catch(e){Y.error(e instanceof b?e.message:`حذف بنر ناموفق بود.`)}}return i(()=>{Q()}),(i,s)=>(n(),u(`div`,O,[l(`div`,{class:`admin-page-header`},[s[13]||=l(`div`,null,[l(`h1`,{class:`admin-page-header__title`},`بنرها`),l(`p`,{class:`admin-page-header__sub`},`بنر بخش‌های مختلف اپ کاربر را از اینجا مدیریت کنید.`)],-1),l(`button`,{type:`button`,class:`admin-btn admin-btn--primary`,onClick:$},`افزودن بنر`)]),G.value?(n(),m(te,{key:0,variant:`table`})):W.value.length?(n(),u(`div`,k,[l(`table`,A,[s[14]||=l(`thead`,null,[l(`tr`,null,[l(`th`,null,`تصویر`),l(`th`,null,`عنوان`),l(`th`,null,`بخش`),l(`th`,null,`دکمه`),l(`th`,null,`فعال`),l(`th`,{class:`actions`},`عملیات`)])],-1),l(`tbody`,null,[(n(!0),u(g,null,p(W.value,e=>(n(),u(`tr`,{key:e.id},[l(`td`,null,[l(`span`,{class:a([`banner-thumb`,{"banner-thumb--empty":!e.imageUrl}]),style:t(e.imageUrl?{backgroundImage:`url(${e.imageUrl})`}:void 0)},null,6)]),l(`td`,null,[l(`strong`,null,r(e.title),1),e.subtitle?(n(),u(`p`,j,r(e.subtitle),1)):y(``,!0)]),l(`td`,null,r(re(e.slot)),1),l(`td`,null,r(e.ctaLabel||`—`),1),l(`td`,null,r(e.isActive?`بله`:`خیر`),1),l(`td`,M,[l(`button`,{type:`button`,class:`admin-btn admin-btn--ghost admin-btn--xs`,onClick:t=>ie(e)},` ویرایش `,8,N),l(`button`,{type:`button`,class:`admin-btn admin-btn--ghost admin-btn--xs`,onClick:t=>oe(e)},` حذف `,8,P)])]))),128))])])])):(n(),m(T,{key:1,title:`بنری ثبت نشده`,description:`اولین بنر خانه را اضافه کنید.`},{default:e(()=>[l(`button`,{type:`button`,class:`admin-btn admin-btn--primary admin-btn--sm`,onClick:$},` افزودن بنر `)]),_:1})),f(ee,{open:q.value,title:Z.value,onClose:s[12]||=e=>q.value=!1},{footer:e(()=>[l(`button`,{type:`button`,class:`admin-btn admin-btn--outline`,onClick:s[11]||=e=>q.value=!1},`انصراف`),l(`button`,{type:`button`,class:`admin-btn admin-btn--primary`,disabled:!X.title.trim()||K.value,onClick:ae},r(K.value?`در حال ذخیره...`:`ذخیره`),9,U)]),default:e(()=>[l(`label`,F,[s[15]||=h(` بخش نمایش `,-1),f(D,{modelValue:X.slot,"onUpdate:modelValue":s[0]||=e=>X.slot=e,options:v},null,8,[`modelValue`])]),l(`div`,I,[l(`span`,L,[s[16]||=h(` عنوان `,-1),f(w,{modelValue:X.showTitle,"onUpdate:modelValue":s[1]||=e=>X.showTitle=e,"active-text":`نمایش`,"inactive-text":`مخفی`},null,8,[`modelValue`])]),o(l(`input`,{"onUpdate:modelValue":s[2]||=e=>X.title=e,class:`admin-input`},null,512),[[x,X.title]])]),l(`div`,R,[l(`span`,z,[s[17]||=h(` زیرعنوان `,-1),f(w,{modelValue:X.showSubtitle,"onUpdate:modelValue":s[3]||=e=>X.showSubtitle=e,"active-text":`نمایش`,"inactive-text":`مخفی`},null,8,[`modelValue`])]),o(l(`input`,{"onUpdate:modelValue":s[4]||=e=>X.subtitle=e,class:`admin-input`},null,512),[[x,X.subtitle]])]),l(`div`,B,[l(`span`,ne,[s[18]||=h(` متن دکمه `,-1),f(w,{modelValue:X.showCta,"onUpdate:modelValue":s[5]||=e=>X.showCta=e,"active-text":`نمایش`,"inactive-text":`مخفی`},null,8,[`modelValue`])]),o(l(`input`,{"onUpdate:modelValue":s[6]||=e=>X.ctaLabel=e,class:`admin-input`},null,512),[[x,X.ctaLabel]])]),l(`label`,V,[s[19]||=h(` لینک دکمه `,-1),o(l(`input`,{"onUpdate:modelValue":s[7]||=e=>X.ctaLink=e,class:`admin-input`,dir:`ltr`,placeholder:`/categories`},null,512),[[x,X.ctaLink]])]),l(`label`,H,[s[20]||=h(`ترتیب نمایش`,-1),o(l(`input`,{"onUpdate:modelValue":s[8]||=e=>X.displayOrder=e,type:`number`,min:`0`,class:`admin-input`},null,512),[[x,X.displayOrder,void 0,{number:!0}]])]),f(E,{modelValue:X.imageUrl,"onUpdate:modelValue":s[9]||=e=>X.imageUrl=e,label:`تصویر بنر`},null,8,[`modelValue`]),f(w,{modelValue:X.isActive,"onUpdate:modelValue":s[10]||=e=>X.isActive=e,label:`فعال`},null,8,[`modelValue`])]),_:1},8,[`open`,`title`])]))}}),[[`__scopeId`,`data-v-1ca3d686`]]);export{W as default};