PageSourceSearch

https://shopsavvy.com/_next/static/chunks/pages/admin/watched-dedup-review-1a46eac187811cfb.js

js shopsavvy.com collected 2026-09-24 09:01:28 UTC 6,382 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3004],{21377:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/watched-dedup-review",function(){return a(66985)}])},66985:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return AdminWatchedDedupReviewPage}});var r=a(24246),n=a(27378),d=a(73977),s=a(14819);function AdminWatchedDedupReviewPage(){let{auth:e}=(0,d.XL)(),[t,a]=(0,n.useState)([]),[l,i]=(0,n.useState)(0),[c,o]=(0,n.useState)(!0),[u,x]=(0,n.useState)(null),[h,p]=(0,n.useState)(null),[g,m]=(0,n.useState)({}),y=(0,n.useCallback)(async()=>{if(null==e?void 0:e.currentUser){o(!0),x(null);try{let t=await e.currentUser.getIdToken(),r=await fetch("/api/admin/watched-dedup-review/list?limit=200",{headers:{Authorization:"Bearer ".concat(t)}});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error((null==e?void 0:e.error)||"HTTP ".concat(r.status))}let n=await r.json();a(n.rows||[]),i(n.totalPending||0)}catch(e){x((null==e?void 0:e.message)||"Failed to load review queue")}finally{o(!1)}}},[e]);(0,n.useEffect)(()=>{(null==e?void 0:e.currentUser)&&y()},[null==e?void 0:e.currentUser,y]);let b=(0,n.useCallback)(async t=>{if((null==e?void 0:e.currentUser)&&null===h&&confirm("Merge these products? This will create a new merged product and retarget every reference. The originals stay in the database.")){p(t);try{let r=await e.currentUser.getIdToken(),n=await fetch("/api/admin/watched-dedup-review/accept",{method:"POST",headers:{Authorization:"Bearer ".concat(r),"Content-Type":"application/json"},body:JSON.stringify({pk:t})}),d=await n.json().catch(()=>({}));if(!n.ok){m(e=>({...e,[t]:"Accept failed: ".concat((null==d?void 0:d.error)||n.status)}));return}m(e=>({...e,[t]:"Merged → ".concat(d.newProductPath)})),a(e=>e.filter(e=>e.pk!==t)),i(e=>Math.max(0,e-1))}catch(e){m(a=>({...a,[t]:"Accept error: ".concat((null==e?void 0:e.message)||"unknown")}))}finally{p(null)}}},[e,h]),v=(0,n.useCallback)(async t=>{if(!(null==e?void 0:e.currentUser)||null!==h)return;let r=prompt("Reject reason (optional):")||"";p(t);try{let n=await e.currentUser.getIdToken(),d=await fetch("/api/admin/watched-dedup-review/reject",{method:"POST",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"},body:JSON.stringify({pk:t,notes:r})}),s=await d.json().catch(()=>({}));if(!d.ok){m(e=>({...e,[t]:"Reject failed: ".concat((null==s?void 0:s.error)||d.status)}));return}m(e=>({...e,[t]:"Rejected"})),a(e=>e.filter(e=>e.pk!==t)),i(e=>Math.max(0,e-1))}catch(e){m(a=>({...a,[t]:"Reject error: ".concat((null==e?void 0:e.message)||"unknown")}))}finally{p(null)}},[e,h]);return(0,r.jsx)(s.B,{title:"Watched-Products Dedup Review",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:c?"Loading…":"".concat(t.length," shown \xb7 ").concat(l," pending total")}),(0,r.jsx)("button",{type:"button",onClick:y,disabled:c,className:"px-3 py-1 text-sm rounded-md bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50",children:"Reload"})]}),u&&(0,r.jsx)("div",{className:"p-3 rounded-md bg-red-50 dark:bg-red-900/30 text-red-700 dark:text-red-300 text-sm",children:u}),!c&&0===t.length&&!u&&(0,r.jsx)("div",{className:"p-6 rounded-md border border-dashed border-gray-300 dark:border-gray-700 text-center text-gray-500 dark:text-gray-400",children:"No pending pairs. Either the sweep has not produced medium/low cases recently, or every flagged pair has been triaged."}),(0,r.jsx)("div",{className:"space-y-3",children:t.map(e=>{var t,a;return(0,r.jsxs)("div",{className:"p-4 rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("span",{className:"px-2 py-0.5 text-xs rounded-full ".concat("medium"===e.confidence?"bg-yellow-100 text-yellow-800":"bg-orange-100 text-orange-800"),children:e.confidence}),(0,r.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[e.watch_count," watcher",1===e.watch_count?"":"s"," \xb7 ",new Date(e.time_created).toLocaleStr
1ing()]})]}),(0,r.jsx)("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:(null===(t=e.product)||void 0===t?void 0:t.title)||"(no title)"}),(0,r.jsxs)("div",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 break-all",children:[e.product_path," ",(null===(a=e.product)||void 0===a?void 0:a.ids)?(0,r.jsx)(ProductIds,{ids:e.product.ids}):null]}),(0,r.jsx)("div",{className:"mt-3 pl-4 border-l-2 border-gray-200 dark:border-gray-700 space-y-2",children:e.partners.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.title||"(no title)"}),(0,r.jsxs)("div",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 break-all",children:[e.path," ",e.ids?(0,r.jsx)(ProductIds,{ids:e.ids}):null]})]},e.path))}),e.reason&&(0,r.jsxs)("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400",children:["Reason: ",e.reason]}),e.sample_user_paths&&(0,r.jsxs)("div",{className:"mt-1 text-xs text-gray-500 dark:text-gray-500 truncate",children:["Sample users: ",e.sample_user_paths]}),g[e.pk]&&(0,r.jsx)("div",{className:"mt-2 text-xs text-gray-700 dark:text-gray-300",children:g[e.pk]}),(0,r.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>b(e.pk),disabled:null!==h,className:"px-3 py-1 text-sm rounded-md bg-emerald-600 text-white hover:bg-emerald-700 disabled:opacity-50",children:h===e.pk?"Merging…":"Accept (merge)"}),(0,r.jsx)("button",{type:"button",onClick:()=>v(e.pk),disabled:null!==h,className:"px-3 py-1 text-sm rounded-md bg-gray-200 dark:bg-gray-800 text-gray-800 dark:text-gray-200 hover:bg-gray-300 dark:hover:bg-gray-700 disabled:opacity-50",children:"Reject"})]})]},e.pk)})})]})})}function ProductIds(e){let{ids:t}=e,a=[];for(let e of["barcode","amazon","walmart","bestbuy","target"]){let r=null==t?void 0:t[e];"string"==typeof r&&r.length>0&&a.push("".concat(e,":").concat(r))}return 0===a.length?null:(0,r.jsxs)("span",{className:"text-gray-400",children:["\xb7 ",a.join(" \xb7 ")]})}}},function(e){e.O(0,[9894,9253,4819,9774,2888,179],function(){return e(e.s=21377)}),_N_E=e.O()}]);

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.