PageSourceSearch

https://platform.dalseen.sa/assets/OnboardingPage-Tir2f4RQ.js

js dalseen.sa collected 2026-10-09 23:45:36 UTC 18,404 bytes, 1 lines download raw bytes

1import{u as J,a as se,hk as ne,hl as ae,hm as X,hn as te,r as k,ho as ie,j as e,$ as le,B as q,m as V,n as p,T as H,A as b,M as U,al as re,bv as M,bw as D,O as ce,g as de,L as W,I as z,E as oe,aO as me,N as ue}from"./index-mbu4rngo.js";import{c as xe}from"./staffAssignee.helper-DV8bhZ0z.js";import{O as Y,a as G,n as Z,b as E}from"./onboardingLabels-omYQNSEt.js";import{K as P,F as ge}from"./_shared-lhQwVeXi.js";import{P as he}from"./PlatformPageHeader-v9IdG0yn.js";import{K as pe}from"./KpiSkeleton-CaZsxaxO.js";import{u as fe}from"./useDrawerFromSearch-CYfft93B.js";import"./staffOrgModel-Clzfx9OX.js";import"./saudiRegistryTerms-DA-filpw.js";import"./PageHeader-Bx5JqCoI.js";function R({error:s,t:d,locale:o}){var v;if(!s)return null;const n=(s==null?void 0:s.code)||((v=s==null?void 0:s.error)==null?void 0:v.code),c=re(s,o)||d("Action failed.","فشل الإجراء.");return e.jsxs("div",{className:"card border-rose-200 bg-rose-50/60 px-3 py-2 text-sm",role:"alert",children:[e.jsx("div",{className:"font-medium text-rose-800",children:c}),n&&e.jsx("div",{className:"text-[11px] font-mono text-rose-600 mt-0.5",children:n})]})}const I=Y,je=s=>({low:s("Low","منخفض"),medium:s("Medium","متوسط"),high:s("High","مرتفع")});function be({open:s,onClose:d,id:o}){var $;const{t:n,locale:c}=J(),v=se(t=>t.can),T=je(n),f=ne(o),x=ae(),g=X(),N=te(),_=v("platform.onboarding.work"),[A,y]=k.useState(!1),[w,m]=k.useState(!1),[u,C]=k.useState("whatsapp"),[h,S]=k.useState(""),O=ie({status:"active",per_page:100},{enabled:s&&!!o&&_}),L=k.useMemo(()=>{var l;const t=xe(((l=O.data)==null?void 0:l.items)||[],{functionId:"signups",locale:c,t:n});return h&&!t.some(j=>j.value===h)?[{value:h,label:h,staff:null},...t.filter(j=>j.value!==""),t.find(j=>j.value==="")||{value:"",label:n("(Unassigned)","(غير معيّن)"),staff:null}]:t},[($=O.data)==null?void 0:$.items,c,n,h]),a=f.data;k.useEffect(()=>{a&&S(a.csm||"")},[a==null?void 0:a.id,a==null?void 0:a.csm,a]);const B=t=>{y(!1);const l=(t==null?void 0:t.data)??t;u==="email"&&(l==null?void 0:l.email_sent)!==!0?M.emit(D.TOAST,{tone:"warning",message_en:`Touchpoint logged, but the email was not sent (${(l==null?void 0:l.email_reason)||"unknown"}).`,message_ar:`تم تسجيل التواصل، لكن لم يُرسَل البريد (${(l==null?void 0:l.email_reason)||"غير معروف"}).`}):M.emit(D.TOAST,{tone:"success",message_en:u==="email"?"Touchpoint logged and email queued.":"Touchpoint logged.",message_ar:u==="email"?"تم تسجيل التواصل وإرسال البريد.":"تم تسجيل التواصل."})};return o?e.jsxs(le,{open:s,onClose:d,width:520,title:a?c==="ar"?a.business_ar||a.business_en:a.business_en||a.business_ar:"…",children:[a?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("header",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(q,{tone:a.risk==="high"?"danger":a.risk==="medium"?"warning":"success",dot:!0,children:T[a.risk]||a.risk}),e.jsx("span",{className:"text-sm font-semibold flex-1 truncate",children:c==="ar"?a.business_ar:a.business_en}),a.stuck_days>0&&e.jsx(q,{tone:"warning",children:n(`Stuck ${a.stuck_days}d`,`متوقف ${a.stuck_days} يوم`)})]}),e.jsxs("div",{className:"card p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-widest rtl:tracking-normal text-ink-600 mb-1",children:n("Funnel","المسار")}),e.jsx("ol",{className:"flex flex-col gap-1.5 mt-1",children:(a.steps||[]).map(t=>{const l=I[t.id]||{en:t.id,ar:t.id};return e.jsxs("li",{"aria-current":t.current?"step":void 0,className:V("flex items-center gap-3 px-3 py-2 rounded",t.current?"bg-ink-900 text-white":t.done?"bg-emerald-50/50 text-emerald-700":"text-ink-600"),children:[e.jsx("span",{"aria-hidden":!0,className:V("w-5 h-5 grid place-items-center rounded-full text-[11px] font-semibold",t.current?"bg-white text-ink-900":t.done?"bg-emerald-500 text-white":"bg-ink-200 text-ink-600"),children:t.done?"✓":t.idx}),t.done&&e.jsxs("span",{className:"sr-only",children:[n("Done","مكتمل"),": "]}),e.jsx("span",{className:"flex-1 text-sm",children:c==="ar"?l.ar:l.en}),t.current&&a.eta&&e.jsxs("span",{className:"text-xs opacity-80",children:[n("ETA","الموعد المتوقع")," · ",G(a.eta,n,c)]})]},t.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsx(F,{label:n("Owner","المالك"),value:a.owner}),e.jsx(F,{label:n("ETA","الموعد المتوقع"),value:G(a.eta,n,c)||"-"}),e.jsx(F,{label:n("Stuck days","أيام التعثر"),value:a.stuck_days>0?`${p(a.stuck_days,c)} ${n("days","يوم")}`:n("Moving","يتقدم")})]}),_&&e.jsxs("div",{className:"card p-3 flex flex-col gap-2",children:[e.jsx(H,{label:n("CSM owner","مدير نجاح العميل"),value:h,onChange:t=>S(t.target.value),options:L,hint:n("Onboarding team members from signups & onboarding coverage.","أعضاء فريق التهيئة من تغطية التسجيل والتهيئة.")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{variant:"secondary",size:"sm",loading:N.isPending,disabled:h===(a.csm||""),onClick:()=>N.mutate({id:a.id,csm:h}),children:n("Save CSM","حفظ مدير النجاح")}),a.csm&&e.jsx(b,{variant:"ghost",size:"sm",onClick:()=>N.mutate({id:a.id,csm:""}),loading:N.isPending,children:n("Clear","إزالة")})]}),e.jsx(R,{error:N.error,t:n,locale:c})]}),!_&&e.jsx(F,{label:n("CSM","مدير النجاح"),value:a.csm||"-"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[e.jsx(b,{variant:"secondary",onClick:()=>y(!0),children:n("Nudge","تنبيه")}),e.jsx(b,{variant:"primary",onClick:()=>{x.reset(),m(!0)},disabled:a.current_step==="go_live",children:n("Advance step","تقدّم خطوة")})]}),e.jsx(R,{error:g.error,t:n,locale:c})]}):e.jsx("div",{className:"p-12 text-center text-ink-600 text-sm",children:n("Loading…","جاري التحميل…")}),a&&(()=>{const t=(a.steps||[]).findIndex(i=>i.current),l=t>=0?(a.steps||[])[t+1]:null,j=l?I[l.id]?c==="ar"?I[l.id].ar:I[l.id].en:l.id:null;return e.jsx(U,{open:w,onClose:()=>m(!1),size:"sm",title:n("Advance step","تقدّم خطوة"),footer:e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"secondary",onClick:()=>m(!1),children:n("Cancel","إلغاء")}),e.jsx(b,{variant:"primary",loading:x.isPending,onClick:()=>x.mutate({id:a.id},{onSuccess:()=>m(!1)}),children:n("Advance","تقدّم")})]}),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("p",{className:"text-sm text-ink-700 leading-relaxed",children:j?n(`Advance this tenant to "${j}"? This resets the stuck counter and is recorded in the audit log. It cannot be undone.`,`تقديم هذه المنشأة إلى "${j}"؟ يعيد ضبط عداد التعثر ويُسجَّل في سجل التدقيق. لا يمكن التراجع.`):n("Advance this tenant to the next step? This resets the stuck counter and is recorded in the audit log. It cannot be undone.","تقديم هذه المنشأة إلى الخطوة التالية؟ يعيد ضبط عداد التعثر ويُسجَّل في سجل التدقيق. لا يمكن التراجع.")}),e.jsx(R,{error:x.error,t:n,locale:c})]})})})(),e.jsx(U,{open:A,onClose:()=>y(!1),size:"sm",title:n("Nudge tenant","تنبيه المنشأة"),footer:e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"secondary",onClick:()=>y(!1),children:n("Cancel","إلغاء")}),e.jsx(b,{variant:"primary",onClick:()=>g.mutate({id:a.id,channel:u},{onSuccess:B}),loading:g.isPending,children:n("Send","إرسال")})]}),children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(H,{label:n("Channel","القناة"),value:u,onChange:t=>C(t.target.value),options:[{value:"whatsapp",label:n("WhatsApp","واتساب")},{value:"phone",label:n("Phone call","مكالمة هاتفية")},{value:"email",label:n("Email","البريد الإلكتروني")},{value:"sms",label:"SMS"}]}),e.jsx("p",{className:"text-[11px] text-ink-600 leading-relaxed",children:Z(n,u)})]})})]}):null}function F({label:s,value:d}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide rtl:tracking-normal text-ink-600",children:s}
1),e.jsx("div",{className:"font-medium mt-0.5",children:d||"-"})]})}const ke={low:"success",medium:"warning",high:"danger"},K=Y,ve=["all","low","medium","high"],Q={high:2,medium:1,low:0},Ne=s=>({all:s("All","الكل"),low:s("Low","منخفض"),medium:s("Medium","متوسط"),high:s("High","مرتفع")});function Ie(){var t,l,j;const{t:s,locale:d,apiError:o}=J(),[n,c]=ce(),[v,T]=k.useState(()=>{const i=n.get("risk");return ve.includes(i)?i:"all"}),[f,x]=k.useState(null),[g,N]=k.useState("whatsapp"),[_,A]=k.useState(()=>n.get("open")),{closeDrawer:y}=fe(_,A),w=i=>{T(i);const r=new URLSearchParams(n);i==="all"?r.delete("risk"):r.set("risk",i),c(r,{replace:!0})},m=i=>{A(String(i));const r=new URLSearchParams(n);r.set("open",String(i)),c(r,{replace:!0})},u=de({risk:v}),C=X(),h=((t=u.data)==null?void 0:t.items)||[],S=((l=u.data)==null?void 0:l.kpis)||{},O=((j=u.data)==null?void 0:j.steps)||[],L=Ne(s),a=v!=="all",B=k.useMemo(()=>[...h].sort((i,r)=>(Q[r.risk]??0)-(Q[i.risk]??0)||(r.stuck_days??0)-(i.stuck_days??0)),[h]),$=i=>{x(null);const r=(i==null?void 0:i.data)??i;g==="email"&&(r==null?void 0:r.email_sent)!==!0?M.emit(D.TOAST,{tone:"warning",message_en:`Touchpoint logged, but the email was not sent (${(r==null?void 0:r.email_reason)||"unknown"}).`,message_ar:`تم تسجيل التواصل، لكن لم يُرسَل البريد (${(r==null?void 0:r.email_reason)||"غير معروف"}).`}):M.emit(D.TOAST,{tone:"success",message_en:g==="email"?"Touchpoint logged and email queued.":"Touchpoint logged.",message_ar:g==="email"?"تم تسجيل التواصل وإرسال البريد.":"تم تسجيل التواصل."})};return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(he,{title:s("Onboarding","تهيئة المنشآت"),subtitle:s("Track new tenants moving through activation · spot stuck accounts before churn.","تتبع المنشآت الجديدة خلال التفعيل · رصد الحسابات المتعثرة قبل الفقد."),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(W,{to:"/app/platform/tenants/new",className:"inline-flex items-center justify-center gap-2 rounded-lg font-medium transition focus:outline-none focus:ring-2 bg-ink-900 text-white hover:bg-ink-600 focus:ring-ink-900/30 px-4 py-2 text-sm",children:[e.jsx(z,{name:"plus",size:14}),s("New tenant","منشأة جديدة")]}),e.jsxs(W,{to:"/app/platform/signups",className:"inline-flex items-center gap-1.5 text-sm font-medium px-3 py-2 rounded-lg border border-ink-200 hover:bg-ink-50",children:[e.jsx(z,{name:"clipboard-list",size:14}),s("Signup queue","قائمة طلبات التسجيل")]})]})}),u.isLoading?e.jsx(pe,{}):e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(P,{label:s("At risk","يحتاج متابعة"),value:p(S.at_risk||0,d),tone:(S.at_risk||0)>0?"text-rose-600":void 0}),e.jsx(P,{label:s("Stuck (≥3d)","متعثر (≥3 أيام)"),value:p(S.stuck||0,d),tone:(S.stuck||0)>0?"text-amber-600":void 0}),e.jsx(P,{label:s("In progress","قيد التنفيذ"),value:p(S.total||0,d)}),e.jsx(P,{label:s("Avg steps done","متوسط الخطوات"),value:p(S.avg_steps||0,d),hint:O.length?`${s("of","من")} ${p(O.length,d)} ${s("steps","خطوات")}`:void 0})]}),e.jsxs("div",{className:"card p-3 flex flex-wrap gap-3 items-center",children:[e.jsx(ge,{label:s("Risk:","الخطر:"),value:v,options:["all","low","medium","high"],onChange:w,labelFor:i=>L[i]}),e.jsx("span",{className:"flex-1"}),e.jsxs("span",{className:"text-xs text-ink-600",children:[p(h.length,d)," ",h.length===1?s("account","حساب"):s("accounts","حسابات")]})]}),u.isError&&e.jsx(oe,{error:u.error,onRetry:u.refetch}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:u.isLoading?Array.from({length:4}).map((i,r)=>e.jsxs("div",{className:"card p-5 flex flex-col gap-3 animate-pulse",children:[e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5 flex-1",children:[e.jsx("div",{className:"h-4 w-40 bg-ink-100 rounded"}),e.jsx("div",{className:"h-3 w-28 bg-ink-100 rounded"})]}),e.jsx("div",{className:"h-5 w-14 bg-ink-100 rounded-full"})]}),e.jsx("div",{className:"h-1.5 w-full bg-ink-100 rounded-full"}),e.jsx("div",{className:"h-3 w-32 bg-ink-100 rounded"}),e.jsx("div",{className:"flex gap-1",children:Array.from({length:8}).map((we,ee)=>e.jsx("div",{className:"h-1.5 flex-1 bg-ink-100 rounded-full"},ee))})]},r)):h.length===0?e.jsx("div",{className:"col-span-full",children:e.jsx(me,{title:a?s("No accounts match","لا توجد حسابات مطابقة"):s("No onboarding accounts","لا توجد حسابات قيد الإعداد"),body:a?s("Try clearing the risk filter.","امسح تصفية الخطر."):s("Accounts appear here after signup promotion.","تظهر الحسابات هنا بعد ترقية التسجيل."),cta:a?e.jsx(b,{variant:"secondary",onClick:()=>w("all"),children:s("Clear filter","مسح عامل التصفية")}):null})}):B.map(i=>e.jsx(_e,{o:i,steps:O,locale:d,t:s,risk:L,onOpen:()=>m(i.id),onNudge:()=>{x(i),N("whatsapp")}},i.id))}),e.jsx(be,{open:!!_,id:_,onClose:y}),e.jsx(U,{open:!!f,onClose:()=>x(null),title:s("Log a touchpoint","تسجيل تواصل"),size:"sm",footer:e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"ghost",onClick:()=>x(null),children:s("Cancel","إلغاء")}),e.jsx(b,{loading:C.isPending,onClick:()=>C.mutate({id:f.id,channel:g},{onSuccess:$}),children:g==="email"?s("Log & email","تسجيل وإرسال"):s("Log contact","تسجيل التواصل")})]}),children:f&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"rounded-lg bg-ink-50 border border-ink-100 px-3 py-2.5",children:[e.jsx("div",{className:"text-sm font-semibold text-ink-900",children:d==="ar"?f.business_ar:f.business_en}),e.jsx("div",{className:"text-xs text-ink-600 mt-0.5",children:f.owner})]}),e.jsx(H,{label:s("Channel used","القناة المستخدمة"),value:g,onChange:i=>N(i.target.value),options:[{value:"whatsapp",label:E(s).whatsapp},{value:"phone",label:E(s).phone},{value:"email",label:E(s).email},{value:"sms",label:E(s).sms}]}),e.jsx("p",{className:"text-[11px] text-ink-600 leading-relaxed",children:Z(s,g)}),C.isError&&e.jsx("p",{role:"alert",className:"text-[11px] text-rose-700",children:o(C.error)||s("Could not log the touchpoint.","تعذّر تسجيل التواصل.")})]})})]})}const _e=({o:s,steps:d,locale:o,t:n,risk:c,onNudge:v,onOpen:T})=>{const f=s.completed.length,x=d.length,g=x?Math.round(f/x*100):0,N=s.stuck_days>=3,_=o==="ar"?s.business_ar||s.business_en:s.business_en||s.business_ar,A=d.indexOf(s.current_step),y=K[s.current_step]?o==="ar"?K[s.current_step].ar:K[s.current_step].en:s.current_step,w=s.last_nudge_channel?E(n)[s.last_nudge_channel]||s.last_nudge_channel:null;return e.jsxs("div",{role:"button",tabIndex:0,"aria-label":_,className:"card p-5 cursor-pointer hover:border-ink-300 transition focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ink-300",onClick:T,onKeyDown:m=>{m.target===m.currentTarget&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),T())},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-display font-semibold",children:_}),e.jsxs("div",{className:"text-xs text-ink-600 mt-0.5 flex flex-wrap gap-x-2",children:[e.jsxs("span",{children:[n("Owner","المالك"),": ",e.jsx("span",{className:"text-ink-600",children:s.owner})]}),s.csm&&e.jsxs("span",{children:[n("CSM","م. النجاح"),": ",e.jsx("span",{className:"text-ink-600",children:s.csm})]})]})]}
1),e.jsx(q,{tone:ke[s.risk],dot:!0,children:c[s.risk]||s.risk})]}),e.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[e.jsxs("span",{className:"text-xs text-ink-600",children:[p(f,o),"/",p(x,o)," ",f===1?n("step","خطوة"):n("steps","خطوات")]}),e.jsxs("span",{className:"text-xs font-mono text-ink-600",children:[g,"%"]})]}),e.jsx("div",{className:"h-1.5 bg-ink-100 rounded-full overflow-hidden mb-3","aria-hidden":!0,children:e.jsx("div",{className:"h-full bg-ink-900",style:{width:`${g}%`}})}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"text-xs text-ink-700 mb-1.5",children:A>=0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-ink-600",children:[n("Step","الخطوة")," ",p(A+1,o),"/",p(x,o),": "]}),e.jsx("span",{className:"font-medium",children:y})]}):e.jsx("span",{className:"font-medium",children:n("All steps complete","اكتملت كل الخطوات")})}),e.jsx("ol",{className:"flex gap-1","aria-hidden":!0,children:d.map(m=>{const u=s.completed.includes(m),C=m===s.current_step;return e.jsx("li",{className:"h-1.5 flex-1 rounded-full "+(u?"bg-emerald-500":C?"bg-ink-900":"bg-ink-100")},m)})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-3 border-t border-ink-100",children:[e.jsxs("div",{className:"text-xs flex flex-wrap items-center gap-x-1.5 gap-y-1",children:[e.jsx("span",{className:N?"text-danger font-semibold":"text-ink-600",children:s.stuck_days===0?n("moving","يتقدم"):`${p(s.stuck_days,o)} ${s.stuck_days===1?n("day stuck","يوم متعثر"):n("days stuck","أيام متعثرة")}`}),e.jsx("span",{className:"text-ink-600",children:"·"}),e.jsxs("span",{className:"text-ink-600",children:[n("ETA","الموعد المتوقع"),": ",G(s.eta,n,o)||"-"]}),(s.nudge_count??0)>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-600",children:"·"}),e.jsxs("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-sky-50 text-sky-700",title:s.last_nudged_at?`${n("Last nudge","آخر تذكير")}: ${ue(s.last_nudged_at,o)}${w?` (${w})`:""}`:void 0,children:[e.jsx(z,{name:"send",size:12,className:"inline-block align-middle me-1"}),e.jsxs("span",{className:"sr-only",children:[n("Nudges sent","تذكيرات مرسلة"),": "]}),p(s.nudge_count,o),w?` · ${w}`:""]})]})]}),e.jsx(b,{size:"sm",variant:"secondary",leadingIcon:e.jsx(z,{name:"check",size:12}),onClick:m=>{m.stopPropagation(),v()},children:n("Mark contacted","سجل التواصل")})]})]})};export{Ie 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.