Files
nademitex_user/dist/assets/CustomerCreateOverlay-BlatCdeJ.js
T
mohmdsdgandCopilot adb6ca47cd fix(auth): secure sessions and app routing
Validate sessions against the API, honor configurable base paths, and route unknown pages to 404. Keep development ports stable so user and admin apps cannot be confused.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-24 20:14:11 +03:30

1 line
4.6 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 e,E as t,J as n,M as r,N as i,O as a,P as o,S as s,T as c,U as l,Xt as u,at as d,st as f,t as p,vt as m,w as h}from"./_plugin-vue_export-helper-Bo3WtfwJ.js";import{n as g,u as _}from"./BasicIcon-BXxbbWA_.js";import{t as v}from"./http-CeONvUNq.js";import{l as y}from"./format-C72AoJ2H.js";import{a as b}from"./validation-Duyyve7l.js";import{c as x,n as S}from"./index-BAQfYU-Q.js";import{t as C}from"./FormErrorBanner-DI5hhxpk.js";import{n as w,r as T,t as E}from"./formErrors-DglFjYkZ.js";import{t as D}from"./crm-CooNUbmr.js";import{t as O}from"./BaseInput-CVNdy37R.js";var k={class:`customer-create-form`},A={key:0,class:`customer-create-form__intro`},j={class:`customer-create-form__fields`},M=p(o({__name:`CustomerCreateForm`,props:{customerId:{},initial:{}},emits:[`success`],setup(t,{expose:o,emit:s}){let l=t,p=s,h=x(),g=D(),_=m(``),M=m(``),N=m(``),P=m(``),F=m({}),I=m(``),L=m(!1),R=()=>!!l.customerId;function z(e){_.value=e?.firstName??``,M.value=e?.lastName??``,N.value=e?.phone??``,P.value=e?.businessName??``,F.value={},I.value=``}d(()=>l.initial,e=>z(e),{immediate:!0});function B(e){F.value=w(F.value,e),T(F.value)||(I.value=``)}async function V(){if(F.value={},I.value=``,!h.isAgent){I.value=`فقط واسطه می‌تواند مشتری به لیست خود اضافه کند.`;return}let e=y(N.value),t={};if(_.value.trim()||(t.firstName=`نام الزامی است.`),M.value.trim()||(t.lastName=`نام خانوادگی الزامی است.`),b(e)||(t.phone=`شماره موبایل معتبر نیست.`),T(t)){F.value=t,I.value=E;return}let n={firstName:_.value.trim(),lastName:M.value.trim(),phone:e,businessName:P.value.trim()||void 0};L.value=!0;try{if(R()&&l.customerId){let e=await g.updateCustomer(l.customerId,n);p(`success`,e?.id??l.customerId);return}let e=await g.registerCustomer(n);p(`success`,e?.id)}catch(e){I.value=e instanceof v||e instanceof Error?e.message:R()?`ویرایش مشتری ناموفق بود.`:`ثبت مشتری ناموفق بود.`}finally{L.value=!1}}return o({submit:V,saving:L}),(t,o)=>(n(),a(`div`,k,[R()?e(``,!0):(n(),a(`p`,A,` مشتری به لیست شما اضافه می‌شود و بعد از ورود با همین شماره، سفارش‌هایش به حساب شما وصل می‌ماند. `)),i(C,{message:I.value},null,8,[`message`]),c(`div`,j,[i(O,{modelValue:_.value,"onUpdate:modelValue":[o[0]||=e=>_.value=e,o[1]||=e=>B(`firstName`)],label:`نام`,placeholder:`نام مشتری`,error:F.value.firstName},null,8,[`modelValue`,`error`]),i(O,{modelValue:M.value,"onUpdate:modelValue":[o[2]||=e=>M.value=e,o[3]||=e=>B(`lastName`)],label:`نام خانوادگی`,placeholder:`نام خانوادگی`,error:F.value.lastName},null,8,[`modelValue`,`error`]),i(O,{modelValue:N.value,"onUpdate:modelValue":[o[4]||=e=>N.value=e,o[5]||=e=>B(`phone`)],label:`شماره موبایل`,type:`tel`,inputmode:`tel`,dir:`ltr`,placeholder:`۰۹۱۲۳۴۵۶۷۸۹`,error:F.value.phone},null,8,[`modelValue`,`error`]),i(O,{modelValue:P.value,"onUpdate:modelValue":o[6]||=e=>P.value=e,label:`نام فروشگاه یا برند (اختیاری)`,placeholder:`مثلاً بوتیک رز`},null,8,[`modelValue`])]),i(S,{block:``,loading:L.value,disabled:L.value,onClick:V},{default:f(()=>[r(u(R()?`ذخیره تغییرات`:`ثبت مشتری`),1)]),_:1},8,[`loading`,`disabled`])]))}}),[[`__scopeId`,`data-v-4f911c6f`]]),N={class:`customer-create-sheet`},P={class:`customer-create-sheet__head`},F={id:`customer-create-title`},I=p(o({__name:`CustomerCreateOverlay`,props:{open:{type:Boolean},customerId:{},initial:{},title:{}},emits:[`close`,`success`],setup(r,{emit:o}){let p=r,m=h(()=>p.title??(p.customerId?`ویرایش مشتری`:`افزودن مشتری`)),v=o;function y(){v(`close`)}function b(e){v(`success`,e)}function x(e){e.key===`Escape`&&p.open&&y()}return d(()=>p.open,e=>{document.body.style.overflow=e?`hidden`:``,e?window.addEventListener(`keydown`,x):window.removeEventListener(`keydown`,x)},{immediate:!0}),l(()=>{document.body.style.overflow=``,window.removeEventListener(`keydown`,x)}),(o,l)=>(n(),t(s,{to:`body`},[i(g,{name:`customer-create-sheet`},{default:f(()=>[r.open?(n(),a(`div`,{key:0,class:`customer-create-overlay`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`customer-create-title`,onClick:_(y,[`self`])},[c(`div`,N,[l[0]||=c(`div`,{class:`customer-create-sheet__handle`,"aria-hidden":`true`},null,-1),c(`header`,P,[c(`h2`,F,u(m.value),1),c(`button`,{type:`button`,class:`customer-create-sheet__close`,"aria-label":`بستن`,onClick:y},` × `)]),i(M,{"customer-id":r.customerId,initial:r.initial,onSuccess:b},null,8,[`customer-id`,`initial`])])])):e(``,!0)]),_:1})]))}}),[[`__scopeId`,`data-v-ac91feb8`]]);export{I as t};