Files
machartaa_admin_dist/dist/assets/index-d8ad4ee9.js
T

2 lines
11 KiB
JavaScript
Raw Normal View History

2026-06-07 15:06:40 +03:30
import{_ as D,u as I}from"./useBaseTable-084adda9.js";import{_ as M}from"./button.vue_vue_type_style_index_0_lang-379723a2.js";import{I as q}from"./Icon-61906fca.js";import{_ as P}from"./Modal.vue_vue_type_style_index_0_lang-5da46335.js";import{_ as R}from"./BasicInput.vue_vue_type_style_index_0_lang-1513fc09.js";import{_ as S,H as f,d as T,r as A,Q as F,C as p,o as $,i as V,w as _,a as y,b as c,j as v,g as E,c as z,E as O}from"./index-5870e6d3.js";import{F as j,_ as x}from"./index-c8d614fc.js";import{t as H}from"./useDataTime-b0920a9a.js";import{M as N}from"./index-12089cb1.js";import{T as B}from"./shallowequal-2bdf6cc7.js";import"./fa_IR-09853d0d.js";import"./toArray-f3da0fcb.js";import"./vnode-22dd7580.js";import"./FormItemContext-817438bc.js";import"./pickAttrs-38dcf0c9.js";import"./useState-9f642396.js";import"./_plugin-vue_export-helper-5e3c08f4.js";import"./lodash-c64d74c3.js";import"./BasicModal.vue_vue_type_style_index_0_lang-cd9077ad.js";import"./index-ccb2a61b.js";import"./Col-619d881f.js";import"./index-f48a08af.js";import"./isPlainObject-9db900ef.js";import"./index-46729aba.js";import"./usePrice-7afab779.js";const G=async r=>{const{TableEngineRequest:t}=await S(()=>import("./buildSupabaseQuery-e573bc87.js"),["assets/buildSupabaseQuery-e573bc87.js","assets/index-5870e6d3.js","assets/index-fc36161b.css"]),s={...r};!s.sort&&!s.order&&(s.order="-created_at");const e=await t(s,"users");try{if(Array.isArray(e==null?void 0:e.rows)){const a=e.rows.map(l=>({id:l.id??null,first_name:l.first_name||"",last_name:l.last_name||"",phone:l.phone||"",fname:l.first_name||"",lname:l.last_name||"",mobile:l.phone||"",...l}));return{...e,rows:a}}}catch(a){console.log("[getMembersTable] normalize error:",a)}return e},C=async r=>{const{data:t,error:s}=await f.from("users").select("*").eq("id",r).single();if(s)throw s;return{id:t.id??null,first_name:t.first_name||"",last_name:t.last_name||"",phone:t.phone||"",fname:t.first_name||"",lname:t.last_name||"",mobile:t.phone||"",...t}},J=async r=>{const t={};r.first_name&&r.first_name.trim()!==""&&(t.first_name=r.first_name.trim()),r.last_name&&r.last_name.trim()!==""&&(t.last_name=r.last_name.trim()),r.phone&&r.phone.trim()!==""&&(t.phone=r.phone.trim());const{data:s,error:e}=await f.from("users").select("id, user_id").order("created_at",{ascending:!1}).limit(100);if(e||!s||s.length===0)throw new Error("برای ایجاد کاربر جدید، حداقل یک کاربر باید در سیستم وجود داشته باشد");let a=null;const l=s.find(u=>u.id===u.user_id);l?a=l.id:a=s[0].id,t.user_id=a;let d=null,w=null,i=0;const n=10,m=new Set;for(m.add(a);i<n;){const u=await f.from("users").insert([t]).select().single();if(w=u.error,d=u.data,!w)break;if(w.code==="23505"&&w.message.includes("user_id")){if(i++,i>=n)throw new Error("خطا در ایجاد کاربر: user_id باید منحصر به فرد باشد. لطفاً چند لحظه صبر کنید و دوباره تلاش کنید.");await new Promise(b=>setTimeout(b,300*i));const{data:o,error:U}=await f.from("users").select("id, user_id").order("created_at",{ascending:!1}).limit(100);if(!U&&o&&o.length>0){const b=o.find(h=>!m.has(h.id));if(b){a=b.id,m.add(a),t.user_id=a;continue}const g=o.find(h=>h.id===h.user_id&&!m.has(h.id));if(g){a=g.id,m.add(a),t.user_id=a;continue}const k=o.find(h=>h.id!==a);if(k){a=k.id,t.user_id=a;continue}}throw new Error("خطا در ایجاد کاربر: لطفاً چند لحظه صبر کنید و دوباره تلاش کنید.")}else throw w}if(w)throw w;if(d&&d.id&&d.user_id!==d.id){const{data:u,error:o}=await f.from("users").update({user_id:d.id}).eq("id",d.id).select().single();if(!o&&u)return u;if(o)throw o}return d},L=async(r,t)=>{const s={};t.first_name!==void 0&&(s.first_name=t.first_name.trim()||null),t.last_name!==void 0&&(s.last_name=t.last_name.trim()||null),t.phone!==void 0&&(s.phone=t.phone.trim()||null);const{data:e,error:a}=await f.from("users").update(s).eq("id",r).select().single();if(a)throw a;return e},Q=async r=>{const{error:t}=await f.from("users").delete().eq("id",r);if(t)t