PageSourceSearch

https://saudilegal.ai/assets/AdminCrmSyncTab-D46qDfRL.js

js saudilegal.ai collected 2026-10-05 15:14:15 UTC 7,164 bytes, 1 lines download raw bytes

1import{j as s}from"./vendor-ui-CJswEVbh.js";import{r as x}from"./vendor-react-CXRu5Dj1.js";import{u as D,p as M,m as L,Q as P,C as v,f as V,g as H,B as d,R as I,a as R,K as O,s as u,h as l}from"./index-D7ZrIOpR.js";import{B as F}from"./badge-Ci7ft87c.js";import{T as $,a as K,b as f,c as n,d as Q,e as r}from"./table-Cs9hCfNc.js";import{R as W}from"./rotate-ccw-B4kk0kJc.js";import"./vendor-query-DGJZ7wa4.js";import"./vendor-helmet--SzguAe_.js";import"./vendor-recharts-_i_RtjiL.js";import"./vendor-supabase-DiBj512E.js";import"./vendor-markdown-BLahVorR.js";const Z={synced:"bg-emerald-100 text-emerald-800",pending:"bg-sky-100 text-sky-800",processing:"bg-sky-100 text-sky-800",retry:"bg-amber-100 text-amber-800",failed:"bg-red-100 text-red-800"},j={hubspot:"crm-sync-worker",google_sheets:"sheets-sync-worker"},q=["all","hubspot","google_sheets"],oe=()=>{const{l:t,dir:N}=D(),{user:h,loading:w}=M(),[k,y]=x.useState(!1),[C,_]=x.useState(!1),[o,T]=x.useState("all"),i=L((h==null?void 0:h.id)??null,!w,async e=>O(await u.from("crm_sync_jobs").select("id, provider, submission_type, submission_id, source, status, attempt_count, last_error_message_safe, hubspot_contact_id, hubspot_company_id, hubspot_deal_id, hubspot_ticket_id, created_at, synced_at").order("created_at",{ascending:!1}).limit(300).abortSignal(e.signal))??[],[]),c=i.data,S=i.initialLoading,b=()=>i.refresh(!1,!0),g=x.useMemo(()=>o==="all"?c:c.filter(e=>e.provider===o),[c,o]),E=g.reduce((e,a)=>(e[a.status]=(e[a.status]??0)+1,e),{}),G=c.reduce((e,a)=>(e[a.provider]=(e[a.provider]??0)+1,e),{}),z=async e=>{const{error:a}=await u.from("crm_sync_jobs").update({status:"pending",attempt_count:0,next_attempt_at:new Date().toISOString(),last_error_message_safe:null}).eq("id",e.id);if(a){l.error(a.message);return}await u.functions.invoke(j[e.provider]??"crm-sync-worker",{body:{trigger:"admin"}}),l.success(t("تمت إعادة جدولة المزامنة","Sync re-queued","已重新排队","Synchronisation relancée","Synchronisierung erneut eingeplant","Sincronización reencolada")),b()},A=async()=>{y(!0);const e=o==="all"?["crm-sync-worker","sheets-sync-worker"]:[j[o]],a=await Promise.all(e.map(p=>u.functions.invoke(p,{body:{trigger:"admin"}})));y(!1);const m=a.find(p=>p.error);m!=null&&m.error?l.error(m.error.message):l.success(t("تم تشغيل المزامنة","Sync run started","同步已启动","Synchronisation lancée","Synchronisierung gestartet","Sincronización iniciada")),b()},B=async()=>{_(!0);const{error:e}=await u.functions.invoke("sheets-sync-worker",{body:{ensure_tabs:!0}});_(!1),e?l.error(e.message):l.success(t("تم التحقق من تبويبات جوجل شيت","Google Sheets tabs verified","已验证 Google Sheets 标签","Onglets Google Sheets vérifiés","Google-Sheets-Tabs geprüft","Pestañas de Google Sheets verificadas"))};return s.jsxs("div",{className:"space-y-6",dir:N,children:[s.jsx(P,{state:i}),s.jsxs(v,{children:[s.jsxs(V,{className:"flex-row items-center justify-between gap-3",children:[s.jsx(H,{className:"text-base",children:t("مزامنة CRM وجوجل شيت","CRM & Google Sheets delivery","CRM 与 Google Sheets 同步","Livraison CRM et Google Sheets","CRM- und Google-Sheets-Zustellung","Entrega CRM y Google Sheets")}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(d,{variant:"outline",size:"sm",onClick:()=>void i.refresh(!0,!0),disabled:S||i.manualRefreshing,children:[s.jsx(I,{className:`h-4 w-4 me-1 ${i.manualRefreshing?"animate-spin":""}`}),t("تحديث","Refresh","刷新","Actualiser","Aktualisieren","Actualizar")]}),s.jsx(d,{variant:"outline",size:"sm",onClick:()=>void B(),disabled:C,children:t("تهيئة تبويبات جوجل شيت","Verify Sheets tabs","验证表格标签","Vérifier les onglets","Tabs prüfen","Verificar pestañas")}),s.jsx(d,{size:"sm",onClick:()=>void A(),disabled:k,children:t("تشغيل المزامنة","Run sync","运行同步","Lancer la synchro","Sync starten","Ejecutar sincronización")})]})]}),s.jsxs(R,{className:"space-y-3",children:[s.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(e=>s.jsxs(d,{size:"sm",variant:o===e?"default":"outline",onClick:()=>T(e),children:[e==="all"?t("الكل","All","全部","Tout","Alle","Todos"):e==="hubspot"?"HubSpot":"Google Sheets",e!=="all"?` (${G[e]??0})`:` (${c.length})`]},e))}),s.jsx("div",{className:"flex flex-wrap gap-2",children:["synced","pending","retry","processing","failed"].map(e=>s.jsxs(F,{variant:"outline",className:"text-xs",children:[e,": ",E[e]??0]},e))})]})]}),s.jsx(v,{children:s.jsx(R,{className:"p-0 overflow-x-auto",children:s.jsxs($,{children:[s.jsx(K,{children:s.jsxs(f,{children:[s.jsx(n,{className:"text-start",children:t("القناة","Destination","渠道","Destination","Ziel","Destino")}),s.jsx(n,{className:"text-start",children:t("النوع","Type","类型","Type","Typ","Tipo")}),s.jsx(n,{className:"text-start",children:t("المعرّف","Submission","提交","Soumission","Eingang","Envío")}),s.jsx(n,{className:"text-start",children:t("الحالة","Status","状态","Statut","Status","Estado")}),s.jsx(n,{className:"text-start",children:t("المحاولات","Attempts","尝试","Tentatives","Versuche","Intentos")}),s.jsx(n,{className:"text-start",children:t("مراجع","References","引用","Références","Referenzen","Referencias")}),s.jsx(n,{className:"text-start",children:t("التاريخ","Created","创建","Créé","Erstellt","Creado")}),s.jsx(n,{className:"text-start"})]})}),s.jsxs(Q,{children:[g.map(e=>s.jsxs(f,{children:[s.jsx(r,{className:"text-start text-xs",children:e.provider==="google_sheets"?"Google Sheets":"HubSpot"}),s.jsx(r,{className:"text-start",children:e.submission_type}),s.jsx(r,{className:"text-left font-mono text-xs",children:e.submission_id}),s.jsxs(r,{className:"text-start",children:[s.jsx("span",{className:`inline-block rounded px-2 py-0.5 text-xs ${Z[e.status]??""}`,children:e.status}),e.last_error_message_safe?s.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-xs truncate",title:e.last_error_message_safe,children:e.last_error_message_safe}):null]}),s.jsx(r,{className:"text-start",children:e.attempt_count}),s.jsx(r,{className:"text-left font-mono text-xs",children:e.provider==="google_sheets"?e.synced_at?t("تم الإضافة","Row appended","已追加","Ligne ajoutée","Zeile ergänzt","Fila añadida"):"—":[e.hubspot_contact_id,e.hubspot_company_id,e.hubspot_deal_id,e.hubspot_ticket_id].filter(
1Boolean).join(" / ")||"—"}),s.jsx(r,{className:"text-left text-xs",children:new Date(e.created_at).toLocaleString()}),s.jsx(r,{className:"text-start",children:e.status!=="synced"?s.jsxs(d,{variant:"ghost",size:"sm",onClick:()=>void z(e),children:[s.jsx(W,{className:"h-4 w-4 me-1"}),t("إعادة","Retry","重试","Réessayer","Wiederholen","Reintentar")]}):null})]},e.id)),!g.length&&!S?s.jsx(f,{children:s.jsx(r,{colSpan:8,className:"text-center text-sm text-muted-foreground py-8",children:t("لا توجد سجلات مزامنة بعد","No sync records yet","暂无同步记录","Aucun enregistrement","Keine Einträge","Sin registros")})}):null]})]})})})]})};export{oe as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.