1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
import{$ as e,A as t,D as n,F as r,I as i,J as a,K as o,L as s,M as c,N as l,R as u,St as d,T as ee,Tt as f,X as p,_ as m,j as h,k as g,n as _,pt as v,t as y,wt as b,xt as x}from"./BasicIcon-B6lR-mG3.js";import{n as S,o as C,r as w,u as T}from"./format-BHJptHdF.js";import{C as E,S as D,b as O,c as k,g as A,h as j,o as te,r as ne,s as M,u as N,w as P}from"./index-DNdnTjwr.js";import{r as F,t as I}from"./constants-DXXK14Zz.js";import{t as L}from"./IconPhone-Glpo76KE.js";import{t as R}from"./IconEditPen-CppsBLM9.js";import{t as z}from"./IconBuilding-oclvcvlP.js";import{t as B}from"./IconVerified-BSlZDcZt.js";import{t as V}from"./IconLayoutGrid-DgOvzvMf.js";import{t as H}from"./PageSkeleton-BImjuI6S.js";import{n as U,t as W}from"./crm-DbcoqKAF.js";import{n as G,t as K}from"./IconBolt-BuLG6uFR.js";import{t as q}from"./IconCash-Bxyfv_aw.js";import{t as J}from"./IconCashSettlement-DizzShjh.js";import{t as Y}from"./IconMail-BWRmFd4j.js";var X=u({__name:`IconSettings`,props:{size:{default:24},strokeWidth:{default:1.5},color:{default:null}},setup(e){return(t,n)=>(a(),h(y,{icon:`vuesax-linear:setting-2`,size:e.size,"stroke-width":e.strokeWidth,color:e.color},null,8,[`size`,`stroke-width`,`color`]))}}),Z={class:`page profile-page`},Q={class:`page__scroll page__scroll--with-nav profile-scroll`},re={class:`hero`},ie={class:`hero__pin`},ae={class:`hero__top`},oe=[`aria-label`],se={class:`hero__meta`},ce={class:`level-pill`},le={class:`profile-sheet`},ue={class:`panel`},de={class:`panel__head`},fe={class:`panel__period`},pe={class:`stats`},me={class:`stat-card`},he={class:`stat-card__text`},ge={class:`stat-card__value`},_e={class:`stat-card__icon stat-card__icon--orders`},ve={class:`stat-card`},ye={class:`stat-card__text`},be={class:`stat-card__value`},xe={class:`stat-card__icon stat-card__icon--customers`},Se={class:`stat-card`},Ce={class:`stat-card__text`},we={class:`stat-card__value`},Te={class:`stat-card__icon stat-card__icon--profit`},Ee={class:`stat-card`},De={class:`stat-card__text`},Oe={class:`stat-card__value`},ke={class:`stat-card__icon stat-card__icon--sales`},Ae={class:`loyalty`},je={class:`loyalty__row`},Me={class:`loyalty__text`},Ne={class:`loyalty__bar`},Pe={class:`quick-grid`},Fe=[`onClick`],Ie={class:`quick-item__icon`},Le={class:`orders-box`},Re={class:`section-head`},ze=[`onClick`,`onKeydown`],Be={class:`order-row__meta`},Ve={class:`order-row__date`},He={class:`order-row__title`},Ue={key:0,class:`order-row__customer`},We={class:`price-section`},Ge={class:`price-card`},Ke={class:`price-card__body`},qe={class:`price-card__info`},Je=_(u({__name:`MobileProfilePage`,setup(e){let u={id:`sample-base-price`,name:`پارچه فاستونی ایتالیایی`,code:`DF-1204`,categoryId:``,season:`all_season`,widthCm:160,composition:``,colors:[`1`,`2`,`3`,`4`,`5`,`6`],tags:[],isNew:!1,rollMeters:0,basePrice:38e4},_=m(),S=k(),T=A(),E=W(),D=N(),O=v(null),j=v(u),L=v(!1),R=[{label:`ثبت مشتری جدید`,to:`/customers`,icon:`vuesax-linear:add`},{label:`سفارشها`,to:`/orders`,icon:`vuesax-linear:document-text`},{label:`مشتریان من`,to:`/customers`,icon:`vuesax-linear:people`},{label:`گزارشها`,to:`/reminders`,icon:`vuesax-linear:chart-2`},{label:`درخواست کالیته`,to:`/catalog-request`,icon:`vuesax-linear:category`},{label:`قیمتگذاری`,to:`/categories`,icon:`vuesax-linear:money-4`}],z=g(()=>[...T.orders].sort((e,t)=>String(t.createdAt).localeCompare(String(e.createdAt))).slice(0,3).map(e=>{let t=F[e.status]??`info`,n=t===`danger`||t===`neutral`?`danger`:t===`success`?`success`:t===`warning`?`warning`:`info`;return{id:e.id,title:`سفارش #${e.orderNumber}`,date:e.createdAt?w(e.createdAt):``,customer:e.companyName||``,statusLabel:I[e.status]||e.status,statusTone:n}})),B=g(()=>S.fullName||`کاربر`),V=g(()=>O.value?.code||S.user?.agentCode||`—`),G=g(()=>O.value?.levelLabel||S.user?.levelLabel||`برنزی`),K=g(()=>O.value?.nextLevelLabel||S.user?.nextLevelLabel||`نقرهای`),q=g(()=>O.value?.pointsToNext??S.user?.pointsToNext??0),J=g(()=>O.value?.periodLabel||`۳۰ روز اخیر`),Y=g(()=>O.value?.customersCount??0),Je=g(()=>O.value?.ordersCount??T.orders.length),Ye=g(()=>O.value?.salesVolumeToman??0),$=g(()=>O.value?.profitToman??0),Xe=g(()=>O.value?.levelProgress??S.user?.levelProgress??72),Ze=g(()=>D.unreadCount>9?`9+`:String(D.unreadCount)),Qe=g(()=>j.value.basePrice??u.basePrice??0);return o(async()=>{L.value=!0;try{D.hydrate();try{O.value=await U()}catch{O.value=null}try{let e=(await E.loadBrowseProducts())[0];j.value=e?{...u,...e,basePrice:e.basePrice??u.basePrice}:u}catch{j.value=u}T.orders.length||await T.hydrate()}finally{L.value=!1}}),(e,o)=>(a(),l(`div`,Z,[t(`div`,Q,[t(`header`,re,[t(`div`,ie,[t(`div`,ae,[t(`button`,{type:`button`,class:`icon-btn`,"aria-label":`تنظیمات`,onClick:o[0]||=e=>x(_).push(`/profile/display`)},[s(X,{size:20,color:`#ffffff`})]),o[4]||=t(`h1`,null,`پروفایل من`,-1),t(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اعلانها`,onClick:o[1]||=e=>x(_).push(`/profile/notifications`)},[s(M,{size:20,color:`#ffffff`}),x(D).hasUnread?(a(),l(`span`,{key:0,class:`icon-btn__badge`,"aria-label":`${x(D).unreadCount} اعلان خواندهنشده`},f(Ze.value),9,oe)):c(``,!0)])]),s(ne,{class:`hero__avatar`,src:x(S).user?.avatarUrl,initials:B.value.charAt(0),size:84},null,8,[`src`,`initials`])]),t(`div`,se,[t(`h2`,null,f(B.value),1),t(`p`,null,`کد واسطه: `+f(V.value),1),t(`span`,ce,[o[5]||=t(`svg`,{class:`level-pill__crown`,viewBox:`0 0 24 24`,"aria-hidden":`true`},[t(`path`,{fill:`currentColor`,d:`M3.5 17.5h17l-1.2-8.2a1 1 0 0 0-1.5-.7L14 11l-2.5-5.2a1 1 0 0 0-1.8 0L7.2 11 4.2 8.6a1 1 0 0 0-1.5.7L3.5 17.5Zm1.7 1.5h13.6v1.2H5.2V19Z`})],-1),i(` سطح: `+f(G.value),1)])])]),t(`div`,le,[L.value?(a(),h(H,{key:0,variant:`profile`})):(a(),l(n,{key:1},[t(`section`,ue,[t(`div`,de,[o[6]||=t(`h3`,null,`خلاصه عملکرد`,-1),t(`span`,fe,[i(f(J.value)+` `,1),s(y,{icon:`vuesax-linear:arrow-down`,size:14,"stroke-width":1.5})])]),t(`div`,pe,[t(`div`,me,[t(`div`,he,[o[7]||=t(`span`,{class:`stat-card__label`},`سفارشها`,-1),t(`strong`,ge,f(x(C)(Je.value)),1),o[8]||=t(`em`,{class:`stat-card__hint`},`سفارش`,-1)]),t(`span`,_e,[s(P,{size:18})])]),t(`div`,ve,[t(`div`,ye,[o[9]||=t(`span`,{class:`stat-card__label`},`مشتریان من`,-1),t(`strong`,be,f(x(C)(Y.value)),1),o[10]||=t(`em`,{class:`stat-card__hint`},`مشتری فعال`,-1)]),t(`span`,xe,[s(y,{icon:`vuesax-linear:people`,size:18,"stroke-width":1.5})])]),t(`div`,Se,[t(`div`,Ce,[o[11]||=t(`span`,{class:`stat-card__label`},`سود شما (ریال)`,-1),t(`strong`,we,f(x(C)($.value)),1),o[12]||=t(`em`,{class:`stat-card__hint`},`تومان`,-1)]),t(`span`,Te,[s(y,{icon:`vuesax-linear:chart-2`,size:18,"stroke-width":1.5})])]),t(`div`,Ee,[t(`div`,De,[o[13]||=t(`span`,{class:`stat-card__label`},`حجم فروش (ریال)`,-1),t(`strong`,Oe,f(x(C)(Ye.value)),1),o[14]||=t(`em`,{class:`stat-card__hint`},`تومان`,-1)]),t(`span`,ke,[s(y,{icon:`vuesax-linear:wallet`,size:18,"stroke-width":1.5})])])])]),t(`section`,Ae,[t(`div`,je,[o[15]||=r(`<div class="loyalty__crown" aria-hidden="true" data-v-947f93d3><svg viewBox="0 0 48 48" width="40" height="40" data-v-947f93d3><path fill="#E0C35A" d="M8 34h32l-2.4-16.2a2 2 0 0 0-3-.1L28 24l-4.8-10a2 2 0 0 0-3.6 0L14.8 24 9.4 17.7a2 2 0 0 0-3.1.1L8 34Z" data-v-947f93d3></path><path fill="#C9A227" d="M10 36h28v3H10z" data-v-947f93d3></path><circle cx="24" cy="28" r="3" fill="#F7E7A1" data-v-947f93d3></circle></svg></div>`,1),t(`p`,Me,` شما در سطح `+f(G.value)+` قرار دارید. تا سطح `+f(K.value)+` فقط `+f(x(C)(q.value))+` تومان فروش دیگر نیاز دارید. `,1)]),t(`div`,Ne,[t(`span`,{style:b({width:`${Math.min(100,Math.max(0,Xe.value))}%`})},null,4)])]),t(`section`,null,[o[16]||=t(`h3`,{class:`section-title`},`دسترسی سریع`,-1),t(`div`,Pe,[(a(),l(n,null,p(R,e=>t(`button`,{key:e.label,type:`button`,class:`quick-item`,onClick:t=>x(_).push(e.to)},[t(`span`,Ie,[s(y,{icon:e.icon,size:22,"stroke-width":1.5},null,8,[`icon`])]),i(` `+f(e.label),1)],8,Fe)),64))])]),t(`section`,Le,[t(`div`,Re,[o[17]||=t(`h3`,null,`آخرین سفارشها`,-1),t(`button`,{type:`button`,class:`link`,onClick:o[2]||=e=>x(_).push(`/orders`)},`مشاهده همه`)]),(a(!0),l(n,null,p(z.value,e=>(a(),l(`article`,{key:e.id,class:`order-row`,role:`button`,tabindex:`0`,onClick:t=>x(_).push({path:`/order`,query:{id:e.id}}),onKeydown:ee(t=>x(_).push({path:`/order`,query:{id:e.id}}),[`enter`])},[t(`div`,Be,[t(`span`,Ve,f(e.date),1),t(`strong`,He,f(e.title),1),e.customer?(a(),l(`p`,Ue,`مشتری: `+f(e.customer),1)):c(``,!0)]),t(`span`,{class:d([`tone`,`tone--${e.statusTone}`])},f(e.statusLabel),3),s(te,{size:16,class:`order-row__chevron`})],40,ze))),128)),t(`button`,{type:`button`,class:`orders-all`,onClick:o[3]||=e=>x(_).push(`/orders`)},` مشاهده همه سفارشها `)]),t(`section`,We,[o[18]||=t(`h3`,{class:`section-title`},`قیمتهای پایه (نمونه)`,-1),t(`div`,Ge,[t(`div`,Ke,[t(`div`,qe,[t(`strong`,null,f(j.value.name),1),t(`p`,null,`کد: `+f(j.value.code),1),t(`p`,null,`عرض: `+f(x(C)(j.value.widthCm))+` سانتیمتر`,1),t(`p`,null,`رنگها: `+f(x(C)(j.value.colors.length))+` رنگ`,1)]),t(`div`,{class:`price-card__image`,style:b(j.value.imageUrl?{backgroundImage:`url(${j.value.imageUrl})`}:void 0)},null,4)]),t(`footer`,null,`قیمت پایه به شما: `+f(x(C)(Qe.value))+` تومان / متر`,1)])])],64))])])]))}}),[[`__scopeId`,`data-v-947f93d3`]]),Ye=u({__name:`IconMapPin`,props:{size:{default:24},strokeWidth:{default:1.5},color:{default:null}},setup(e){return(t,n)=>(a(),h(y,{icon:`vuesax-linear:location`,size:e.size,"stroke-width":e.strokeWidth,color:e.color},null,8,[`size`,`stroke-width`,`color`]))}}),$=u({__name:`IconLock`,props:{size:{default:24},strokeWidth:{default:1.5},color:{default:null}},setup(e){return(t,n)=>(a(),h(y,{icon:`vuesax-linear:lock`,size:e.size,"stroke-width":e.strokeWidth,color:e.color},null,8,[`size`,`stroke-width`,`color`]))}}),Xe={class:`desktop-page desktop-profile`},Ze={class:`profile-overview`},Qe={class:`profile-overview__identity`},$e={class:`profile-overview__aside`},et={class:`profile-overview__details`},tt={class:`profile-overview__name-row`},nt={class:`profile-overview__name`},rt={class:`profile-overview__verified`,title:`حساب تأیید شده`},it={class:`profile-overview__meta`},at={class:`profile-overview__meta-label`},ot={class:`profile-overview__meta`},st={dir:`ltr`},ct={class:`profile-overview__meta`},lt={dir:`ltr`},ut={class:`profile-overview__stats`},dt={class:`profile-stat`},ft={class:`profile-stat__icon profile-stat__icon--amber`},pt={class:`profile-stat__value profile-stat__value--sm`},mt={class:`profile-stat`},ht={class:`profile-stat__icon profile-stat__icon--green`},gt={class:`profile-stat__value`},_t={class:`profile-stat`},vt={class:`profile-stat__icon profile-stat__icon--blue`},yt={class:`profile-stat__value`},bt={class:`desktop-profile__grid`},xt={class:`profile-panel profile-panel--settings`},St={class:`profile-panel__title`},Ct={class:`profile-settings`,"aria-label":`تنظیمات حساب`},wt=[`onClick`],Tt={class:`profile-settings__icon`},Et={class:`profile-settings__body`},Dt={class:`profile-settings__label`},Ot={class:`profile-settings__desc`},kt={class:`profile-panel profile-panel--quick`},At={class:`profile-panel__title`},jt={class:`profile-quick-grid`},Mt=[`onClick`],Nt={class:`profile-quick-grid__icon`},Pt={class:`profile-quick-grid__label`},Ft={class:`profile-panel profile-panel--company`},It={class:`profile-panel__title`},Lt={class:`profile-info-list`},Rt={key:0,class:`profile-badge`},zt=_(u({__name:`DesktopProfilePage`,emits:[`logout`],setup(r,{emit:o}){let c=m(),u=k(),d=A(),ee=o,_=g(()=>`${u.user?.firstName?.[0]??``}${u.user?.lastName?.[0]??``}`||`؟`),v=g(()=>u.user?.id?d.userOrders(u.user.id).length:0),y=g(()=>u.user?.id?d.userOrders(u.user.id).reduce((e,t)=>e+(t.checks?.length??0),0)+d.draftChecks.length:0),b=g(()=>{let e=u.user;return e?u.isAgent&&e.agentCode?T(e.agentCode):e.nationalId?T(e.nationalId.slice(-6).padStart(6,`0`)):T(e.id?.slice(-6)??`—`):T(`—`)}),N=g(()=>u.isAgent?`کد واسطه:`:`کد مشتری:`),P=g(()=>{let e=u.user?.phone??``;return e?`user${e.slice(-4)}@parsbaft.ir`:`—`}),F=g(()=>u.user?.createdAt?w(u.user.createdAt):`—`),I=g(()=>0),H=g(()=>[{label:`نام شرکت`,value:u.fullName||`—`},{label:`شناسه ملی`,value:u.user?.nationalId?T(u.user.nationalId):`—`},{label:`کد اقتصادی`,value:u.user?.nationalId?T(`4${u.user.nationalId.slice(0,10)}`):`—`},{label:`تاریخ عضویت`,value:F.value},{label:`نوع مشتری`,value:u.isAgent?`واسطه`:`مشتری عمده`,badge:!0},{label:`وضعیت حساب`,value:`فعال`,badge:!0}]),U=[{label:`حسابهای بانکی`,icon:J},{label:`آدرسها`,icon:Ye},{label:`حمایت و پشتیبانی`,icon:j,href:`tel:02112345678`},{label:`فاکتورهای من`,icon:E,path:`/orders`}],W=[{id:`profile`,label:`اطلاعات کاربری`,description:`ویرایش نام، موبایل و ایمیل`,icon:D,path:`/profile/edit`},{id:`security`,label:`امنیت حساب`,description:`تغییر رمز عبور و تنظیمات ورود`,icon:$,path:`/profile/security`},{id:`notifications`,label:`اعلانها`,description:`خبرهای فاکتور، چک و ارسال سفارش`,icon:M,path:`/profile/notifications`},{id:`display`,label:`تنظیمات`,description:`نمایش، اطلاعات کاربری و خروج`,icon:V,path:`/profile/display`},{id:`logout`,label:`خروج از حساب`,description:`پایان نشست و ورود مجدد`,icon:$,action:`logout`}];function Z(e){e.path?c.push(e.path):e.href&&(window.location.href=e.href)}function Q(e){if(e.action===`logout`){ee(`logout`);return}e.path&&c.push(e.path)}return(r,o)=>(a(),l(`div`,Xe,[o[11]||=t(`header`,{class:`desktop-profile__head`},[t(`h1`,{class:`desktop-profile__title`},`پروفایل`),t(`p`,{class:`desktop-profile__subtitle`},`مدیریت اطلاعات حساب کاربری و تنظیمات`)],-1),t(`section`,Ze,[t(`div`,Qe,[t(`div`,$e,[s(ne,{class:`profile-overview__avatar`,src:x(u).user?.avatarUrl,initials:_.value,size:92},null,8,[`src`,`initials`]),t(`button`,{type:`button`,class:`profile-overview__edit`,onClick:o[0]||=e=>x(c).push(`/profile/edit`)},[s(R,{size:16}),o[3]||=i(` ویرایش اطلاعات `,-1)])]),t(`div`,et,[t(`div`,tt,[t(`h2`,nt,f(x(u).fullName),1),t(`span`,rt,[s(B,{size:18})])]),t(`p`,it,[s(G,{size:15,class:`profile-overview__meta-icon`}),t(`span`,at,f(N.value),1),t(`span`,null,f(b.value),1)]),t(`p`,ot,[s(L,{size:15,class:`profile-overview__meta-icon`}),t(`span`,st,f(x(u).user?.phone),1)]),t(`p`,ct,[s(Y,{size:15,class:`profile-overview__meta-icon`}),t(`span`,lt,f(P.value),1)])])]),t(`div`,ut,[t(`article`,dt,[t(`span`,ft,[s(q,{size:20})]),t(`strong`,pt,f(x(S)(I.value)),1),o[4]||=t(`span`,{class:`profile-stat__label`},`موجودی اعتبار`,-1),o[5]||=t(`button`,{type:`button`,class:`profile-stat__link`},`مشاهده جزئیات`,-1)]),t(`article`,mt,[t(`span`,ht,[s(O,{size:20})]),t(`strong`,gt,f(x(C)(y.value)),1),o[6]||=t(`span`,{class:`profile-stat__label`},`چک فعال`,-1),t(`button`,{type:`button`,class:`profile-stat__link`,onClick:o[1]||=e=>x(c).push(`/profile/checks`)},` مشاهده همه `)]),t(`article`,_t,[t(`span`,vt,[s(E,{size:20})]),t(`strong`,yt,f(x(C)(v.value)),1),o[7]||=t(`span`,{class:`profile-stat__label`},`سفارش ثبتشده`,-1),t(`button`,{type:`button`,class:`profile-stat__link`,onClick:o[2]||=e=>x(c).push(`/orders`)},` مشاهده همه `)])])]),t(`div`,bt,[t(`section`,xt,[t(`h3`,St,[s(X,{size:18}),o[8]||=i(` تنظیمات حساب `,-1)]),t(`nav`,Ct,[(a(),l(n,null,p(W,n=>t(`button`,{key:n.id,type:`button`,class:`profile-settings__item`,onClick:e=>Q(n)},[t(`span`,Tt,[(a(),h(e(n.icon),{size:20}))]),t(`span`,Et,[t(`strong`,Dt,f(n.label),1),t(`span`,Ot,f(n.description),1)]),s(te,{size:16,class:`profile-settings__chevron`,"aria-hidden":`true`})],8,wt)),64))])]),t(`section`,kt,[t(`h3`,At,[s(K,{size:18}),o[9]||=i(` دسترسی سریع `,-1)]),t(`div`,jt,[(a(),l(n,null,p(U,n=>t(`button`,{key:n.label,type:`button`,class:`profile-quick-grid__item`,onClick:e=>Z(n)},[t(`span`,Nt,[(a(),h(e(n.icon),{size:22}))]),t(`span`,Pt,f(n.label),1)],8,Mt)),64))])]),t(`section`,Ft,[t(`h3`,It,[s(z,{size:18}),o[10]||=i(` اطلاعات شرکت `,-1)]),t(`dl`,Lt,[(a(!0),l(n,null,p(H.value,e=>(a(),l(`div`,{key:e.label,class:`profile-info-list__row`},[t(`dt`,null,f(e.label),1),t(`dd`,null,[e.badge?(a(),l(`span`,Rt,f(e.value),1)):(a(),l(n,{key:1},[i(f(e.value),1)],64))])]))),128))])])])]))}}),[[`__scopeId`,`data-v-0481e66d`]]),Bt=u({__name:`ProfileView`,setup(e){let t=m(),r=k();function i(){r.logout(),t.replace(`/login`)}return(e,t)=>(a(),l(n,null,[s(Je,{class:`mobile-only`}),s(zt,{class:`desktop-only`,onLogout:i})],64))}});export{Bt as default}; |