PageSourceSearch

https://www.creatorsenseai.com/app/assets/AgencyOutcomesPage-DoP48y9g.js

js creatorsenseai.com collected 2026-10-02 01:27:24 UTC 10,058 bytes, 1 lines download raw bytes

1import{k as ct,r as f,w as Q,c as j,C as v,D as l,I as st,y as i,Q as N,u as O,G as R,K as u,N as T,J as A,z as k,H as G,V as H,W as lt,a3 as ut}from"./vendor-misc-5pJBpqhN.js";import{g as dt,u as mt}from"./vendor-vue-BIDZeepx.js";import{P as pt}from"./PageFrame-CmNWALAg.js";import{D as ft}from"./DataPageToolbar-CgUiuW-1.js";import{A as gt}from"./AsyncState-C1wY1NSf.js";import{M as vt}from"./MasterDataTable-PTWiW2Qq.js";import"./creatorFieldHelp-BrZsjpkG.js";import"./FieldLabel-DcFbp3Rs.js";import{C as W}from"./ChromeButton-DmiFifbd.js";import"./DataTable-DiOue6-9.js";import{E as V}from"./EmptyState-HBFSUaTT.js";import{f as _t,be as yt,aD as kt,ax as Y,bf as ht,k as E,b0 as Ct,_ as St}from"./index-BNPflmqD.js";import{u as bt}from"./useAgencyPermissions-B_HoLjuX.js";import"./PageToolbar-C0IR3MXo.js";import"./TimeframePills-C882UVAW.js";import"./ChromeCard-DkvfllPh.js";import"./useBreakpoint-DOQrj9xp.js";import"./breakpoints-Cr7fi6TV.js";import"./arrow-up-8FIemuBW.js";import"./vendor-utils-CxkvrZ9U.js";import"./vendor-tanstack-B6ELLr_Q.js";import"./vendor-sentry-84cD2ryj.js";const Ot=["onClick"],At=["title"],wt={key:2,class:"text-muted"},It={class:"row-actions"},Dt={class:"more-actions"},xt=["onChange"],Mt={key:0,value:"contract"},Nt={key:1,value:"view-contract"},Rt={key:2,value:"aria"},Tt=ct({__name:"AgencyOutcomesPage",setup(Lt){const _=mt(),r=dt(),g=_t();g.initFromMemberships();const{canManageRoster:w}=bt(),X=[30,60,90],I=f(30),D=f(""),x=f("active"),h=f(!1),C=f(null),S=f([]),L=f({}),$=f({}),d=f({});function B(){F()}let M=0;function P(e){return!!e.completed_at||!!e.dismissed_at||e.stage==="completed"||e.stage==="dismissed"}async function F(){var o;const e=g.activeOrgId;if(!e)return;const t=++M;h.value=!0,C.value=null,S.value=[],L.value={},$.value={};try{const[a,n,m]=await Promise.all([yt(I.value,100),kt(void 0,{includeAnchor:!1}).catch(()=>[]),Y(e).catch(()=>[])]);if(t!==M||g.activeOrgId!==e)return;S.value=a||[];const c={},y=n||[];for(const s of S.value){const p=s.outcome_id||s.id;if(!p)continue;const rt=y.find(K=>{var z;return(K.template_metadata||((z=K.scopes_snapshot)==null?void 0:z.template_metadata)||{}).outcome_id===p});c[p]=rt||null}L.value=c;const b={};for(const s of m||[]){const p=String(s.creator_id||s.id||"");p&&(b[p]=s.manager||s.metadata&&(s.metadata.manager||((o=s.metadata)==null?void 0:o.manager))||"—")}$.value=b}catch(a){if(t!==M||g.activeOrgId!==e)return;C.value=a}finally{t===M&&(h.value=!1)}}Q(I,F,{immediate:!0}),Q(()=>g.activeOrgId,()=>{F()});const U=j(()=>{let e=S.value||[];if(D.value){const t=D.value.toLowerCase();e=e.filter(o=>(o.title||"").toLowerCase().includes(t)||(o.detail||"").toLowerCase().includes(t)||(o.kind||"").toLowerCase().includes(t))}return x.value==="active"?e=e.filter(t=>!!t.accepted_at&&!P(t)):x.value==="done"&&(e=e.filter(t=>P(t))),e}),Z=[{key:"title",label:"Signal"},{key:"status",label:"Status"},{key:"nudge",label:"Nudge"},{key:"date",label:"Date"},{key:"contract",label:"Contract"},{key:"actions",label:"Actions"}],tt=j(()=>U.value.map(e=>{var s,p;const t=e.outcome_id||e.id,o=L.value[t],a=!!o,n=String(e.creator_id||""),m=P(e)?"done":e.accepted_at?"active":"pending",c=e.nudge_status?String(e.nudge_status):null,y=e.nudge_kind?String(e.nudge_kind).replace(/_/g," "):null,b=e.completed_at||e.dismissed_at;return{id:t,kind:e.kind,title:e.title,manager:$.value[n]||"—",status:m==="done"?"Done":m==="active"?"Active":"Pending",statusKey:m,nudge:c?`${y||"nudge"}: ${c}`:"—",date:b?new Date(b).toLocaleDateString():e.accepted_at?new Date(e.accepted_at).toLocaleDateString():"—",contract:a?`Contract ${((s=o==null?void 0:o.id)==null?void 0:s.slice(0,8))||""}`:(p=e.template_metadata)!=null&&p.from_accept_and_contract?"Contract draft":"—",has_contract:a,contract_id:(o==null?void 0:o.id)||null,creator_id:n,raw:e}}));async function et(e){const t=e.raw;if(!t.creator_id){r.warning("This outcome is not linked to a specific creator yet.");return}if(!d.value[e.id]){d.value[e.id]=!0;try{const o=g.activeOrgId;if(!o)throw new Error("No active org");const n=(await Y(o)).find(y=>String(y.creator_id)===String(t.creator_id)&&y.status==="active");if(!n){r.warning("No active roster link found for this creator.");return}const m={source:"outcome",outcome_id:t.outcome_id||t.id,outcome_kind:t.kind,outcome_title:t.title,from_outcomes_page:!0},c={from_outcome:t.outcome_id||t.id,creator_id:String(t.creator_id),roster_link_id:n.id,title:t.title,template_metadata:m,scopes:{analytics:!0,content_performance:!0},suggested_scopes:{analytics:!0,content_performance:!0}};r.success("Opening On-Chain E-Contracts with prefilled draft from this outcome (modal seeded with template_metadata for traceability)."),_.push({path:"/agency/contracts",query:{from_outcome:String(t.outcome_id||t.id),prefill:JSON.stringify(c)}})}catch(o){r.error(E(o,"Could not create contract from outcome"))}finally{d.value[e.id]=!1}}}async function at(e){var o;const t=e.raw;if(!t.creator_id){r.warning("Outcome not linked to a creator.");return}if(!d.value[e.id]){d.value[e.id]=!0;try{const a=await Ct({mission_type:"next_best_action",creator_ids:[String(t.creator_id)],notes:`From outcomes page: ${t.title}`,timeframe_days:30});r.success(`ARIA mission started (run ${((o=a.run_id)==null?void 0:o.slice(0,8))||""}). Track it on Outcomes / Performance.`)}catch(a){r.error(E(a,"Could not launch ARIA from outcome"))}finally{d.value[e.id]=!1}}}function q(e){const t=e.raw;t.recommendation_key||t.source==="opportunity"?_.push("/agency/opportunities"):_.push("/agency/inbox")}function J(e){e.contract_id&&_.push({path:"/agency/contracts",query:{packetId:String(e.contract_id)}})}function ot(e){var o;const t=e.creator_id||((o=e.raw)==null?void 0:o.creator_id);if(t){_.push(`/agency/roster/${encodeURIComponent(String(t))}`);return}q(e)}async function nt(e){var o;const t=String(e.id||((o=e.raw)==null?void 0:o.outcome_id)||"");if(!t){r.warning("Outcome id missing — cannot mark done.");return}if(!d.value[e.id]){d.value[e.id]=!0;try{await ht(t),r.success("Marked done"),B()}catch(a){r.error(E(a,"Could not mark outcome done"))}finally{d.value[e.id]=!1}}}function it(e,t){var a,n,m;const o=e.target.value;if(o){if(o==="workspace"){const c=t.creator_id||((a=t.raw)==null?void 0:a.creator_id);c&&_.push(`/agency/roster/${encodeURIComponent(String(c))}/workspace`)}else if(o==="copy-trace"){const c={outcome:t.raw,template_metadata:((n=t.raw)==null?void 0:n.template_metadata)||{},from_outcome:!0,timestamp:new Date().toISOString()};(m=navigator.clipboard)==null||m.writeText(JSON.stringify(c,null,2)).then(()=>r.success("Trace JSON copied")).catch(()=>r.error("Copy failed"))}else o==="contract"?et(t):o==="view-contract"?J(t):o==="aria"&&at(t);e.target.value=""}}return(e,t)=>{const o=st("RouterLink");return i(),v(pt,{title:"Outcomes",description:"Track accepted actions through follow-up — mark done when the move is complete."},{toolbar:l(()=>[N(ft,{"timeframe-days":I.value,"onUpdate:timeframeDays":t[2]||(t[2]=a=>I.value=a),options:X},{actions:l(()=>[H(u("input",{"onUpdate:modelValue":t[0]||(t[0]=a=>D.value=a),type:"search",placeholder:"Search outcomes...",class:"search-input"},null,512),[[lt,D.value]]),H(u("select",{"onUpdate:modelValue":t[1]||(t[1]=a=>x.value=a),class:"filter-select","aria-label":"Filter by status"},[...t[4]||(t[4]=[u("option",{value:"all"},"All",-1),u("option",{value:"active"},"Active",-1),u("option",{value:"done"},"Done",-1)])],512),[[ut,x.value]]),N(o,{to:"/agency/inbox",class:"toolbar-action"},{default:l(()=>[...t[5]||(t[5]=[R("Inbox",-1)])]),_:1})]),_:1},8,["timeframe-days"])]),default:l(()=>[N(gt,{loading:h.value,error:C.value?C.value.message||String(C.value):null,onRetry:B},{default:l(()=>[O(g).activeOrgId?!h.value&&!S.value.length?(i(),v(V,{key:1,title:"No outcomes yet",description:"Accept an inbox item to start tracking follow-up here."},{actions:l(()=>[N(o,{to:"/agency/inbox",class:"empty-cta"},{default:l(()=>[...t[6]||(t[6]=[R("Open Inbox",-1)])]),_:1})]),_:1})):!h.value&&!U.value.length?(i(),v(V,{key:2,title:"No matching outcomes",description:"Adjust search or status filter to see active or done follow-ups."})):(i(),v(vt,{key:3,title:"Outcomes","hide-header":"","count-label":"outcomes",columns:Z,rows:tt.value,"default-sort-key":"date","default-sort-direction":"desc",layout:"responsive","row-clickable":"",onRowClick:q},{"cell-contract":l(({row:a})=>[a.has_contract&&a.contract_id?(i(),k("span",{key:0,class:"contract-badge",title:"This outcome led to the On-Chain E-Contract — click to review",onClick:T(n=>J(a),["stop"])},G(a.contract)+" ↗ ",9,Ot)):a.contract&&a.contract!=="—"?(i(),k("span",{key:1,class:"trace-badge",title:String(a.contract||"").includes("Contract")?"Contract context recorded in template_metadata for traceability":""},G(a.contract),9,At)):(i(),k("span",wt,"—"))]),"cell-actions":l(({row:a})=>[u("div",It,[O(w)&&a.statusKey==="active"?(i(),v(W,{key:0,variant:"primary",loading:d.value[String(a.id)],title:"Mark this follow-up done",onClick:T(n=>nt(a),["stop"])},{default:l(()=>[...t[7]||(t[7]=[R(" Mark done ",-1)])]),_:1},8,["loading","onClick"])):A("",!0),O(w)?(i(),v(W,{key:1,variant:"ghost",onClick:T(n=>ot(a),["stop"])},{default:l(()=>[...t[8]||(t[8]=[R("Follow up",-1)])]),_:1},8,["onClick"])):A("",!0),u("div",Dt,[u("select",{"aria-label":"More outcome actions",onChange:n=>it(n,a),onClick:t[3]||(t[3]=T(()=>{},["stop"]))},[t[9]||(t[9]=u("option",{value:""},"More…",-1)),!a.has_contract&&O(w)?(i(),k("option",Mt," Create contract ")):A("",!0),a.has_contract&&a.contract_id?(i(),k("option",Nt," View contract ")):A("",!0),O(w)?(i(),k("option",Rt,"Launch ARIA")):A("",!0),t[10]||(t[10]=u("option",{value:"workspace"},"Open workspace",-1)),t[11]||(t[11]=u("option",{value:"copy-trace"},"Copy trace JSON",-1))],40,xt)])])]),_:1},8,["rows"])):(i(),v(V,{key:0,title:"No agency workspace",description:"Your account is not linked to an agency organization. Contact your agency owner for an invite."}))]),_:1},8,["loading","error"])]),_:1})}}}),ne=St(Tt,[["__scopeId","data-v-2aad2f67"]]);export{ne 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.