PageSourceSearch

https://platform.dalseen.sa/assets/PosMigrationPage-Dok_jBG3.js

js dalseen.sa collected 2026-10-09 23:46:40 UTC 13,929 bytes, 1 lines download raw bytes

1import{u as v,j as t,r as p,be as y,a5 as G,a6 as $,bQ as ee,b5 as te,I as V,L as E,B as se,E as C,Q as M,A as w,m as O}from"./index-mbu4rngo.js";import{P as ne}from"./PageHeader-Bx5JqCoI.js";import{I as re,a as ie}from"./ImportPreviewTable-D_zs7xJf.js";import{c as l}from"./catalogArTerms-yA_zlqxW.js";import{u as ae}from"./useCatalogAccess-BZMZf_IW.js";import"./ListPaginationBar-DZLdPGo3.js";import"./Pagination-D67TwaBd.js";const H={foodics:{en:"Foodics export",ar:"تصدير فودكس"},dalseen_legacy:{en:"Legacy DALSEEN",ar:"دال سين القديم"},erp:{en:"ERP export",ar:"تصدير ERP"},generic_pos:{en:"Generic POS CSV",ar:"CSV نقطة بيع عام"},unknown:{en:"Unknown format",ar:"صيغة غير معروفة"}};function oe({source:e,confidence:s}){const{t:o,locale:n}=v(),i=H[e]||H.unknown,c=s!=null?`${s}%`:"-";return t.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-indigo-200 bg-indigo-50 px-3 py-1 text-xs text-indigo-900","data-testid":"migration-source-badge",children:[t.jsx("span",{className:"font-medium",children:n==="ar"?i.ar:i.en}),t.jsxs("span",{className:"text-indigo-600",children:[o("match","تطابق"),": ",c]})]})}function le(e){return e>=85?"border-emerald-200 bg-emerald-50 text-emerald-900":e>=60?"border-amber-200 bg-amber-50 text-amber-900":"border-red-200 bg-red-50 text-red-900"}function ce({score:e,ready:s,blocking:o,review:n}){const{t:i}=v(),c=e??0;return t.jsxs("div",{className:`rounded-lg border px-4 py-3 text-sm ${le(c)}`,"data-testid":"migration-confidence-badge",children:[t.jsxs("p",{className:"font-semibold",children:[i("Migration confidence","ثقة الترحيل"),": ",c,"%",s?` · ${i("Ready","جاهز")}`:""]}),t.jsxs("p",{className:"mt-1 text-xs opacity-80",children:[o>0?i(`${o} blocking issue(s)`,`${o} مشكلة مانعة`):i("No blocking issues","لا مشاكل مانعة"),n>0?` · ${i(`${n} need review`,`${n} للمراجعة`)}`:""]})]})}function de({warnings:e=[]}){const{t:s,locale:o}=v(),n=e.filter(i=>i.code==="unsupported_field");return n.length?t.jsxs("section",{className:"rounded-lg border border-amber-200 bg-amber-50 p-4","data-testid":"unsupported-fields-panel",children:[t.jsx("h3",{className:"text-sm font-semibold text-amber-900",children:s("Unsupported from your old system","غير مدعوم من نظامك القديم")}),t.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-amber-800",children:n.map((i,c)=>t.jsx("li",{children:o==="ar"?i.message_ar:i.message_en},c))})]}):null}const me=["products","categories","taxes","inventory"];function pe({preview:e}){var c,d;const{t:s}=v(),[o,n]=p.useState("products");if(!(e!=null&&e.sections))return null;const i=e.sections;return t.jsxs("div",{"data-testid":"migration-preview-tabs",children:[t.jsx("div",{className:"mb-3 flex flex-wrap gap-2 border-b border-gray-200 pb-2",children:me.map(a=>t.jsx("button",{type:"button",onClick:()=>n(a),className:`rounded-md px-3 py-1 text-xs font-medium capitalize ${o===a?"bg-gray-900 text-white":"bg-gray-100 text-gray-700"}`,children:s(a,a==="products"?"منتجات":a==="categories"?"فئات":a==="taxes"?"ضرائب":"مخزون")},a))}),o==="products"&&t.jsx(re,{products:i.products,summary:e.summary}),o==="categories"&&t.jsx("ul",{className:"text-sm text-gray-700",children:(i.categories||[]).map(a=>t.jsx("li",{children:a.name},a.name))}),o==="taxes"&&t.jsx("ul",{className:"text-sm text-gray-700",children:(i.taxes||[]).map(a=>t.jsxs("li",{children:[s("Rate","نسبة")," ",a.tax_rate,"%: ",a.product_count," ",s("products","منتج")]},a.tax_rate))}),o==="inventory"&&t.jsxs("p",{className:"text-sm text-gray-600",children:[s("Rows with quantity","صفوف بكمية"),": ",((d=(c=i.inventory)==null?void 0:c[0])==null?void 0:d.rows_with_quantity)??0]})]})}const S={upload:e=>y.post("/migration-runs",e),get:e=>y.get(`/migration-runs/${e}`),approve:e=>y.post(`/migration-runs/${e}/approve`,{}),ask:(e,s)=>y.post(`/migration-runs/${e}/ask`,s),updateMapping:(e,s)=>y.patch(`/migration-runs/${e}/mapping`,s)},I={run:e=>["migration","run",e]};function ue(e,s={}){return ee({queryKey:I.run(e),queryFn:()=>S.get(e),enabled:!!e&&s.enabled!==!1,refetchInterval:o=>{var i;const n=(i=o.state.data)==null?void 0:i.job_state;return n==="queued"||n==="running"?2e3:!1}})}function xe(){const e=G();return $({mutationFn:s=>S.upload(s),onSuccess:s=>{s!=null&&s.id&&e.setQueryData(I.run(s.id),s)}})}function ge(){const e=G();return $({mutationFn:s=>S.approve(s),onSuccess:s=>{s!=null&&s.id&&e.setQueryData(I.run(s.id),s)}})}function fe(){return $({mutationFn:({id:e,message:s})=>S.ask(e,{message:s})})}const be=["upload","analyze","preview","approve"];function he({activeStep:e,t:s,embedded:o}){const n=i=>o?l(s,`migration_step_${i}`):{upload:s("Upload","رفع"),analyze:s("Analyze","تحليل"),preview:s("Preview","معاينة"),approve:s("Approve","موافقة")}[i];return t.jsx("ol",{className:"flex flex-wrap gap-2","aria-label":o?l(s,"tabMigration"):s("Migration progress","تقدّم الترحيل"),children:be.map((i,c)=>{const d=c<e,a=c===e;return t.jsxs("li",{className:O("inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium border",d&&"border-emerald-200 bg-emerald-50 text-emerald-800",a&&!
1d&&"border-gold-300 bg-gold-50 text-gold-900",!d&&!a&&"border-ink-200 bg-white text-ink-400"),"aria-current":a?"step":void 0,children:[t.jsx("span",{className:O("w-5 h-5 rounded-full grid place-items-center text-[10px] font-bold",d?"bg-emerald-600 text-white":a?"bg-gold-500 text-white":"bg-ink-100 text-ink-500"),children:d?"✓":c+1}),n(i)]},i)})})}function _e(e){return e?e.job_state==="complete"||e.approval_state==="approved"?3:e.preview_state==="ready"||e.preview?2:(e.parsing_state==="complete"||e.validation_state,1):0}function je(e){return e?["queued","running"].includes(e.job_state)||e.parsing_state==="running"||e.validation_state==="running"||e.preview_state==="running":!1}function Ae(){const{t:e,locale:s}=v(),n=te().pathname.includes("/merchandise/"),i=ae(),c=n?i.showImportTools:!0,d=i.canImport,a=p.useRef(null),[u,T]=p.useState(null),[h,L]=p.useState(""),[_,R]=p.useState(null),[F,N]=p.useState(null),j=xe(),g=ge(),A=fe(),b=ue(u),r=b.data,k=r==null?void 0:r.preview,q=(r==null?void 0:r.conflicts)??(k==null?void 0:k.conflicts)??[],W=((r==null?void 0:r.blocking_issues_count)??0)>0,B=je(r),K=_e(r),f=m=>n?l(e,m):null,x=p.useMemo(()=>({kicker:f("migration_kicker")??e("MIGRATION","الترحيل"),title:f("migration_title")??e("Move from another POS","الانتقال من نقطة بيع أخرى"),subtitle:f("migration_subtitle")??e("Upload a Foodics, legacy DALSEEN, or POS export. We detect the format, map fields, and show a preview before anything is imported.","ارفع تصدير فودكس أو دال سين القديم أو نقطة بيع. نكتشف الصيغة ونربط الحقول ونعرض معاينة قبل أي استيراد."),csvLink:f("migration_simple_csv_link")??e("Simple CSV import","استيراد CSV بسيط"),uploadHint:f("migration_upload_hint")??e("Foodics, legacy DALSEEN, ERP, or generic product CSV.","تصدير فودكس أو دال سين أو ERP أو CSV منتجات عام."),uploadBtn:f("migration_upload_btn")??e("Upload export","رفع التصدير")}),[f,e]),J=p.useCallback(async m=>{var D;const Q=(D=m.target.files)==null?void 0:D[0];if(!Q)return;N(null);const U=new FormData;U.append("file",Q);try{const P=await j.mutateAsync(U);T(P.id),R(null)}catch(P){N(P)}},[j]),X=p.useCallback(async()=>{if(u)try{await g.mutateAsync(u),b.refetch()}catch{}},[u,g,b]),Y=p.useCallback(async()=>{if(!u||!h.trim())return;const m=await A.mutateAsync({id:u,message:h.trim()});R(m)},[u,h,A]),Z=()=>{T(null),R(null),L(""),N(null),a.current&&(a.current.value="")},z=_?s==="ar"?_.reply_ar||_.reply_en:_.reply_en||_.reply_ar:null;return n&&!i.hasRetail?t.jsxs("div",{className:"card p-8 text-center max-w-lg mx-auto flex flex-col items-center gap-3",children:[t.jsx(V,{name:"spark",size:28,className:"text-ink-300"}),t.jsx("p",{className:"text-sm text-ink-600",children:l(e,"migration_retail_only_hint")}),t.jsx(E,{to:"../import",className:"text-sm font-semibold text-ink-900 hover:underline",children:l(e,"migration_simple_csv_link")})]}):t.jsxs("div",{className:"flex flex-col gap-5","data-testid":"pos-migration-page",children:[!n&&t.jsx(ne,{kicker:x.kicker,title:x.title,subtitle:x.subtitle}),n&&t.jsxs("section",{className:"card p-4 bg-violet-50/40 border-violet-100",children:[t.jsx(se,{tone:"gold",children:x.kicker}),t.jsx("h2",{className:"text-lg font-display font-semibold mt-2",children:x.title}),t.jsx("p",{className:"text-sm text-ink-600 mt-1 max-w-2xl leading-relaxed",children:x.subtitle})]}),n&&!d&&t.jsx("div",{className:"card p-3 border border-ink-200 bg-ink-50 text-sm text-ink-600",children:l(e,"migration_import_perm_hint")}),t.jsx("p",{className:"text-sm text-ink-500",children:t.jsx(E,{to:"../import",className:"text-dine-strong font-medium hover:underline",children:x.csvLink})}),(F||j.isError)&&t.jsx(C,{error:F||j.error,onRetry:()=>N(null)}),g.isError&&t.jsx(C,{error:g.error,onRetry:()=>g.reset()}),b.isError&&t.jsx(C,{error:b.error,onRetry:b.refetch}),(u||r)&&t.jsx(he,{activeStep:K,t:e,embedded:n}),!u&&c&&d&&t.jsxs("section",{className:"card p-8 border-2 border-dashed border-ink-200 text-center",children:[t.jsx("input",{ref:a,type:"file",accept:".csv,.tsv,.txt",className:"hidden",onChange:J}),t.jsx("div",{className:"w-12 h-12 rounded-xl bg-ink-100 text-ink-500 grid place-items-center mx-auto mb-4",children:t.jsx(V,{name:"upload",size:22})}),t.jsx("p",{className:"mb-4 text-sm text-ink-600 max-w-md mx-auto",children:x.uploadHint}),t.jsx(M,{permission:"catalog.products.import",children:t.jsx(w,{onClick:()=>{var m;return(m=a.current)==null?void 0:m.click()},loading:j.isPending,"data-testid":"migration-upload-btn",children:x.uploadBtn})})]}),r&&B&&t.jsxs("section",{className:"card p-6 text-center","data-testid":"migration-processing",children:[t.jsxs("div",{className:"inline-flex items-center gap-2 text-sm text-ink-600",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-gold-400 animate-pulse"}),n?l(e,"migration_processing"):e("Analyzing export…","جاري تحليل التصدير…")]}),t.jsx("p",{className:"text-xs text-ink-400 mt-2 max-w-md mx-auto",children:n?l(e,"migration_processing_hint"):e("Detecting source system and building preview. This usually takes a few seconds.","جاري اكتشاف نظام المصدر وبناء المعاينة. عادة يستغرق ذلك ثواني.")})]}),r&&!B&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(oe,{source:r.source_system,confidence:r.source_confidence}),t.jsx(ce,{score:r.overall_confidence,ready:r.ready_for_import,blocking:r.blocking_issues_count,review:r.manual_review_count}),r.original_filename&&t.jsx("span",{className:"text-xs text-ink-400 font-mono truncate max-w-[200px]",title:r.original_filename,children:r.original_filename})]}),t.jsx(de,{warnings:r.warnings}),q.length>0&&t.jsxs("section",{className:"card p-4",children:[t.jsx("h2",{className:"mb-3 text-sm font-semibold text-ink-900",children:n?l(e,"migration_conflicts"):e("Conflicts","تعارضات")}),t.jsx(ie,{issues:q})]}),k&&t.jsxs("section",{className:"card p-4",children:[t.jsx("h2",{className:"mb-3 text-sm font-semibold text-ink-900",children:n?l(e,"migration_preview"):e("Migration preview","معاينة الترحيل")}),t.jsx(pe,{preview:k})]}),r.job_state==="complete"&&r.import_result&&t.jsx("div",{className:"card p-4 border border-emerald-200 bg-emerald-50/80","data-testid":"migration-complete-summary",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold text-emerald-900",children:n?l(e,"migration_approved"):e("Migration complete","اكتمل الترحيل")}),t.jsx("p",{className:"text-sm text-emerald-800 mt-1",children:e(`Imported ${r.import_result.imported_entities} product row(s). Skipped ${r.import_result.skipped_entities}.`,`تم استيراد ${r.import_result.imported_entities} صف منتج. تخطي ${r.import_result.skipped_entities}.`)})]}),n&&t.jsx(E,{to:"../products",className:"inline-flex items-center justify-center gap-2 rounded-lg font-medium transition px-3 py-1.5 text-xs bg-ink-900 text-white hover:bg-ink-600",children:l(e,"migration_view_products")})]})}),t.jsxs("div",{className:"flex flex-wrap gap-3",children:[t.jsx(M,{permission:"catalog.products.import",children:t.jsx(w,{variant:"primary",disabled:W||r.approval_state==="approved"||g.isPending||!r.ready_for_import,loading:g.isPending,onClick:X,"data-testid":"migration-approve-btn",children:n?l(e,"migration_approve"):e("Approve migration","موافقة على الترحيل")})}),t.jsx(M,{permission:"catalog.products.import",children:t.jsx(w,{variant:"secondary",onClick:Z,children:n?l(e,"migration_reupload"):e("Re-upload","إعادة الرفع")})})]}),t.jsxs("section",{className:"card p-4 bg-ink-50/50",children:[t.jsx("h2",{className:"mb-2 text-sm font-semibold text-ink-900",children:n?l(e,"migration_ask_title"):e("Ask about this migration","اسأل عن هذا الترحيل")}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[t.jsx("input",{type:"text",className:"flex-1 rounded-lg border border-ink-200 px-3 py-2 text-sm bg-white",placeholder:n?l(e,"migration_ask_placeholder"):e("Why is confidence low?","لماذا الثقة منخفضة؟"),value:h,onChange:m=>L(m.target.value),"data-testid":"migration-ask-input"}),t.jsx(w,{size:"sm",onClick:Y,loading:A.isPending,disabled:!h.trim(),children:n?l(e,"migration_ask_btn"):e("Ask","اسأل")})]}),z&&t.jsx("p",{className:"mt-3 text-sm text-ink-700 leading-relaxed","data-testid":"migration-ask-reply",children:z})]})]})]})}export{Ae 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.