1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
import{A as e,Ct as t,E as n,F as r,G as i,I as a,L as o,M as s,O as c,P as l,Q as u,Y as d,_ as f,bt as p,ft as m,j as h,k as g,n as _,q as v,t as y,w as b,wt as x,xt as S}from"./BasicIcon-CjTTsi6o.js";import{n as C,o as w,r as T,u as E}from"./format-BHJptHdF.js";import{C as ee,S as D,c as O,h as k,m as A,o as j,r as M,s as te,u as ne,x as N,y as P}from"./index-D3Z8WOeX.js";import{r as F,t as I}from"./constants-DXXK14Zz.js";import{t as L}from"./IconEditPen-CUhGotGH.js";import{t as R}from"./IconBuilding-BTmZv_WO.js";import{t as z}from"./IconLayoutGrid-fpJ_H2ee.js";import{t as B}from"./PageSkeleton-CyATkHE1.js";import{n as V,t as H}from"./crm-l0KpZ2AN.js";import{n as U,t as W}from"./IconBolt-DDYT1Qsn.js";import{t as G}from"./IconCash-CCD4LPLC.js";import{t as K}from"./IconCashSettlement-DDfZWnNk.js";import{n as q,t as J}from"./IconMail-xKb9uNIK.js";var Y=o({__name:`IconSettings`,props:{size:{default:24},strokeWidth:{default:1.5},color:{default:null}},setup(t){return(n,r)=>(v(),e(y,{icon:`vuesax-linear:setting-2`,size:t.size,"stroke-width":t.strokeWidth,color:t.color},null,8,[`size`,`stroke-width`,`color`]))}}),X={class:`page profile-page`},Z={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=_(o({__name:`MobileProfilePage`,setup(o){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},_=f(),C=O(),E=k(),D=H(),A=ne(),N=m(null),P=m(u),L=m(!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=c(()=>[...E.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?T(e.createdAt):``,customer:e.companyName||``,statusLabel:I[e.status]||e.status,statusTone:n}})),U=c(()=>C.fullName||`کاربر`),W=c(()=>N.value?.code||C.user?.agentCode||`—`),G=c(()=>N.value?.levelLabel||C.user?.levelLabel||`برنزی`),K=c(()=>N.value?.nextLevelLabel||C.user?.nextLevelLabel||`نقرهای`),q=c(()=>N.value?.pointsToNext??C.user?.pointsToNext??0),J=c(()=>N.value?.periodLabel||`۳۰ روز اخیر`),Je=c(()=>N.value?.customersCount??0),Q=c(()=>N.value?.ordersCount??E.orders.length),Ye=c(()=>N.value?.salesVolumeToman??0),$=c(()=>N.value?.profitToman??0),Xe=c(()=>N.value?.levelProgress??C.user?.levelProgress??72),Ze=c(()=>A.unreadCount>9?`9+`:String(A.unreadCount)),Qe=c(()=>P.value.basePrice??u.basePrice??0);return i(async()=>{L.value=!0;try{A.hydrate();try{N.value=await V()}catch{N.value=null}try{let e=(await D.loadBrowseProducts())[0];P.value=e?{...u,...e,basePrice:e.basePrice??u.basePrice}:u}catch{P.value=u}E.orders.length||await E.hydrate()}finally{L.value=!1}}),(i,o)=>(v(),s(`div`,X,[g(`div`,Z,[g(`header`,re,[g(`div`,ie,[g(`div`,ae,[g(`button`,{type:`button`,class:`icon-btn`,"aria-label":`تنظیمات`,onClick:o[0]||=e=>p(_).push(`/profile/display`)},[a(Y,{size:20,color:`#ffffff`})]),o[4]||=g(`h1`,null,`پروفایل من`,-1),g(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اعلانها`,onClick:o[1]||=e=>p(_).push(`/profile/notifications`)},[a(te,{size:20,color:`#ffffff`}),p(A).hasUnread?(v(),s(`span`,{key:0,class:`icon-btn__badge`,"aria-label":`${p(A).unreadCount} اعلان خواندهنشده`},x(Ze.value),9,oe)):h(``,!0)])]),a(M,{class:`hero__avatar`,src:p(C).user?.avatarUrl,initials:U.value.charAt(0),size:84},null,8,[`src`,`initials`])]),g(`div`,se,[g(`h2`,null,x(U.value),1),g(`p`,null,`کد واسطه: `+x(W.value),1),g(`span`,ce,[o[5]||=g(`svg`,{class:`level-pill__crown`,viewBox:`0 0 24 24`,"aria-hidden":`true`},[g(`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),r(` سطح: `+x(G.value),1)])])]),g(`div`,le,[L.value?(v(),e(B,{key:0,variant:`profile`})):(v(),s(n,{key:1},[g(`section`,ue,[g(`div`,de,[o[6]||=g(`h3`,null,`خلاصه عملکرد`,-1),g(`span`,fe,[r(x(J.value)+` `,1),a(y,{icon:`vuesax-linear:arrow-down`,size:14,"stroke-width":1.5})])]),g(`div`,pe,[g(`div`,me,[g(`div`,he,[o[7]||=g(`span`,{class:`stat-card__label`},`سفارشها`,-1),g(`strong`,ge,x(p(w)(Q.value)),1),o[8]||=g(`em`,{class:`stat-card__hint`},`سفارش`,-1)]),g(`span`,_e,[a(ee,{size:18})])]),g(`div`,ve,[g(`div`,ye,[o[9]||=g(`span`,{class:`stat-card__label`},`مشتریان من`,-1),g(`strong`,be,x(p(w)(Je.value)),1),o[10]||=g(`em`,{class:`stat-card__hint`},`مشتری فعال`,-1)]),g(`span`,xe,[a(y,{icon:`vuesax-linear:people`,size:18,"stroke-width":1.5})])]),g(`div`,Se,[g(`div`,Ce,[o[11]||=g(`span`,{class:`stat-card__label`},`سود شما (ریال)`,-1),g(`strong`,we,x(p(w)($.value)),1),o[12]||=g(`em`,{class:`stat-card__hint`},`تومان`,-1)]),g(`span`,Te,[a(y,{icon:`vuesax-linear:chart-2`,size:18,"stroke-width":1.5})])]),g(`div`,Ee,[g(`div`,De,[o[13]||=g(`span`,{class:`stat-card__label`},`حجم فروش (ریال)`,-1),g(`strong`,Oe,x(p(w)(Ye.value)),1),o[14]||=g(`em`,{class:`stat-card__hint`},`تومان`,-1)]),g(`span`,ke,[a(y,{icon:`vuesax-linear:wallet`,size:18,"stroke-width":1.5})])])])]),g(`section`,Ae,[g(`div`,je,[o[15]||=l(`<div class="loyalty__crown" aria-hidden="true" data-v-cb99d05f><svg viewBox="0 0 48 48" width="40" height="40" data-v-cb99d05f><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-cb99d05f></path><path fill="#C9A227" d="M10 36h28v3H10z" data-v-cb99d05f></path><circle cx="24" cy="28" r="3" fill="#F7E7A1" data-v-cb99d05f></circle></svg></div>`,1),g(`p`,Me,` شما در سطح `+x(G.value)+` قرار دارید. تا سطح `+x(K.value)+` فقط `+x(p(w)(q.value))+` تومان فروش دیگر نیاز دارید. `,1)]),g(`div`,Ne,[g(`span`,{style:t({width:`${Math.min(100,Math.max(0,Xe.value))}%`})},null,4)])]),g(`section`,null,[o[16]||=g(`h3`,{class:`section-title`},`دسترسی سریع`,-1),g(`div`,Pe,[(v(),s(n,null,d(R,e=>g(`button`,{key:e.label,type:`button`,class:`quick-item`,onClick:t=>p(_).push(e.to)},[g(`span`,Ie,[a(y,{icon:e.icon,size:22,"stroke-width":1.5},null,8,[`icon`])]),r(` `+x(e.label),1)],8,Fe)),64))])]),g(`section`,Le,[g(`div`,Re,[o[17]||=g(`h3`,null,`آخرین سفارشها`,-1),g(`button`,{type:`button`,class:`link`,onClick:o[2]||=e=>p(_).push(`/orders`)},`مشاهده همه`)]),(v(!0),s(n,null,d(z.value,e=>(v(),s(`article`,{key:e.id,class:`order-row`,role:`button`,tabindex:`0`,onClick:t=>p(_).push({path:`/order`,query:{id:e.id}}),onKeydown:b(t=>p(_).push({path:`/order`,query:{id:e.id}}),[`enter`])},[g(`div`,Be,[g(`span`,Ve,x(e.date),1),g(`strong`,He,x(e.title),1),e.customer?(v(),s(`p`,Ue,`مشتری: `+x(e.customer),1)):h(``,!0)]),g(`span`,{class:S([`tone`,`tone--${e.statusTone}`])},x(e.statusLabel),3),a(j,{size:16,class:`order-row__chevron`})],40,ze))),128)),g(`button`,{type:`button`,class:`orders-all`,onClick:o[3]||=e=>p(_).push(`/orders`)},` مشاهده همه سفارشها `)]),g(`section`,We,[o[18]||=g(`h3`,{class:`section-title`},`قیمتهای پایه (نمونه)`,-1),g(`div`,Ge,[g(`div`,Ke,[g(`div`,qe,[g(`strong`,null,x(P.value.name),1),g(`p`,null,`کد: `+x(P.value.code),1),g(`p`,null,`عرض: `+x(p(w)(P.value.widthCm))+` سانتیمتر`,1),g(`p`,null,`رنگها: `+x(p(w)(P.value.colors.length))+` رنگ`,1)]),g(`div`,{class:`price-card__image`,style:t(P.value.imageUrl?{backgroundImage:`url(${P.value.imageUrl})`}:void 0)},null,4)]),g(`footer`,null,`قیمت پایه به شما: `+x(p(w)(Qe.value))+` تومان / متر`,1)])])],64))])])]))}}),[[`__scopeId`,`data-v-cb99d05f`]]),Q=o({__name:`IconMapPin`,props:{size:{default:24},strokeWidth:{default:1.5},color:{default:null}},setup(t){return(n,r)=>(v(),e(y,{icon:`vuesax-linear:location`,size:t.size,"stroke-width":t.strokeWidth,color:t.color},null,8,[`size`,`stroke-width`,`color`]))}}),Ye=o({__name:`IconVerified`,props:{size:{default:24},strokeWidth:{default:1.5},color:{default:null}},setup(t){return(n,r)=>(v(),e(y,{icon:`vuesax-linear:verify`,size:t.size,"stroke-width":t.strokeWidth,color:t.color},null,8,[`size`,`stroke-width`,`color`]))}}),$=o({__name:`IconLock`,props:{size:{default:24},strokeWidth:{default:1.5},color:{default:null}},setup(t){return(n,r)=>(v(),e(y,{icon:`vuesax-linear:lock`,size:t.size,"stroke-width":t.strokeWidth,color:t.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=_(o({__name:`DesktopProfilePage`,emits:[`logout`],setup(t,{emit:i}){let o=f(),l=O(),m=k(),h=i,_=c(()=>`${l.user?.firstName?.[0]??``}${l.user?.lastName?.[0]??``}`||`؟`),y=c(()=>l.user?.id?m.userOrders(l.user.id).length:0),b=c(()=>l.user?.id?m.userOrders(l.user.id).reduce((e,t)=>e+(t.checks?.length??0),0)+m.draftChecks.length:0),S=c(()=>{let e=l.user;return e?l.isAgent&&e.agentCode?E(e.agentCode):e.nationalId?E(e.nationalId.slice(-6).padStart(6,`0`)):E(e.id?.slice(-6)??`—`):E(`—`)}),ee=c(()=>l.isAgent?`کد واسطه:`:`کد مشتری:`),ne=c(()=>{let e=l.user?.phone??``;return e?`user${e.slice(-4)}@parsbaft.ir`:`—`}),F=c(()=>l.user?.createdAt?T(l.user.createdAt):`—`),I=c(()=>0),B=c(()=>[{label:`نام شرکت`,value:l.fullName||`—`},{label:`شناسه ملی`,value:l.user?.nationalId?E(l.user.nationalId):`—`},{label:`کد اقتصادی`,value:l.user?.nationalId?E(`4${l.user.nationalId.slice(0,10)}`):`—`},{label:`تاریخ عضویت`,value:F.value},{label:`نوع مشتری`,value:l.isAgent?`واسطه`:`مشتری عمده`,badge:!0},{label:`وضعیت حساب`,value:`فعال`,badge:!0}]),V=[{label:`حسابهای بانکی`,icon:K},{label:`آدرسها`,icon:Q},{label:`حمایت و پشتیبانی`,icon:A,href:`tel:02112345678`},{label:`فاکتورهای من`,icon:D,path:`/orders`}],H=[{id:`profile`,label:`اطلاعات کاربری`,description:`ویرایش نام، موبایل و ایمیل`,icon:N,path:`/profile/edit`},{id:`security`,label:`امنیت حساب`,description:`تغییر رمز عبور و تنظیمات ورود`,icon:$,path:`/profile/security`},{id:`notifications`,label:`اعلانها`,description:`خبرهای فاکتور، چک و ارسال سفارش`,icon:te,path:`/profile/notifications`},{id:`display`,label:`تنظیمات`,description:`نمایش، اطلاعات کاربری و خروج`,icon:z,path:`/profile/display`},{id:`logout`,label:`خروج از حساب`,description:`پایان نشست و ورود مجدد`,icon:$,action:`logout`}];function X(e){e.path?o.push(e.path):e.href&&(window.location.href=e.href)}function Z(e){if(e.action===`logout`){h(`logout`);return}e.path&&o.push(e.path)}return(t,i)=>(v(),s(`div`,Xe,[i[11]||=g(`header`,{class:`desktop-profile__head`},[g(`h1`,{class:`desktop-profile__title`},`پروفایل`),g(`p`,{class:`desktop-profile__subtitle`},`مدیریت اطلاعات حساب کاربری و تنظیمات`)],-1),g(`section`,Ze,[g(`div`,Qe,[g(`div`,$e,[a(M,{class:`profile-overview__avatar`,src:p(l).user?.avatarUrl,initials:_.value,size:92},null,8,[`src`,`initials`]),g(`button`,{type:`button`,class:`profile-overview__edit`,onClick:i[0]||=e=>p(o).push(`/profile/edit`)},[a(L,{size:16}),i[3]||=r(` ویرایش اطلاعات `,-1)])]),g(`div`,et,[g(`div`,tt,[g(`h2`,nt,x(p(l).fullName),1),g(`span`,rt,[a(Ye,{size:18})])]),g(`p`,it,[a(U,{size:15,class:`profile-overview__meta-icon`}),g(`span`,at,x(ee.value),1),g(`span`,null,x(S.value),1)]),g(`p`,ot,[a(q,{size:15,class:`profile-overview__meta-icon`}),g(`span`,st,x(p(l).user?.phone),1)]),g(`p`,ct,[a(J,{size:15,class:`profile-overview__meta-icon`}),g(`span`,lt,x(ne.value),1)])])]),g(`div`,ut,[g(`article`,dt,[g(`span`,ft,[a(G,{size:20})]),g(`strong`,pt,x(p(C)(I.value)),1),i[4]||=g(`span`,{class:`profile-stat__label`},`موجودی اعتبار`,-1),i[5]||=g(`button`,{type:`button`,class:`profile-stat__link`},`مشاهده جزئیات`,-1)]),g(`article`,mt,[g(`span`,ht,[a(P,{size:20})]),g(`strong`,gt,x(p(w)(b.value)),1),i[6]||=g(`span`,{class:`profile-stat__label`},`چک فعال`,-1),g(`button`,{type:`button`,class:`profile-stat__link`,onClick:i[1]||=e=>p(o).push(`/profile/checks`)},` مشاهده همه `)]),g(`article`,_t,[g(`span`,vt,[a(D,{size:20})]),g(`strong`,yt,x(p(w)(y.value)),1),i[7]||=g(`span`,{class:`profile-stat__label`},`سفارش ثبتشده`,-1),g(`button`,{type:`button`,class:`profile-stat__link`,onClick:i[2]||=e=>p(o).push(`/orders`)},` مشاهده همه `)])])]),g(`div`,bt,[g(`section`,xt,[g(`h3`,St,[a(Y,{size:18}),i[8]||=r(` تنظیمات حساب `,-1)]),g(`nav`,Ct,[(v(),s(n,null,d(H,t=>g(`button`,{key:t.id,type:`button`,class:`profile-settings__item`,onClick:e=>Z(t)},[g(`span`,Tt,[(v(),e(u(t.icon),{size:20}))]),g(`span`,Et,[g(`strong`,Dt,x(t.label),1),g(`span`,Ot,x(t.description),1)]),a(j,{size:16,class:`profile-settings__chevron`,"aria-hidden":`true`})],8,wt)),64))])]),g(`section`,kt,[g(`h3`,At,[a(W,{size:18}),i[9]||=r(` دسترسی سریع `,-1)]),g(`div`,jt,[(v(),s(n,null,d(V,t=>g(`button`,{key:t.label,type:`button`,class:`profile-quick-grid__item`,onClick:e=>X(t)},[g(`span`,Nt,[(v(),e(u(t.icon),{size:22}))]),g(`span`,Pt,x(t.label),1)],8,Mt)),64))])]),g(`section`,Ft,[g(`h3`,It,[a(R,{size:18}),i[10]||=r(` اطلاعات شرکت `,-1)]),g(`dl`,Lt,[(v(!0),s(n,null,d(B.value,e=>(v(),s(`div`,{key:e.label,class:`profile-info-list__row`},[g(`dt`,null,x(e.label),1),g(`dd`,null,[e.badge?(v(),s(`span`,Rt,x(e.value),1)):(v(),s(n,{key:1},[r(x(e.value),1)],64))])]))),128))])])])]))}}),[[`__scopeId`,`data-v-0481e66d`]]),Bt=o({__name:`ProfileView`,setup(e){let t=f(),r=O();function i(){r.logout(),t.replace(`/login`)}return(e,t)=>(v(),s(n,null,[a(Je,{class:`mobile-only`}),a(zt,{class:`desktop-only`,onLogout:i})],64))}});export{Bt as default}; |