Files
nademitex_admin/dist/assets/BannersView-KHMLub3-.js
T

1 line
6.6 KiB
JavaScript
Raw Normal View History

2026-09-24 20:16:16 +03:30
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