PageSourceSearch

https://app.xlift.ai/assets/ApprovalsPage-cz-PsiGL.js

js xlift.ai collected 2026-10-05 13:20:36 UTC 9,074 bytes, 6 lines download raw bytes

1import{v as N,ai as W,o as m,A as X,al as y,a4 as z,a5 as k,U as g,j as e,C as v,G as c,af as Q,$ as U,E as b,T as l,X as f,a8 as H,F as T,ao as Z,at as J,D as L,ap as V,S as Y,I as ee,a7 as se,Z as K}from"./index-dE8a1mPK.js";import{H as te}from"./HandleLink-CMsO54nu.js";import{E as re}from"./ErrorState-gVNyx0--.js";import{I as $}from"./IconX-B50qDTAe.js";import{T as n}from"./Table-5ftamFSf.js";import{C as D}from"./Checkbox-CVTqs_Fd.js";import{T as O}from"./Textarea-BtbUvWWM.js";import"./IconExternalLink-DcQXcLz7.js";import"./IconCopy-B63sUmw8.js";import"./Code-YtMEZkZ5.js";import"./InputsGroupFieldset-C0syow2C.js";import"./CheckIcon-DkMc45y2.js";import"./get-env-uyVen0u2.js";/**
2 * @license @tabler/icons-react v3.43.0 - MIT
3 *
4 * This source code is licensed under the MIT license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ie=[["path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M13.5 6.5l4 4",key:"svg-1"}]],ae=N("outline","pencil","Pencil",ie);function ye(){var M;const t=W(),[a,u]=m.useState(new Set),[p,h]=m.useState(null),[j,x]=m.useState(null),i=X({queryKey:["actions-awaiting-approval"],queryFn:()=>g.listActions({status:"awaiting-approval",limit:500}),refetchInterval:9e4}),d=((M=i.data)==null?void 0:M.actions)||[];function w(){t.invalidateQueries({queryKey:["actions-awaiting-approval"]})}const E=async s=>{await t.cancelQueries({queryKey:["actions-awaiting-approval"]});const o=t.getQueryData(["actions-awaiting-approval"]);return t.setQueriesData({queryKey:["actions-awaiting-approval"]},r=>r!=null&&r.actions?{...r,actions:r.actions.filter(S=>S.id!==s)}:r),{previous:o}},I=(s,o,r)=>{r!=null&&r.previous&&t.setQueriesData({queryKey:["actions-awaiting-approval"]},r.previous)},A=y({mutationFn:s=>g.approveAction(s),onMutate:s=>E(s),onSuccess:()=>{k("Approved — will dispatch on next tick.")},onError:(s,o,r)=>{I(s,o,r),z(s)},onSettled:()=>w()}),q=y({mutationFn:({id:s,reason:o})=>g.rejectAction(s,o),onMutate:({id:s})=>E(s),onSuccess:()=>{k("Rejected.")},onError:(s,o,r)=>{I(s,o,r),z(s)},onSettled:()=>w()}),C=y({mutationFn:s=>g.approveActionsBulk(s),onSuccess:s=>{k(`Approved ${s.approved} actions.`),u(new Set),w()},onError:s=>z(s)}),R=y({mutationFn:s=>g.rejectActionsBulk(s,"bulk reject"),onSuccess:s=>{k(`Rejected ${s.rejected} actions.`),u(new Set),w()},onError:s=>z(s)});function _(s){u(o=>{const r=new Set(o);return r.has(s)?r.delete(s):r.add(s),r})}function G(){u(s=>s.size===d.length?new Set:new Set(d.map(o=>o.id)))}return e.jsxs(v,{gap:"md",children:[e.jsxs(c,{justify:"space-between",wrap:"wrap",gap:"xs",children:[e.jsxs("div",{children:[e.jsxs(c,{gap:"xs",align:"center",children:[e.jsx(Q,{size:20}),e.jsx(U,{order:2,children:"Approvals"}),d.length>0&&e.jsx(b,{color:"yellow",variant:"filled",children:d.length})]}),e.jsx(l,{c:"dimmed",size:"sm",children:"Campaigns with approval mode pause every action here. Approve to dispatch on the next worker tick; reject to mark failed."})]}),e.jsxs(c,{gap:"xs",children:[e.jsxs(f,{variant:"default",color:"red",disabled:a.size===0||R.isPending,loading:R.isPending,leftSection:e.jsx($,{size:14}),onClick:()=>R.mutate(Array.from(a)),children:["Reject ",a.size>0?`(${a.size})`:"selected"]}),e.jsxs(f,{disabled:a.size===0||C.isPending,loading:C.isPending,leftSection:e.jsx(H,{size:14}),onClick:()=>C.mutate(Array.from(a)),children:["Approve ",a.size>0?`(${a.size})`:"selected"]}),e.jsx(T,{variant:"default",size:"lg",onClick:()=>i.refetch(),loading:i.isRefetching,children:e.jsx(Z,{size:16})})]})]}),i.isLoading&&e.jsx(J,{count:5,h:88}),i.error&&e.jsx(re,{error:i.error,onRetry:()=>i.refetch()}),!i.isLoading&&d.length===0&&e.jsx(L,{withBorder:!0,p:"xl",children:e.jsx(V,{children:e.jsxs(v,{align:"center",gap:"xs",children:[e.jsx(Q,{size:32,color:"var(--mantine-color-dimmed)"}),e.jsx(l,{fw:600,children:"Nothing waiting for approval"}),e.jsxs(l,{c:"dimmed",size:"sm",ta:"center",maw:420,children:["When a campaign with ",e.jsx("b",{children:"approval mode"})," on materializes actions, they pile up here for you to review before they go out."]})]})})}),d.length>0&&e.jsx(L,{withBorder:!0,p:0,children:e.jsx(Y.Autosize,{mah:640,children:e.jsxs(n,{stickyHeader:!0,highlightOnHover:!0,children:[e.jsx(n.Thead,{children:e.jsxs(n.Tr,{children:[e.jsx(n.Th,{w:36,children:e.jsx(D,{checked:a.size>0&&a.size===d.length,indeterminate:a.size>0&&a.size<d.length,onChange:G})}),e.jsx(n.Th,{children:"Type"}),e.jsx(n.Th,{children:"Target"}),e.jsx(n.Th,{children:"Text"}),e.jsx(n.Th,{children:"Campaign"}),e.jsx(n.Th,{children:"Scheduled"}),e.jsx(n.Th,{})]})}),e.jsx(n.Tbody,{children:d.map(s=>{var o,r,S,P,F,B;return e.jsxs(n.Tr,{children:[e.jsx(n.Td,{children:e.jsx(D,{checked:a.has(s.id),onChange:()=>_(s.id)})}),e.jsx(n.Td,{children:e.jsxs(c,{gap:4,wrap:"nowrap",children:[e.jsx(l,{size:"xs",fw:500,children:s.type}),typeof((o=s.payload)==null?void 0:o.sequenceStepIndex)=="number"&&e.jsxs(b,{variant:"dot",color:"cyan",size:"xs",children:["step ",s.payload.sequenceStepIndex+1]})]})}),e.jsx(n.Td,{children:(S=(r=s.payload)==null?void 0:r.target)!=null&&S.startsWith("@")?e.jsx(te,{handle:s.payload.target,size:"xs",truncate:!0,maw:160}):e.jsx(l,{size:"xs",truncate:!0,maw:180,children:((P=s.payload)==null?void 0:P.target)||"—"})}),e.jsx(n.Td,{children:e.jsxs(c,{gap:4,wrap:"nowrap",children:[e.jsx(l,{size:"xs",lineClamp:2,maw:240,children:((F=s.payload)==null?void 0:F.text)||"—"}),((B=s.payload)==null?void 0:B.text)&&e.jsx(T,{size:"xs",variant:"subtle",onClick:()=>x(s),"aria-label":"Edit message",title:"Edit before approving",children:e.jsx(ae,{size:12})})]})}),e.jsx(n.Td,{children:s.campaignId?e.jsx(ee,{component:se,to:`/campaigns/${s.campaignId}`,size:"xs",children:"view"}):e.jsx(l,{size:"xs",c:"dimmed",children:"—"})}),e.jsx(n.Td,{children:e.jsx(l,{size:"xs",c:"dimmed",children:s.scheduledFor?new Date(s.scheduledFor).toLocaleStr
6ing():"—"})}),e.jsx(n.Td,{children:e.jsxs(c,{gap:4,wrap:"nowrap",justify:"flex-end",children:[e.jsx(T,{size:"sm",color:"green",variant:"light",onClick:()=>A.mutate(s.id),loading:A.isPending&&A.variables===s.id,"aria-label":"Approve",children:e.jsx(H,{size:14})}),e.jsx(T,{size:"sm",color:"red",variant:"light",onClick:()=>h(s),"aria-label":"Reject",children:e.jsx($,{size:14})})]})})]},s.id)})})]})})}),e.jsx(oe,{action:p,onClose:()=>h(null),onSubmit:s=>{q.mutate({id:p.id,reason:s}),h(null)},loading:q.isPending}),e.jsx(ne,{action:j,onClose:()=>x(null),onApproved:()=>{x(null),w()}})]})}function ne({action:t,onClose:a,onApproved:u}){var x;const[p,h]=m.useState("");m.useEffect(()=>{var i;h(((i=t==null?void 0:t.payload)==null?void 0:i.text)||"")},[t==null?void 0:t.id]);const j=y({mutationFn:async()=>{var i;p!==(((i=t.payload)==null?void 0:i.text)||"")&&await g.patchAction(t.id,{text:p}),await g.approveAction(t.id)},onSuccess:()=>{k("Edited + approved"),u()},onError:i=>z(i)});return t?e.jsx(K,{opened:!!t,onClose:a,title:"Edit + approve",size:"md",centered:!0,children:e.jsxs(v,{children:[e.jsxs(v,{gap:4,children:[e.jsx(l,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,children:"Action"}),e.jsxs(c,{gap:6,children:[e.jsx(b,{variant:"light",children:t.type}),((x=t.payload)==null?void 0:x.target)&&e.jsx(l,{size:"sm",children:t.payload.target})]})]}),e.jsx(O,{label:"Message",description:"Edits save before approval. Approve dispatches on the next worker tick.",value:p,onChange:i=>h(i.currentTarget.value),autosize:!0,minRows:4,maxRows:12}),e.jsxs(c,{justify:"space-between",children:[e.jsxs(l,{size:"xs",c:"dimmed",children:[p.length," chars"]}),e.jsxs(c,{gap:"xs",children:[e.jsx(f,{variant:"default",onClick:a,children:"Cancel"}),e.jsx(f,{onClick:()=>j.mutate(),loading:j.isPending,disabled:!p.trim(),children:"Save + approve"})]})]})]})}):null}function oe({action:t,onClose:a,onSubmit:u,loading:p}){var x,i;const[h,j]=m.useState("");return m.useEffect(()=>{j("")},[t==null?void 0:t.id]),t?e.jsx(K,{opened:!!t,onClose:a,title:"Reject this action?",centered:!0,size:"md",children:e.jsxs(v,{children:[e.jsxs(v,{gap:4,children:[e.jsx(l,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,children:"Action"}),e.jsxs(c,{gap:6,children:[e.jsx(b,{variant:"light",children:t.type}),((x=t.payload)==null?void 0:x.target)&&e.jsx(l,{size:"sm",children:t.payload.target})]})]}),((i=t.payload)==null?void 0:i.text)&&e.jsxs(v,{gap:4,children:[e.jsx(l,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,children:"Message"}),e.jsx(l,{size:"sm",style:{padding:8,background:"var(--xb-bg-soft)",borderRadius:4,whiteSpace:"pre-wrap",maxHeight:200,overflow:"auto"},children:t.payload.text})]}),e.jsx(O,{label:"Reason (optional)",description:"Logged on the action and surfaced in History so you remember later.",placeholder:"e.g. wrong list, message needs rework, prospect already engaged elsewhere",value:h,onChange:d=>j(d.currentTarget.value),autosize:!0,minRows:2,maxRows:5}),e.jsxs(c,{justify:"flex-end",children:[e.jsx(f,{variant:"default",onClick:a,children:"Cancel"}),e.jsx(f,{color:"red",onClick:()=>u(h.trim()||"rejected by user"),loading:p,children:"Reject"})]})]})}):null}export{ye 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.