Files
tehran_taj/apps/user-app-v2/dist/assets/DashboardView-D-MaoniL.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
8.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{d as U,S as O,y as q,h as m,K as N,A as G,o as H,z as K,c as u,p as t,C,m as i,s as k,T,D as Y,O as j,v as I,b as _,I as o,f as R,n as b,e as s,t as p,R as J,g as P,B as Q,F as W,i as z,E as X,_ as Z}from"./index-BIZGiNHX.js";import{A as ss}from"./AppPullRefresh-BHaN1AoQ.js";import{P as es}from"./PageBar-Zk5iCdG_.js";import{R as as}from"./RateStrip-DO3b69bq.js";import{p as ts}from"./filters-CVq8c4MW.js";const os={class:"dash"},ns={key:1,class:"dash__exitSpacer","aria-hidden":"true"},is={class:"dash__heroHead"},rs={class:"dash__heroIdentity"},ls={class:"dash__heroName"},ds={class:"dash__heroMobile"},us={class:"dash__heroBalance"},_s={class:"dash__heroFigure"},hs={class:"dash__heroNum"},cs={class:"dash__heroDebt"},ps={class:"dash__heroHead"},vs={class:"dash__heroIdentity"},fs={class:"dash__heroMobile"},ms={class:"dash__heroPending"},bs=["alt"],ws={class:"dash__rowIcon","aria-hidden":"true"},gs={class:"dash__rowChevron","aria-hidden":"true"},ys={class:"dash__rowIcon","aria-hidden":"true"},xs={class:"dash__rowChevron","aria-hidden":"true"},Cs={class:"dash__rowIcon","aria-hidden":"true"},ks={class:"dash__rowChevron","aria-hidden":"true"},Is={class:"dash__rowIcon","aria-hidden":"true"},zs={class:"dash__rowChevron","aria-hidden":"true"},Ss={class:"dash__rowIcon","aria-hidden":"true"},Ls={class:"dash__rowChevron","aria-hidden":"true"},Ds={class:"dash__rowIcon","aria-hidden":"true"},$s={class:"dash__rowChevron","aria-hidden":"true"},Es={class:"dash__rowIcon","aria-hidden":"true"},Ns={class:"dash__rowChevron","aria-hidden":"true"},Ts={class:"dash__rowIcon","aria-hidden":"true"},Rs={class:"dash__rowChevron","aria-hidden":"true"},Ps=70,Vs=U({__name:"DashboardView",setup(Fs){const l=Y(),r=O(),w=q(),d=m(w.peek(N.profile)??null),S=m(w.peek(N.goldPrice)??null),y=m(!1),v=m(!1),L=z(()=>d.value?parseFloat(d.value.goldDebtGrams)>0:!1),V=z(()=>d.value?Math.abs(parseFloat(d.value.goldDebtGrams)):0),F=z(()=>{const a=V.value;return Number.isFinite(a)?a.toLocaleString("fa-IR",{maximumFractionDigits:3}):"۰"}),h=j({notify:!1,loginNotify:!1});function c(a){if(!r.isLoggedIn){h.loginNotify=!0;return}a===0&&l.push({name:"ordersList"}),a===1&&l.push({name:"transactionsList"}),a===2&&l.push({name:"profileData"}),a===3&&l.push({name:"favoritesList"}),a===4&&l.push({name:"ChildOrder"}),a===5&&l.push({name:"customerChoice"}),a===6&&l.push({name:"report"})}async function A(){h.notify=!1;try{await I.endSharedSession()}catch{}let a=null;try{a=(await I.ssoLogoutUrl()).logout_url}catch{a=null}if(r.logout(),sessionStorage.removeItem("gb_iam_sso_checked"),a){window.location.assign(a);return}l.push({name:"home"})}async function g(){v.value=!1;const[a,e]=await Promise.allSettled([r.isLoggedIn?w.me({force:!0}):Promise.resolve(null),w.goldPrice({force:!0})]);a.status==="fulfilled"?(d.value=a.value,v.value=!1):(v.value=r.isLoggedIn&&!d.value,console.log(a.reason)),S.value=e.status==="fulfilled"?e.value:null}async function B(){try{await g()}finally{y.value=!1}}async function D(){if(r.isLoggedIn)try{const a=await I.getExpertIdentity();r.setSalesExpert(a.isSalesExpert)}catch{}}let $=!1;G(()=>{$&&(g(),D()),$=!0});let E=!1;const x=m(E);function f(a){return{"--reveal-delay":`${a*Ps}ms`}}return H(async()=>{D(),await g(),!x.value&&(await K(),requestAnimationFrame(()=>{x.value=!0,E=!0}))}),(a,e)=>{const M=X("container");return _(),u("div",os,[t(es,{title:"میز کار",back:!1},{trailing:C(()=>[i(r).isLoggedIn?(_(),u("button",{key:0,type:"button",class:"dash__exit","aria-label":"خروج",onClick:e[0]||(e[0]=n=>h.notify=!0)},[t(o,{icon:"vuesax-linear:logout",size:"18"})])):(_(),u("span",ns))]),_:1}),t(ss,{modelValue:y.value,"onUpdate:modelValue":e[10]||(e[10]=n=>y.value=n),onRefresh:B},{default:C(()=>[t(M,{class:R(["dash__body",{"is-revealed":x.value}])},{default:C(()=>[i(r).isLoggedIn&&d.value?(_(),u("section",{key:0,class:"dash__hero dash__reveal",style:b(f(0))},[s("header",is,[s("div",rs,[s("span",ls,p(d.value.fullName),1),s("span",ds,p(i(r).mobile),1)]),s("span",{class:R(["dash__heroSeal",L.value?"is-debtor":"is-creditor"])},p(L.value?"بدهکار":"بستانکار"),3)]),s("div",us,[s("div",_s,[s("span",hs,p(F.value),1),e[14]||(e[14]=s("span",{class:"dash__heroUnit"},"گرم",-1))]),e[15]||(e[15]=s("span",{class:"dash__heroEyebrow"},"موجودی طلا",-1))]),s("div",cs,[e[17]||(e[17]=s("span",{class:"dash__heroDebtLabel"},"بدهی ریالی",-1)),s("b",null,[J(p(i(ts)(d.value.fiatDebtRial))+" ",1),e[16]||(e[16]=s("i",null,"ریال",-1))])])],4)):i(r).isLoggedIn?(_(),u("section",{key:1,class:"dash__hero dash__hero--pending dash__reveal",style:b(f(0))},[s("header",ps,[s("div",vs,[e[18]||(e[18]=s("span",{class:"dash__heroName"},"حساب شما",-1)),s("span",fs,p(i(r).mobile),1)])]),s("p",ms,p(v.value?"موجودی الان در دسترس نیست. دوباره تلاش کنید.":"در حال دریافت موجودی…"),1),v.value?(_(),u("button",{key:0,type:"button",class:"dash__heroRetry",onClick:g}," تلاش دوباره ")):P("",!0)],4)):(_(),u("section",{key:2,class:"dash__hero dash__invite dash__reveal",style:b(f(0))},[s("img",{class:"dash__inviteLogo",src:Q,alt:i(k).name},null,8,bs),s("button",{type:"button",class:"dash__inviteCta",onClick:e[1]||(e[1]=n=>i(l).push({name:"login"}))}," ورود / ثبت‌نام ")],4)),s("section",{class:"dash__rows dash__reveal",style:b(f(1))},[s("button",{type:"button",class:"dash__row",onClick:e[2]||(e[2]=n=>c(0))},[s("span",ws,[t(o,{icon:"vuesax-linear:box",size:"18"})]),e[19]||(e[19]=s("span",{class:"dash__rowText"},[s("b",null,"سفارشات")],-1)),s("span",gs,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[3]||(e[3]=n=>c(1))},[s("span",ys,[t(o,{icon:"vuesax-linear:receipt-text",size:"18"})]),e[20]||(e[20]=s("span",{class:"dash__rowText"},[s("b",null,"اسناد")],-1)),s("span",xs,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[4]||(e[4]=n=>c(2))},[s("span",Cs,[t(o,{icon:"vuesax-linear:user",size:"18"})]),e[21]||(e[21]=s("span",{class:"dash__rowText"},[s("b",null,"پروفایل")],-1)),s("span",ks,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[5]||(e[5]=n=>c(3))},[s("span",Is,[t(o,{icon:"vuesax-linear:heart",size:"18"})]),e[22]||(e[22]=s("span",{class:"dash__rowText"},[s("b",null,"علاقمندی")],-1)),s("span",zs,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[6]||(e[6]=n=>c(6))},[s("span",Ss,[t(o,{icon:"vuesax-linear:chart-2",size:"18"})]),e[23]||(e[23]=s("span",{class:"dash__rowText"},[s("b",null,"گزارش")],-1)),s("span",Ls,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[7]||(e[7]=n=>i(l).push({name:"appearanceSettings"}))},[s("span",Ds,[t(o,{icon:"vuesax-linear:brush",size:"18"})]),e[24]||(e[24]=s("span",{class:"dash__rowText"},[s("b",null,"تنظیمات ظاهری")],-1)),s("span",$s,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),i(r).isSalesExpert?(_(),u(W,{key:0},[s("button",{type:"button",class:"dash__row",onClick:e[8]||(e[8]=n=>c(4))},[s("span",Es,[t(o,{icon:"vuesax-linear:box-tick",size:"18"})]),e[25]||(e[25]=s("span",{class:"dash__rowText"},[s("b",null,"سفارش مشتریان")],-1)),s("span",Ns,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])]),s("button",{type:"button",class:"dash__row",onClick:e[9]||(e[9]=n=>c(5))},[s("span",Ts,[t(o,{icon:"vuesax-linear:profile-2user",size:"18"})]),e[26]||(e[26]=s("span",{class:"dash__rowText"},[s("b",null,"مشتریان من")],-1)),s("span",Rs,[t(o,{icon:"vuesax-linear:arrow-left-1",size:"16"})])])],64)):P("",!0)],4),t(as,{quote:S.value,class:"dash__rate dash__reveal",style:b(f(2))},null,8,["quote","style"])]),_:1},8,["class"])]),_:1},8,["modelValue"]),t(T,{show:h.notify,"onUpdate:show":e[11]||(e[11]=n=>h.notify=n),art:"logout",title:"آیا می خواهید از برنامه خارج شوید؟",description:`برای استفاده دوباره از امکانات ${i(k).name}، باید دوباره وارد حساب کاربری خود شوید.`,"confirm-text":"بله","cancel-text":"بی خیال",onConfirm:A},null,8,["show","description"]),t(T,{show:h.loginNotify,"onUpdate:show":e[12]||(e[12]=n=>h.loginNotify=n),art:"login",title:"ابتدا وارد حساب کاربری شوید",description:`برای دسترسی به تمامی امکانات نرم افزار ${i(k).name}، گزینه ورود/ثبت نام را لمس کنید و در صورت نداشتن حساب کاربری، ثبت نام نمایید.`,"confirm-text":"ورود/ثبت نام","cancel-text":"بیخیال",onConfirm:e[13]||(e[13]=n=>i(l).push({name:"login"}))},null,8,["show","description"])])}}}),qs=Z(Vs,[["__scopeId","data-v-bbab2eac"]]);export{qs as default};