1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[82285],{41933:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>n});var s=a(37876),r=a(14232),l=a(37497),d=a(53403);function i(e){if(!e)return"â";try{return new Date(e).toLocaleString()}catch(t){return e}}function n(){var e,t;let[a,n]=(0,r.useState)("active"),[c,o]=(0,r.useState)(null),[x,m]=(0,r.useState)(!0),[u,h]=(0,r.useState)(null),[b,p]=(0,r.useState)(""),[g,v]=(0,r.useState)(null),[y,f]=(0,r.useState)(!1),[j,N]=(0,r.useState)(""),[w,A]=(0,r.useState)(""),[C,k]=(0,r.useState)(!1),[S,P]=(0,r.useState)(null),[_,D]=(0,r.useState)(null),[F,E]=(0,r.useState)(""),[L,B]=(0,r.useState)(!1),[W,G]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(!W)return;let e=setTimeout(()=>G(null),4e3);return()=>clearTimeout(e)},[W]);let I=async()=>{try{m(!0),h(null);let e=await d.KD.listAlerts();e.success&&e.data?o(e.data):(o(null),h(e.error||"Failed to load alerts"))}catch(e){o(null),h((null==e?void 0:e.message)||"Failed to load alerts")}finally{m(!1)}};(0,r.useEffect)(()=>{I()},[]);let M=(0,r.useMemo)(()=>{var e;let t=null!=(e=null==c?void 0:c.serviceProviderAlerts.filter(e=>e.isActive))?e:[];if(!b.trim())return t;let a=b.trim().toLowerCase();return t.filter(e=>(e.serviceProviderName||"").toLowerCase().includes(a)||(e.activatedBy||"").toLowerCase().includes(a)||(e.message||"").toLowerCase().includes(a))},[c,b]),T=(0,r.useMemo)(()=>{var e;let t=null!=(e=null==c?void 0:c.providersWithoutAlert)?e:[];if(!b.trim())return t;let a=b.trim().toLowerCase();return t.filter(e=>(e.name||"").toLowerCase().includes(a))},[c,b]),z=()=>{var e,t;f(!0),v(null),N((null==c||null==(e=c.globalAlert)?void 0:e.header)||"Heads up"),A((null==c||null==(t=c.globalAlert)?void 0:t.message)||""),P(null)},H=()=>{v(null),f(!1),P(null)},K=async()=>{try{var e;k(!0),P(null);let t=await d.KD.activateAlert({isGlobal:y,serviceProviderId:null!=(e=null==g?void 0:g.id)?e:null,header:j,message:w});t.success?(G({type:"success",text:y?"Global banner published":"Banner for ".concat(null==g?void 0:g.name," published")}),H(),await I()):P(t.error||"Failed to save alert")}catch(e){P((null==e?void 0:e.message)||"Failed to save alert")}finally{k(!1)}},U=async()=>{if(_)try{B(!0);let e=await d.KD.deactivateAlert(_);e.success?(G({type:"success",text:"".concat(F," banner deactivated")}),D(null),await I()):G({type:"error",text:e.error||"Failed to deactivate"})}catch(e){G({type:"error",text:(null==e?void 0:e.message)||"Failed to deactivate"})}finally{B(!1)}};return(0,s.jsxs)(l.A,{children:[(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex flex-wrap justify-between items-start gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-2xl font-bold text-gray-900","data-testid":"alerts-title",children:"Alerts"}),(0,s.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:"Manage in-app banners shown to customers. Provider alerts appear for affected linked-account refreshes and before a new link starts, so check the customer-facing blast radius before publishing."})]}),(0,s.jsx)("button",{onClick:I,disabled:x,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50","data-testid":"alerts-refresh",children:x?"Loadingâ¦":"Refresh"})]}),(0,s.jsx)("div",{className:"border-b border-gray-200",children:(0,s.jsx)("nav",{className:"flex -mb-px overflow-x-auto",children:[{id:"active",label:"Active Service Provider Alerts (".concat(null!=(e=null==c?void 0:c.serviceProviderAlerts.filter(e=>e.isActive).length)?e:0,")")},{id:"inactive",label:"Providers Without Alert (".concat(null!=(t=null==c?void 0:c.providersWithoutAlert.length)?t:0,")")},{id:"global",label:"Global Banner ".concat((null==c?void 0:c.globalAlert)?"(live)":"")}].map(e=>(0,s.jsx)("button",{onClick:()=>n(e.id),className:"whitespace-nowrap py-3 px-5 text-sm font-medium border-b-2 ".concat(a===e.id?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"),"data-testid":"alerts-tab-".concat(e.id),children:e.label},e.id))})}),u&&(0,s.jsx)("div",{className:"bg-red-50 border border-red-200 text-red-700 rounded-md px-4 py-3 text-sm","data-testid":"alerts-error",children:u}),x&&(0,s.jsx)("div",{className:"flex justify-center py-12",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})}),!x&&c&&(0,s.jsxs)(s.Fragment,{children:["global"!==a&&(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{value:b,onChange:e=>p(e.target.value),placeholder:"active"===a?"Filter by provider / message / who activatedâ¦":"Filter providersâ¦",className:"form-input w-full max-w-sm px-3 py-2 border border-gray-300 rounded-md text-sm focus:ring-2 focus:ring-blue-500","data-testid":"alerts-search"}),b&&(0,s.jsx)("button",{onClick:()=>p(""),className:"text-xs text-gray-500 hover:text-gray-700",children:"Clear"})]}),"active"===a&&(0,s.jsx)("div",{className:"bg-white shadow rounded-lg overflow-hidden","data-testid":"alerts-active-table",children:(0,s.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,s.jsx)("thead",{className:"bg-gray-50",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase",children:"Provider"}),(0,s.jsx)("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase",children:"Header"}),(0,s.jsx)("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase",children:"Message"}),(0,s.jsx)("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase",children:"Activated By"}),(0,s.jsx)("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase",children:"Active Since"}),(0,s.jsx)("th",{className:"px-4 py-2 text-right text-xs font-medium text-gray-500 uppercase",children:"Actions"})]})}),(0,s.jsxs)("tbody",{className:"bg-white divide-y divide-gray-100",children:[0===M.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:6,className:"px-4 py-6 text-center text-sm text-gray-500",children:"No active service-provider alerts"})}),M.map(e=>(0,s.jsxs)("tr",{className:"hover:bg-gray-50","data-testid":"alerts-row-".concat(e.serviceProviderName),children:[(0,s.jsx)("td",{className:"px-4 py-2 text-sm font-medium text-gray-900",children:e.serviceProviderName||"â"}),(0,s.jsx)("td",{className:"px-4 py-2 text-sm text-gray-700",children:e.header}),(0,s.jsx)("td",{className:"px-4 py-2 text-xs text-gray-500 max-w-xs truncate",title:e.message,children:e.message}),(0,s.jsx)("td",{className:"px-4 py-2 text-xs text-gray-500",children:e.activatedBy||"â"}),(0,s.jsx)("td",{className:"px-4 py-2 text-xs text-gray-500",children:i(e.activatedDate)}),(0,s.jsx)("td",{className:"px-4 py-2 text-right",children:(0,s.jsx)("button",{onClick:()=>{D(e.id),E(e.serviceProviderName||"Alert")},className:"px-2 py-1 text-xs font-medium text-red-700 bg-red-50 rounded-md hover:bg-red-100","data-testid":"alerts-deactivate-".concat(e.serviceProviderName),children:"Deactivate"})})]},e.id))]})]})}),"inactive"===a&&(0,s.jsxs)("div",{className:"bg-white shadow rounded-lg overflow-hidden","data-testid":"alerts-inactive-table",children:[(0,s.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,s.jsx)("thead",{className:"bg-gray-50",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase",children:"Provider"}),(0,s.jsx)("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase",children:"Site Id"}),(0,s.jsx)("th",{className:"px-4 py-2 text-right text-xs font-medium text-gray-500 uppercase",children:"Actions"})]})}),(0,s.jsxs)("tbody",{className:"bg-white divide-y divide-gray-100",children:[0===T.length&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:3,className:"px-4 py-6 text-center text-sm text-gray-500",children:"No providers without an active alert"})}),T.slice(0,500).map(e=>(0,s.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,s.jsx)("td",{className:"px-4 py-2 text-sm font-medium text-gray-900",children:e.name||"â"}),(0,s.jsx)("td",{className:"px-4 py-2 text-xs font-mono text-gray-500",children:e.siteId}),(0,s.jsx)("td",{className:"px-4 py-2 text-right",children:(0,s.jsx)("button",{onClick:()=>{let t;return v(e),f(!1),N("Weâre seeing trouble connecting your account."),void(A((t=e.name,"Weâre seeing trouble connecting ".concat(null!=t?t:"<prov
1ider>"," accounts. This is not caused by anything youâve done. Weâll share an update here when connection status changes."))),P(null))},className:"px-2 py-1 text-xs font-medium text-blue-700 bg-blue-50 rounded-md hover:bg-blue-100","data-testid":"alerts-create-".concat(e.name),children:"Create banner"})})]},e.id))]})]}),T.length>500&&(0,s.jsxs)("p",{className:"px-4 py-2 text-xs text-gray-500 bg-gray-50",children:["Showing first 500 of ",T.length," matches â refine the filter to see more."]})]}),"global"===a&&(0,s.jsx)("div",{className:"bg-white shadow rounded-lg p-6 space-y-4","data-testid":"alerts-global-panel",children:c.globalAlert?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"rounded-md border border-amber-300 bg-amber-50 p-4",children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-amber-800",children:c.globalAlert.header}),(0,s.jsx)("p",{className:"text-sm text-amber-700 mt-1 whitespace-pre-wrap",children:c.globalAlert.message}),(0,s.jsxs)("p",{className:"text-xs text-amber-600 mt-2",children:["Activated by ",c.globalAlert.activatedBy," on ",i(c.globalAlert.activatedDate)]})]}),(0,s.jsx)("span",{className:"text-xs font-medium bg-amber-200 text-amber-900 px-2 py-0.5 rounded",children:"LIVE"})]})}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)("button",{onClick:z,className:"px-3 py-1.5 text-sm font-medium text-blue-700 bg-blue-50 rounded-md hover:bg-blue-100","data-testid":"alerts-global-edit",children:"Edit"}),(0,s.jsx)("button",{onClick:()=>{D(c.globalAlert.id),E("Global")},className:"px-3 py-1.5 text-sm font-medium text-red-700 bg-red-50 rounded-md hover:bg-red-100","data-testid":"alerts-global-deactivate",children:"Deactivate"})]})]}):(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("p",{className:"text-sm text-gray-500 mb-4",children:"No global banner is currently active."}),(0,s.jsx)("button",{onClick:z,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700","data-testid":"alerts-global-create",children:"Create global banner"})]})})]})]}),(g||y)&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 overflow-y-auto","data-testid":"alerts-edit-modal",children:(0,s.jsxs)("div",{className:"flex min-h-full items-start justify-center p-4",children:[(0,s.jsx)("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-sm",onClick:C?void 0:H}),(0,s.jsxs)("div",{className:"relative bg-white rounded-lg shadow-xl max-w-2xl w-full mt-16 p-6",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-gray-900 mb-1",children:y?"Global banner":"Banner for ".concat(null==g?void 0:g.name)}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mb-4",children:y?"Shown to every Vault22 user across the app. Use sparingly â for planned maintenance, region-wide outages, or compliance notices.":"Shown to customers with this provider when a linked-account refresh is affected and before new linking starts. Use neutral, customer-safe wording; this is the live advisory blast radius."}),S&&(0,s.jsx)("div",{className:"bg-red-50 border border-red-200 text-red-700 rounded-md px-4 py-2 text-sm mb-3",children:S}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Header"}),(0,s.jsx)("input",{value:j,onChange:e=>N(e.target.value),className:"form-input w-full px-3 py-2 border border-gray-300 rounded-md text-sm","data-testid":"alerts-edit-header"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:"Message"}),(0,s.jsx)("textarea",{value:w,onChange:e=>A(e.target.value),rows:4,className:"form-textarea w-full px-3 py-2 border border-gray-300 rounded-md text-sm","data-testid":"alerts-edit-message"})]})]}),(0,s.jsxs)("div",{className:"mt-5 flex justify-end gap-3 border-t pt-4",children:[(0,s.jsx)("button",{onClick:H,disabled:C,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50",children:"Cancel"}),(0,s.jsx)("button",{onClick:K,disabled:C||!j.trim()||!w.trim(),className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"alerts-edit-save",children:C?"Publishingâ¦":y&&(null==c?void 0:c.globalAlert)?"Update":"Publish banner"})]})]})]})}),_&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:(0,s.jsxs)("div",{className:"flex min-h-full items-start justify-center p-4",children:[(0,s.jsx)("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-sm",onClick:L?void 0:()=>D(null)}),(0,s.jsxs)("div",{className:"relative bg-white rounded-lg shadow-xl max-w-md w-full mt-32 p-6",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"Deactivate banner?"}),(0,s.jsxs)("p",{className:"text-sm text-gray-500 mt-2",children:[(0,s.jsx)("span",{className:"font-medium",children:F})," banner will stop showing to customers immediately. You can re-create it later from the Inactive tab."]}),(0,s.jsxs)("div",{className:"mt-5 flex justify-end gap-3",children:[(0,s.jsx)("button",{onClick:()=>D(null),disabled:L,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50",children:"Cancel"}),(0,s.jsx)("button",{onClick:U,disabled:L,className:"px-4 py-2 text-sm font-medium text-white bg-red-600 rounded-md hover:bg-red-700 disabled:opacity-50","data-testid":"alerts-deactivate-confirm",children:L?"Deactivatingâ¦":"Deactivate"})]})]})]})}),W&&(0,s.jsx)("div",{className:"fixed top-4 right-4 z-[60] flex items-center gap-3 rounded-md px-4 py-3 shadow-lg border ".concat("success"===W.type?"bg-green-50 border-green-200 text-green-800":"bg-red-50 border-red-200 text-red-800"),children:(0,s.jsx)("span",{className:"text-sm font-medium",children:W.text})})]})}},73638:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/alerts",function(){return a(41933)}])}},e=>{e.O(0,[37497,90636,46593,38792],()=>e(e.s=73638)),_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.