Files
nademitex_user/dist/assets/CustomersView-_yD0xFZV.js
T
safavimohadeseh78 418039303c Fix production build and refresh dist output.
Restore catalog cover assets, resolve TypeScript issues in TimeInput and catalogGallery, and rebuild the production bundle.
2026-09-15 21:47:31 +03:30

1 line
8.2 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{A as e,Ct as t,D as n,Et as r,K as i,L as a,M as o,N as s,O as c,P as l,R as u,St as d,Tt as f,Y as p,Z as m,_ as h,g,j as _,k as v,mt as y,n as b,q as x,rt as S,tt as C,y as w,z as T}from"./BasicIcon-C6boaehV.js";import{t as E}from"./http-BC1hNfZ4.js";import{c as D,o as O}from"./format-BHJptHdF.js";import{a as k}from"./validation-BD7oi-2I.js";import{c as A,n as j,o as M,x as N,y as P}from"./index-fdhs4HNc.js";import{t as F}from"./IconFilter-D9NdLZ7w.js";import{t as I}from"./FormErrorBanner-CjdBfIQT.js";import{n as L,r as R,t as z}from"./formErrors-DglFjYkZ.js";import{t as B}from"./PageSkeleton-sKuEY4NI.js";import{t as V}from"./crm-DmqasSZ_.js";import{t as H}from"./PageHeader-Cd04Z6F_.js";import{t as U}from"./SearchField-CRmbblW7.js";import{t as W}from"./BaseInput-C6eO_Qjy.js";var G={class:`customer-create-form`},K={class:`customer-create-form__fields`},q=b(T({__name:`CustomerCreateForm`,emits:[`success`],setup(e,{expose:t,emit:n}){let r=n,i=A(),o=V(),s=y(``),c=y(``),d=y(``),f=y(``),m=y({}),h=y(``),g=y(!1);function v(e){m.value=L(m.value,e),R(m.value)||(h.value=``)}async function b(){if(m.value={},h.value=``,!i.isAgent){h.value=`فقط واسطه می‌تواند مشتری به لیست خود اضافه کند.`;return}let e=D(d.value),t={};if(s.value.trim()||(t.firstName=`نام الزامی است.`),c.value.trim()||(t.lastName=`نام خانوادگی الزامی است.`),k(e)||(t.phone=`شماره موبایل معتبر نیست.`),R(t)){m.value=t,h.value=z;return}g.value=!0;try{let t=await o.registerCustomer({firstName:s.value.trim(),lastName:c.value.trim(),phone:e,businessName:f.value.trim()||void 0});r(`success`,t?.id)}catch(e){h.value=e instanceof E||e instanceof Error?e.message:`ثبت مشتری ناموفق بود.`}finally{g.value=!1}}return t({submit:b,saving:g}),(e,t)=>(p(),l(`div`,G,[t[8]||=_(`p`,{class:`customer-create-form__intro`},` مشتری به لیست شما اضافه می‌شود و بعد از ورود با همین شماره، سفارش‌هایش به حساب شما وصل می‌ماند. `,-1),u(I,{message:h.value},null,8,[`message`]),_(`div`,K,[u(W,{modelValue:s.value,"onUpdate:modelValue":[t[0]||=e=>s.value=e,t[1]||=e=>v(`firstName`)],label:`نام`,placeholder:`نام مشتری`,error:m.value.firstName},null,8,[`modelValue`,`error`]),u(W,{modelValue:c.value,"onUpdate:modelValue":[t[2]||=e=>c.value=e,t[3]||=e=>v(`lastName`)],label:`نام خانوادگی`,placeholder:`نام خانوادگی`,error:m.value.lastName},null,8,[`modelValue`,`error`]),u(W,{modelValue:d.value,"onUpdate:modelValue":[t[4]||=e=>d.value=e,t[5]||=e=>v(`phone`)],label:`شماره موبایل`,type:`tel`,inputmode:`tel`,dir:`ltr`,placeholder:`۰۹۱۲۳۴۵۶۷۸۹`,error:m.value.phone},null,8,[`modelValue`,`error`]),u(W,{modelValue:f.value,"onUpdate:modelValue":t[6]||=e=>f.value=e,label:`نام فروشگاه یا برند (اختیاری)`,placeholder:`مثلاً بوتیک رز`},null,8,[`modelValue`])]),u(j,{block:``,loading:g.value,disabled:g.value,onClick:b},{default:S(()=>[...t[7]||=[a(` ثبت مشتری `,-1)]]),_:1},8,[`loading`,`disabled`])]))}}),[[`__scopeId`,`data-v-a166152e`]]),J={class:`customer-create-sheet`},Y=b(T({__name:`CustomerCreateOverlay`,props:{open:{type:Boolean}},emits:[`close`,`success`],setup(e,{emit:t}){let r=e,a=t;function c(){a(`close`)}function d(e){a(`success`,e)}function f(e){e.key===`Escape`&&r.open&&c()}return C(()=>r.open,e=>{document.body.style.overflow=e?`hidden`:``,e?window.addEventListener(`keydown`,f):window.removeEventListener(`keydown`,f)},{immediate:!0}),i(()=>{document.body.style.overflow=``,window.removeEventListener(`keydown`,f)}),(t,r)=>(p(),o(v,{to:`body`},[u(w,{name:`customer-create-sheet`},{default:S(()=>[e.open?(p(),l(`div`,{key:0,class:`customer-create-overlay`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`customer-create-title`,onClick:n(c,[`self`])},[_(`div`,J,[r[1]||=_(`div`,{class:`customer-create-sheet__handle`,"aria-hidden":`true`},null,-1),_(`header`,{class:`customer-create-sheet__head`},[r[0]||=_(`h2`,{id:`customer-create-title`},`افزودن مشتری`,-1),_(`button`,{type:`button`,class:`customer-create-sheet__close`,"aria-label":`بستن`,onClick:c},` × `)]),u(q,{onSuccess:d})])])):s(``,!0)]),_:1})]))}}),[[`__scopeId`,`data-v-82c86546`]]),X={class:`page customers-page`},Z={class:`page__scroll page__scroll--with-nav customers-scroll`},Q={class:`toolbar`},ee={class:`summary-card`},te={class:`summary-card__icon`,"aria-hidden":`true`},ne={class:`summary-card__cols`},re={class:`tabs`,role:`tablist`},ie=[`aria-selected`,`onClick`],ae={class:`tab__text`},oe={key:1},se=[`onClick`],ce={class:`customer-card__body`},le={class:`customer-card__top`},$=b(T({__name:`CustomersView`,setup(n){let i=g(),a=h(),v=V(),b=y(String(i.query.q??``)),w=e(()=>String(i.query.status??`all`)),T=y([]),E=y(!0),D=y(null),k=e(()=>T.value),A=e(()=>i.query.create===`1`),j=e(()=>T.value.filter(e=>e.status===`active`).length),I=e(()=>T.value.reduce((e,t)=>e+t.totalPurchaseToman,0)),L=[{id:`all`,label:`همه`},{id:`active`,label:`فعال`},{id:`inactive`,label:`غیرفعال`},{id:`new`,label:`جدید`}];async function R(){E.value=!0,D.value=null;try{T.value=await v.loadCustomers({q:b.value||void 0,status:w.value===`all`?void 0:w.value})}catch(e){D.value=e instanceof Error?e.message:`بارگذاری مشتریان ناموفق بود.`,T.value=[]}finally{E.value=!1}}x(R),C([w,b],R);function z(e){a.replace({path:`/customers`,query:{...e===`all`?{}:{status:e},...b.value?{q:b.value}:{}}})}function W(e){b.value=e,a.replace({path:`/customers`,query:{...w.value===`all`?{}:{status:w.value},...e?{q:e}:{}}})}function G(e){return e===`active`?`فعال`:e===`inactive`?`غیرفعال`:`جدید`}function K(e={}){return{...w.value===`all`?{}:{status:w.value},...b.value?{q:b.value}:{},...e}}function q(){a.push({path:`/customers`,query:{...K(),create:`1`}})}function J(){a.replace({path:`/customers`,query:K()})}async function $(e){if(e){await a.replace({path:`/customer`,query:{id:e}});return}J(),await R()}function ue(){let e=[`all`,`active`,`inactive`,`new`],t=e.indexOf(w.value);z(e[(t<0?0:t+1)%e.length]??`all`)}return(e,n)=>(p(),l(`div`,X,[u(H,{title:`مشتریان من`,"show-back":``,centered:``,onBack:n[0]||=e=>d(a).back()},{trailing:S(()=>[_(`button`,{type:`button`,class:`nav-add-btn`,"aria-label":`ثبت مشتری`,onClick:q},[u(P,{size:22})])]),_:1}),_(`div`,Z,[_(`div`,Q,[u(U,{"model-value":b.value,placeholder:`جستجو بر اساس نام یا موبایل...`,"onUpdate:modelValue":W},null,8,[`model-value`]),_(`button`,{type:`button`,class:`filter-btn`,"aria-label":`فیلتر وضعیت`,onClick:ue},[u(F,{size:18})])]),_(`section`,ee,[_(`div`,te,[u(N,{size:22,color:`#fff`})]),_(`div`,ne,[_(`div`,null,[n[1]||=_(`span`,null,`تعداد مشتری فعال`,-1),_(`strong`,null,r(d(O)(j.value)),1)]),n[4]||=_(`span`,{class:`summary-card__divider`,"aria-hidden":`true`},null,-1),_(`div`,null,[n[2]||=_(`span`,null,`مجموع خرید (ریال)`,-1),_(`strong`,null,r(d(O)(I.value)),1),n[3]||=_(`em`,null,`تومان`,-1)])])]),_(`div`,re,[(p(),l(c,null,m(L,e=>_(`button`,{key:e.id,type:`button`,role:`tab`,class:t([`tab`,{"tab--active":w.value===e.id}]),"aria-selected":w.value===e.id,onClick:t=>z(e.id)},[_(`span`,ae,r(e.label),1)],10,ie)),64))]),E.value?(p(),o(B,{key:0,variant:`list`})):D.value?(p(),l(`p`,oe,r(D.value),1)):s(``,!0),(p(!0),l(c,null,m(k.value,e=>(p(),l(`button`,{key:e.id,type:`button`,class:`customer-card`,onClick:t=>d(a).push({path:`/customer`,query:{id:e.id}})},[_(`div`,{class:`customer-card__avatar`,style:f({background:e.avatarColor})},r(e.avatarLetter),5),_(`div`,ce,[_(`div`,le,[_(`strong`,null,r(e.name),1)]),_(`p`,null,r(e.phone),1),_(`p`,null,`مجموع خرید: `+r(d(O)(e.totalPurchaseToman))+` تومان`,1)]),_(`span`,{class:t([`status`,{"status--ok":e.status===`active`,"status--off":e.status===`inactive`,"status--new":e.status===`new`}])},r(G(e.status)),3),u(M,{size:18,class:`chevron`})],8,se))),128)),n[5]||=_(`section`,{class:`promo`},[_(`div`,null,[_(`strong`,null,`افزایش مشتریان = افزایش سطح شما`),_(`p`,null,`با جذب مشتریان بیشتر به سطح VIP برسید`)])],-1)]),u(Y,{open:A.value,onClose:J,onSuccess:$},null,8,[`open`])]))}}),[[`__scopeId`,`data-v-f25758ff`]]);export{$ as default};