1 line
5.1 KiB
JavaScript
1 line
5.1 KiB
JavaScript
import{$ as e,A as t,Ct as n,E as r,F as i,G as a,I as o,L as s,M as c,O as l,T as u,Y as d,_ as f,bt as p,ft as m,g as h,j as ee,k as g,n as _,q as v,tt as y,wt as b,xt as x}from"./BasicIcon-CjTTsi6o.js";import{l as S,o as C}from"./index-BQQA5ZX-.js";import{t as w}from"./IconFilter-lDKrtGms.js";import{t as te}from"./PageHeader-WFa4BbgN.js";import{t as ne}from"./SearchField-Ao52FWA8.js";import{t as re}from"./PageSkeleton-CyATkHE1.js";import{t as ie}from"./crm-DPw1h61_.js";import{t as ae}from"./IconHeart-BmvFB3Xr.js";var oe={class:`page products-page`},se={class:`page__scroll page__scroll--with-nav products-scroll`},ce={key:0},le={class:`cat-banner`},T={class:`chips`,role:`tablist`,"aria-label":`فصل`},E=[`onClick`],D={class:`list-meta`},O=[`onClick`],k={class:`product-item__body`},A={class:`product-item__head`},j={class:`product-item__title`},M={key:0,class:`new-tag`},N=[`aria-label`,`aria-pressed`,`onClick`],P={class:`product-item__specs`},F={class:`swatches`},I=[`onClick`],L=_(s({__name:`ProductsView`,setup(s){let _=h(),L=f(),R=ie(),z=S(),B=l(()=>String(_.query.categoryId??``)),V=l(()=>String(_.query.season??``)),H=l(()=>String(_.query.q??``)),U=m(String(_.query.q??``)),W=m([]),G=m([]),K=m(!0),q=m(null),J=m(`newest`),Y=l(()=>B.value?R.usageCategories.find(e=>e.id===B.value)?.title??`محصولات`:V.value?G.value.find(e=>e.id===V.value)?.title??`محصولات`:H.value?`جستجو: ${H.value}`:`همه محصولات`),X=l(()=>{let e=H.value.trim().toLowerCase(),t=[...W.value];return e&&(t=t.filter(t=>t.name.toLowerCase().includes(e)||t.code.toLowerCase().includes(e)||(t.composition||``).toLowerCase().includes(e))),J.value===`name`?t.sort((e,t)=>e.name.localeCompare(t.name,`fa`)):t.sort((e,t)=>Number(t.isNew)-Number(e.isNew)||e.name.localeCompare(t.name,`fa`))});function ue(){J.value=J.value===`newest`?`name`:`newest`}function de(e){U.value=e,L.replace({path:`/products`,query:{...B.value?{categoryId:B.value}:{},...V.value?{season:V.value}:{},...e.trim()?{q:e.trim()}:{}}})}async function Z(){K.value=!0,q.value=null;try{if(!R.usageCategories.length||!G.value.length){let e=await R.loadCategories();G.value=e.seasons}W.value=await R.loadBrowseProducts({categoryId:B.value||void 0,season:V.value||void 0})}catch(e){q.value=e instanceof Error?e.message:`بارگذاری محصولات ناموفق بود.`,W.value=[]}finally{K.value=!1}}a(async()=>{await z.hydrate(),await Z()}),e([B,V],Z),e(H,e=>{U.value=e});function Q(e){L.replace({path:`/products`,query:{...B.value?{categoryId:B.value}:{},...e?{season:e}:{},...H.value?{q:H.value}:{}}})}function $(e){L.push({path:`/product`,query:{id:e}})}function fe(e){return G.value.find(t=>t.id===e)?.title??e}function pe(e){z.toggle(e)}return(e,a)=>(v(),c(`div`,oe,[o(te,{title:Y.value,"show-back":``,centered:``,onBack:a[1]||=e=>p(L).back()},{trailing:y(()=>[g(`button`,{type:`button`,class:`nav-filter`,"aria-label":`فیلتر`,onClick:a[0]||=e=>p(L).push(`/categories`)},[o(w,{size:18})])]),_:1},8,[`title`]),g(`div`,se,[o(ne,{"model-value":U.value,placeholder:`جستجو نام یا کد محصول...`,"onUpdate:modelValue":de},null,8,[`model-value`]),q.value?(v(),c(`p`,ce,b(q.value),1)):K.value?(v(),t(re,{key:1,variant:`grid`})):(v(),c(r,{key:2},[g(`section`,le,[a[4]||=g(`div`,{class:`cat-banner__icon`,"aria-hidden":`true`},null,-1),g(`div`,null,[g(`h2`,null,b(Y.value),1),a[3]||=g(`p`,null,`شیک، بادوام و رسمی`,-1)])]),g(`div`,T,[g(`button`,{type:`button`,class:x([`chip`,{"chip--active":!V.value}]),onClick:a[2]||=e=>Q(``)},` همه `,2),(v(!0),c(r,null,d(G.value,e=>(v(),c(`button`,{key:e.id,type:`button`,class:x([`chip`,{"chip--active":V.value===e.id}]),onClick:t=>Q(e.id)},b(e.title),11,E))),128))]),g(`div`,D,[g(`span`,null,`تعداد محصولات: `+b(X.value.length.toLocaleString(`fa-IR`)),1),g(`button`,{type:`button`,class:`list-meta__sort`,onClick:ue},` مرتبسازی: `+b(J.value===`newest`?`جدیدترین`:`نام`),1)]),(v(!0),c(r,null,d(X.value,e=>(v(),c(`article`,{key:e.id,class:`product-item`,onClick:t=>$(e.id)},[g(`div`,{class:`product-item__image`,style:n(e.imageUrl?{backgroundImage:`url(${e.imageUrl})`}:void 0)},null,4),g(`div`,k,[g(`div`,A,[g(`div`,j,[g(`strong`,null,b(e.name),1),e.isNew?(v(),c(`span`,M,`جدید`)):ee(``,!0)]),g(`button`,{type:`button`,class:`bookmark`,"aria-label":p(z).isFavorite(e.id)?`حذف از علاقهمندیها`:`افزودن به علاقهمندیها`,"aria-pressed":p(z).isFavorite(e.id),onClick:u(t=>pe(e.id),[`stop`])},[o(ae,{size:18,filled:p(z).isFavorite(e.id),color:p(z).isFavorite(e.id)?`#0a353c`:`#9ca3af`},null,8,[`filled`,`color`])],8,N)]),g(`ul`,P,[g(`li`,null,`عرض: `+b(e.widthCm.toLocaleString(`fa-IR`))+` سانتیمتر`,1),g(`li`,null,`ترکیب: `+b(e.composition||`—`),1),g(`li`,null,`مناسب: `+b(fe(e.season)),1)]),g(`div`,F,[(v(!0),c(r,null,d(e.colors.slice(0,6),(e,t)=>(v(),c(`span`,{key:t,class:`swatch`,style:n({background:e})},null,4))),128))]),g(`button`,{type:`button`,class:`details-link`,onClick:u(t=>$(e.id),[`stop`])},[a[5]||=i(` مشاهده جزئیات `,-1),o(C,{size:14})],8,I)])],8,O))),128))],64))])]))}}),[[`__scopeId`,`data-v-447a90f3`]]);export{L as default}; |