PageSourceSearch

https://vault22.com/_next/static/chunks/pages/admin/customer-support/closed-profiles-ec88cee4bbd8ef79.js

js vault22.com collected 2026-09-24 13:40:33 UTC 7,867 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3500],{13884:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/customer-support/closed-profiles",function(){return s(29176)}])},29176:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>u});var a=s(37876),r=s(14232),l=s(48230),c=s.n(l),d=s(37497),n=s(52042),o=s(53403);let i=[{value:7,label:"last 7 days"},{value:30,label:"last 30 days"},{value:90,label:"last 90 days"},{value:365,label:"last year"}];function x(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{dateStyle:"medium"})}catch(t){return e}}function u(){let{idToken:e}=(0,n.bn)(),[t,s]=(0,r.useState)([]),[l,u]=(0,r.useState)([]),[p,m]=(0,r.useState)(!1),[h,y]=(0,r.useState)(!1),[b,g]=(0,r.useState)(null),[f,j]=(0,r.useState)(null),[v,N]=(0,r.useState)(""),[w,k]=(0,r.useState)(""),[S,_]=(0,r.useState)(90),C=async()=>{m(!0),j(null);try{let e=await o.KD.listClosedProfiles({reason:v||void 0,provider:w||void 0,sinceDays:S});e.success&&e.data?s(e.data.profiles||[]):j(e.error||"Failed to load closed profiles")}catch(e){j((null==e?void 0:e.message)||"Failed to load closed profiles")}finally{m(!1)}};(0,r.useEffect)(()=>{e&&(C(),(async()=>{try{let e=await o.KD.listMacros("closed_profile");e.success&&e.data&&u(e.data.macros||[])}catch(e){}})())},[e,v,w,S]);let A=(0,r.useMemo)(()=>{let e=new Set;return t.forEach(t=>{t.closedReason&&e.add(t.closedReason)}),Array.from(e).sort()},[t]),I=(0,r.useMemo)(()=>{let e=new Set;return t.forEach(t=>{t.lastKnownBrokenProvider&&e.add(t.lastKnownBrokenProvider)}),Array.from(e).sort()},[t]),O=async()=>{y(!0),g(null);try{let t=await fetch("".concat("https://saasport.briteblue.co.za","/v1/customer-support/closed-profiles/scan?limit=100"),{method:"POST",headers:{Authorization:"Bearer ".concat(e)}}),s=await t.json();s.success?(g("Scanned Zendesk — touched ".concat(s.touched," profile rows.")),await C()):g("Scan failed: ".concat(s.error||t.status))}catch(e){g("Scan threw: ".concat((null==e?void 0:e.message)||"unknown error"))}finally{y(!1)}},P=async e=>{if(window.confirm("Mark ".concat(e," as opted-out? No more outreach will be sent.")))try{(await o.KD.markOutreachOptedOut(e)).success&&await C()}catch(e){}};return(0,a.jsx)(d.A,{children:(0,a.jsxs)("div",{className:"p-6 max-w-7xl mx-auto space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-xl font-semibold text-gray-900",children:"Closed profiles"}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:'Customers who closed their Vault22 profile (Zendesk "Customer Closed Profile" auto-tickets). Send the matching closed-profile macro or mark opted-out.'})]}),(0,a.jsx)("button",{type:"button",onClick:O,disabled:h,className:"px-3 py-1.5 text-sm rounded font-medium ".concat(h?"bg-gray-300 text-gray-600":"bg-blue-600 text-white hover:bg-blue-700"),"data-testid":"cs-closed-profiles-scan",children:h?"Scanning Zendesk…":"Re-scan Zendesk"})]}),b&&(0,a.jsx)("div",{className:"bg-blue-50 border border-blue-200 rounded p-2 text-sm text-blue-800",children:b}),f&&(0,a.jsx)("div",{className:"bg-red-50 border border-red-200 rounded p-2 text-sm text-red-800",children:f}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 items-end bg-white border border-gray-200 rounded-lg p-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-[11px] uppercase tracking-wide text-gray-500 mb-1",children:"Closure reason"}),(0,a.jsxs)("select",{value:v,onChange:e=>N(e.target.value),className:"border border-gray-300 rounded px-2 py-1 text-sm",children:[(0,a.jsx)("option",{value:"",children:"All reasons"}),A.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-[11px] uppercase tracking-wide text-gray-500 mb-1",children:"Last broken provider"}),(0,a.jsxs)("select",{value:w,onChange:e=>k(e.target.value),className:"border border-gray-300 rounded px-2 py-1 text-sm",children:[(0,a.jsx)("option",{value:"",children:"All providers"}),I.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-[11px] uppercase tracking-wide text-gray-500 mb-1",children:"Time window"}),(0,a.jsx)("select",{value:S,onChange:e=>_(parseInt(e.target.value,10)),className:"border border-gray-300 rounded px-2 py-1 text-sm",children:i.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,a.jsxs)("div",{className:"ml-auto text-xs text-gray-500",children:[p?"Loa
1ding…":"".concat(t.length," profiles")," \xb7 ",l.length," closed-profile macros"]})]}),(0,a.jsx)("div",{className:"bg-white border border-gray-200 rounded-lg overflow-hidden",children:(0,a.jsxs)("table",{className:"w-full text-sm","data-testid":"cs-closed-profiles-table",children:[(0,a.jsx)("thead",{className:"bg-gray-50 text-[11px] uppercase tracking-wide text-gray-500",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-3 py-2 text-left",children:"Customer"}),(0,a.jsx)("th",{className:"px-3 py-2 text-left",children:"Closed"}),(0,a.jsx)("th",{className:"px-3 py-2 text-left",children:"Reason"}),(0,a.jsx)("th",{className:"px-3 py-2 text-left",children:"Broken provider"}),(0,a.jsx)("th",{className:"px-3 py-2 text-left",children:"Outreach"}),(0,a.jsx)("th",{className:"px-3 py-2 text-left",children:"Tickets"})]})}),(0,a.jsxs)("tbody",{className:"divide-y divide-gray-100",children:[!p&&0===t.length&&(0,a.jsx)("tr",{children:(0,a.jsx)("td",{colSpan:6,className:"px-3 py-10 text-center text-sm text-gray-500",children:'No closed profiles in this window. Try "Re-scan Zendesk" to refresh.'})}),t.map(e=>{var t;let s="zd:".concat((null==(t=e.zendeskTicketIds)?void 0:t[0])||e.customerId);return(0,a.jsxs)("tr",{"data-testid":"cs-closed-profile-row-".concat(s),children:[(0,a.jsxs)("td",{className:"px-3 py-2 align-top",children:[(0,a.jsx)("div",{className:"text-gray-900",children:e.name||"(no name)"}),(0,a.jsx)("div",{className:"text-[11px] text-gray-500",children:e.email||"(no email)"}),e.customerId&&(0,a.jsxs)("div",{className:"text-[10px] text-gray-400",children:["cid: ",(0,a.jsx)("code",{children:e.customerId})]})]}),(0,a.jsx)("td",{className:"px-3 py-2 align-top text-xs text-gray-700",children:x(e.closedAt)}),(0,a.jsx)("td",{className:"px-3 py-2 align-top text-xs text-gray-700",children:e.closedReason||"—"}),(0,a.jsx)("td",{className:"px-3 py-2 align-top text-xs",children:e.lastKnownBrokenProvider?(0,a.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded bg-red-50 text-red-800",children:e.lastKnownBrokenProvider}):(0,a.jsx)("span",{className:"text-gray-400",children:"—"})}),(0,a.jsxs)("td",{className:"px-3 py-2 align-top",children:[(0,a.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ".concat(function(e){switch(e){case"sent":return"bg-emerald-100 text-emerald-800";case"opted_out":return"bg-gray-200 text-gray-700";case"no_contact":return"bg-amber-100 text-amber-800";default:return"bg-blue-50 text-blue-800"}}(e.outreachStatus)),children:e.outreachStatus}),e.lastOutreachAt&&(0,a.jsxs)("div",{className:"text-[10px] text-gray-500 mt-0.5",children:["sent ",x(e.lastOutreachAt)]}),"opted_out"!==e.outreachStatus&&e.customerId&&(0,a.jsx)("button",{type:"button",onClick:()=>{var t;return P("zd:".concat((null==(t=e.zendeskTicketIds)?void 0:t[0])||e.customerId))},className:"mt-1 text-[10px] text-gray-500 hover:text-red-700",children:"opt-out"})]}),(0,a.jsx)("td",{className:"px-3 py-2 align-top text-xs",children:(e.zendeskTicketIds||[]).slice(0,3).map(e=>(0,a.jsxs)(c(),{href:"/admin/customer-support/tickets/".concat(e),className:"text-blue-600 block",children:["#",e]},e))})]},s)})]})]})})]})})}}},e=>{e.O(0,[7497,636,6593,8792],()=>e(e.s=13884)),_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.