Files
tehran_taj/apps/user-app-v2/dist/assets/HomeView-B-ttY4qX.js
T
mahmoodandClaude Sonnet 5.5 0b973f9e46 fix(app): re-check the sales-expert flag on every dashboard visit
The "سفارش مشتریان" / "مشتریان من" entries are shown from session.isSalesExpert,
which was fetched from /expert/whoami only once, at sign-in. A slow or failed
request (silently swallowed) left the flag false until the next login, so an
expert saw a customer-only menu. The dashboard now asks again on mount and on
every re-activation, and keeps the current value when the request fails.

Rebuilds user-app and user-app-v2 dist.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 10:23:08 +03:30

2 lines
9.9 KiB
JavaScript

import{d as N,u as oe,o as te,a as le,b as n,c as o,e as u,F as B,r as U,n as M,f as G,g as w,h as y,i as S,_ as F,j as V,t as D,I as j,k as ie,l as ce,w as re,m as C,p as H,q as ue,s as q,v as se,x as de,y as _e,K as W,z as ve,A as pe,B as fe,C as Y,D as me,E as ge,G as he}from"./index-BIZGiNHX.js";import{A as ye}from"./AppPullRefresh-BHaN1AoQ.js";import{R as ke}from"./RateStrip-DO3b69bq.js";import{u as $e}from"./catalogStore-DypV9mP2.js";import"./filters-CVq8c4MW.js";const Ie={key:0,class:"hero"},be=["onClick"],Ce=["src"],Pe={key:1,class:"hero__artFallback","aria-hidden":"true"},Se={key:0,class:"hero__dots"},we=["aria-label","onClick"],K=46,xe=.76,Ee=36.6,Re=.75,Oe=N({__name:"HeroCarousel",props:{slides:{},autoplay:{type:Boolean,default:!0}},setup(d){const m=d,v=y(0),k=y(null),_=y(!1),l=y(0);let r=0,p=null,g;const h=oe(),c=S(()=>m.slides.length);function f(e){let t=e-v.value;c.value>2&&(t>c.value/2&&(t-=c.value),t<-c.value/2&&(t+=c.value));const a=_.value?l.value:0,s=Math.abs(t),i=t*Ee+a,P=t===0?1:xe,b=s>1?0:s===0?1:Re;return{transform:`translate3d(${i}%, 0, 0) scale(${P})`,opacity:String(b),zIndex:String(10-s),pointerEvents:s>1?"none":"auto",transition:_.value?"none":"transform .42s cubic-bezier(.22,.61,.36,1), opacity .42s ease"}}function I(e){v.value=(e%c.value+c.value)%c.value,O()}function $(){I(v.value+1)}function L(){I(v.value-1)}function T(e){var t,a;c.value<2||(_.value=!0,r=e.clientX,l.value=0,p=e.pointerId,(a=(t=e.currentTarget).setPointerCapture)==null||a.call(t,e.pointerId),R())}function z(e){var a;if(!_.value||e.pointerId!==p)return;const t=((a=k.value)==null?void 0:a.clientWidth)||1;l.value=(e.clientX-r)/t*100}function x(e){if(!_.value)return;const t=e.clientX-r;_.value=!1,l.value=0,p=null,t>K?L():t<-K?$():O()}function E(e){Math.abs(l.value)>1||e!==v.value&&I(e)}function R(){g&&clearInterval(g),g=void 0}function O(){R(),m.autoplay&&!h.isReducedMotion&&c.value>1&&(g=setInterval($,6e3))}return te(O),le(R),(e,t)=>d.slides.length?(n(),o("section",Ie,[u("div",{class:"hero__stage",ref_key:"stage",ref:k,onPointerdown:T,onPointermove:z,onPointerup:x,onPointercancel:x},[(n(!0),o(B,null,U(d.slides,(a,s)=>(n(),o("article",{key:a.key,class:G(["hero__card",{"is-active":s===v.value}]),style:M(f(s)),onClick:i=>E(s)},[a.image?(n(),o("img",{key:0,src:a.image,alt:"",class:"hero__art",draggable:"false"},null,8,Ce)):(n(),o("div",Pe))],14,be))),128))],544),d.slides.length>1?(n(),o("div",Se,[(n(!0),o(B,null,U(d.slides,(a,s)=>(n(),o("button",{key:a.key,type:"button",class:G(["hero__dot",{"is-active":s===v.value}]),"aria-label":`اسلاید ${s+1}`,onClick:i=>I(s)},null,10,we))),128))])):w("",!0)])):w("",!0)}}),Ae=F(Oe,[["__scopeId","data-v-ddde804b"]]),He={class:"cats no-scrollbar"},Me=["onClick"],Be={class:"cats__mark","aria-hidden":"true"},Le=["src"],Te={class:"cats__title"},ze=N({__name:"CategoryGrid",props:{categories:{},activeId:{}},emits:["select"],setup(d,{emit:m}){const v=m;return(k,_)=>(n(),o("div",He,[(n(!0),o(B,null,U(d.categories,l=>{var r;return n(),o("button",{key:l.id,type:"button",class:G(["cats__tile",{"is-active":l.id===d.activeId}]),onClick:p=>v("select",l)},[u("span",Be,[(r=l.icon)!=null&&r.image?(n(),o("img",{key:0,src:l.icon.image,alt:""},null,8,Le)):(n(),V(j,{key:1,icon:"vuesax-linear:3d-cube-scan",size:"27"}))]),u("span",Te,D(l.title),1)],10,Me)}),128))]))}}),De=F(ze,[["__scopeId","data-v-155beefb"]]),Ue={class:"panel__art"},Ge=["alt"],Ne={class:"panel__title"},Fe={class:"panel__meta"},Ve={class:"panel__weight"},Xe={key:0,class:"panel__wageOld"},qe={class:"panel__wage"},je=N({__name:"ProductPanel",props:{value:{},wageBefore:{}},emits:["open"],setup(d,{emit:m}){const v=d,k=m,{image:_,title:l,min_gram:r,wage:p}=ie(v.value);function g(h){return h%1===0?String(h):h.toFixed(2)}return(h,c)=>{const f=ce("lazy");return n(),o("article",{class:"panel","data-product-origin":"",onClick:c[0]||(c[0]=I=>k("open",d.value))},[u("div",Ue,[re(u("img",{alt:C(l)},null,8,Ge),[[f,C(_)]])]),u("h3",Ne,D(C(l)),1),u("div",Fe,[u("span",Ve,D(C(r))+" گرم",1),C(p)!=null?(n(),o(B,{key:0},[c[1]||(c[1]=u("span",{class:"panel__sep","aria-hidden":"true"},null,-1)),d.wageBefore!=null?(n(),o("span",Xe,"اجرت "+D(g(d.wageBefore))+"٪",1)):w("",!0),u("span",qe,D(g(C(p)))+"٪ اجرت",1)],64)):w("",!0)])])}}}),ae=F(je,[["__scopeId","data-v-ccafc905"]]),We={class:"reel"},Ye=["onClick"],Ke={class:"reel__allMark","aria-hidden":"true"},Q=46,Qe=.78,Z=92.5,Ze=.62,Je=N({__name:"ProductCarousel",props:{products:{}},emits:["open","all"],setup(d,{emit:m}){const v=d,k=m,_=y(0),l=y(null),r=y(!1),p=y(0);let g=0,h=null;const c=S(()=>[...v.products.map(e=>({key:e.id,kind:"product",product:e})),{key:"__all__",kind:"all"}]),f=S(()=>c.value.length);function I(e){let t=e-_.value;f.value>2&&(t>f.value/2&&(t-=f.value),t<-f.value/2&&(t+=f.value));const a=r.value?p.value:0,s=t*Z+a,i=Math.min(Math.abs(t+a/Z),1),P=1-(1-Qe)*i,b=1-(1-Ze)*i,A=Math.abs(t)<=1,X=A?b:0;return{transform:`translate3d(${s}%, 0, 0) scale(${P})`,opacity:String(X),zIndex:String(10-Math.abs(t)),pointerEvents:A?"auto":"none",transition:r.value?"none":"transform .55s cubic-bezier(.21,1.02,.36,1), opacity .45s ease"}}function $(e){_.value=(e%f.value+f.value)%f.value}function L(){$(_.value+1)}function T(){$(_.value-1)}function z(e){var t,a;f.value<2||(r.value=!0,g=e.clientX,p.value=0,h=e.pointerId,(a=(t=e.currentTarget).setPointerCapture)==null||a.call(t,e.pointerId))}function x(e){var a;if(!r.value||e.pointerId!==h)return;const t=((a=l.value)==null?void 0:a.clientWidth)||1;p.value=(e.clientX-g)/t*100}function E(e){if(!r.value)return;const t=e.clientX-g;r.value=!1,p.value=0,h=null,t>Q?T():t<-Q&&L()}function R(e,t){if(!(Math.abs(p.value)>1)){if(e!==_.value){$(e);return}k("open",t)}}function O(e){if(!(Math.abs(p.value)>1)){if(e!==_.value){$(e);return}k("all")}}return(e,t)=>(n(),o("section",We,[u("div",{class:"reel__stage",ref_key:"stage",ref:l,onPointerdown:z,onPointermove:x,onPointerup:E,onPointercancel:E},[(n(!0),o(B,null,U(c.value,(a,s)=>(n(),o("div",{key:a.key,class:G(["reel__cell",{"is-active":s===_.value}]),style:M(I(s))},[a.kind==="product"?(n(),V(ae,{key:0,value:a.product,onOpen:i=>R(s,i)},null,8,["value","onOpen"])):(n(),o("button",{key:1,type:"button",class:"reel__all",onClick:i=>O(s)},[u("span",Ke,[H(j,{icon:"vuesax-linear:arrow-left-1",size:"26"})]),t[0]||(t[0]=u("span",{class:"reel__allText"},"مشاهده همه محصولات جدید",-1))],8,Ye))],6))),128))],544)]))}}),et=F(Je,[["__scopeId","data-v-1df7c763"]]),tt="/assets/shipping-and-delivery-CyUGL93q.png",st="/assets/sports-and-competition-ao926_SX.png",ne="/assets/brand-logo-Q_YZU76j.png",at=[{type:"popup",src:tt,text:"ارسال سریع و مطمئن سفارش‌های شما به سراسر کشور.",link:void 0},{type:"popup",src:st,text:`جدیدترین محصولات ${q.name} را در بخش محصولات جدید ببینید.`,link:void 0},{type:"popup",src:ne,text:`${q.name}، همراه شما در خرید و فروش طلا.`,link:void 0}],nt=ue("config",{state:()=>({config:{main_slider:at},cats:[],loaded:!1}),actions:{setCats(d){this.cats=d},async init(d=!1){try{const{categories:m}=await se.getCatalogFacets();this.cats=m.map(v=>({...v,icon:{image:ne}})),this.loaded=!0}catch(m){console.log(m)}}}}),ot={class:"home"},lt={class:"home__bar"},it={class:"home__barInner"},ct=["alt"],rt={class:"home__list"},ut={key:3,class:"home__empty"},dt=70,J=6,ee=4,_t=N({__name:"HomeView",setup(d){let m=!1;const v=me(),k=nt(),_=de(),l=$e(),r=_e(),p=y(!l.loaded),g=y(!1),h=S(()=>l.products),c=y(r.peek(W.goldPrice)??null),f=y(r.peek(W.homeSlider)??null),I=y(m);function $(s){return{"--reveal-delay":`${s*dt}ms`}}const L=S(()=>h.value),T=S(()=>h.value.slice(0,J)),z=S(()=>h.value.slice(0,ee)),x=S(()=>(f.value??[]).filter(s=>s.image).map((s,i)=>({key:`${i}-${s.image}`,image:s.image})));function E(s){he(s)}function R(s){_.query.cats=[s.id],v.push({name:"search"})}function O(){v.push({name:"newestProduct"})}async function e(s=!1){const[i,P,b,A]=await Promise.allSettled([(async()=>{s&&l.invalidate();const X=await se.listProductsPaged({page:1,limit:Math.max(J,ee),sort:"newest"});l.replace(X.rows)})(),k.init(s),r.goldPrice({force:s}),r.homeSlider({force:s})]);i.status==="rejected"&&console.log(i.reason),P.status==="rejected"&&console.log(P.reason),c.value=b.status==="fulfilled"?b.value:null,f.value=A.status==="fulfilled"?A.value:null}async function t(){try{await e(!0)}finally{g.value=!1}}te(async()=>{await e(),p.value=!1,!I.value&&(await ve(),requestAnimationFrame(()=>{I.value=!0,m=!0}))});let a=!1;return pe(async()=>{if(!a){a=!0;return}try{c.value=await r.goldPrice({force:!0})}catch(s){console.log(s)}}),(s,i)=>{const P=ge("container");return n(),o("div",ot,[u("header",lt,[u("div",it,[u("img",{src:fe,alt:C(q).name,class:"home__logo"},null,8,ct),H(ke,{quote:c.value,compact:"",class:"home__rate"},null,8,["quote"])])]),H(ye,{modelValue:g.value,"onUpdate:modelValue":i[0]||(i[0]=b=>g.value=b),onRefresh:t},{default:Y(()=>[H(P,{class:G(["home__body",{"is-revealed":I.value}])},{default:Y(()=>[x.value.length?(n(),V(Ae,{key:0,slides:x.value,class:"home__hero home__reveal",style:M($(0))},null,8,["slides","style"])):w("",!0),C(k).cats.length?(n(),o("section",{key:1,class:"home__section home__reveal",style:M($(1))},[i[1]||(i[1]=u("h2",{class:"home__heading"},"دسته بندی ها",-1)),H(De,{categories:C(k).cats,"active-id":null,onSelect:R},null,8,["categories"])],4)):w("",!0),L.value.length?(n(),o("section",{key:2,class:"home__section home__reveal",style:M($(2))},[i[2]||(i[2]=u("h2",{class:"home__heading"},"محصولات جدید",-1)),H(et,{products:T.value,onOpen:E,onAll:O},null,8,["products"]),u("div",rt,[(n(!0),o(B,null,U(z.value,(b,A)=>(n(),V(ae,{key:b.id,value:b,class:"home__reveal",style:M($(3+A)),onOpen:E},null,8,["value","style"]))),128))])],4)):w("",!0),!p.value&&!h.value.length?(n(),o("section",ut,[H(j,{icon:"vuesax-linear:box",size:"26"}),i[3]||(i[3]=u("p",null,"هنوز محصولی در مجموعه ثبت نشده است.",-1))])):w("",!0)]),_:1},8,["class"])]),_:1},8,["modelValue"])])}}}),ht=F(_t,[["__scopeId","data-v-eca364db"]]);export{ht as default};