PageSourceSearch

https://open-all-connect.lovable.app/assets/admin.p._projectId.recommendations-DzZjY9Ar.js

js open-all-connect.lovable.app collected 2026-10-03 03:35:06 UTC 8,263 bytes, 1 lines download raw bytes

1import{D as A,r as o,j as t}from"./index-D5orObeG.js";import{i as c,r as p}from"./admin-errors-CKoTLluY.js";import{l as R,a as _,u as v}from"./recommendations-functions-D6Rp-QEk.js";import{l as F,r as z}from"./analytics-functions-CiOdq3T-.js";import"./createServerFn-DdQ-IzOa.js";const k={new:"Нова",applied:"Прочитано",dismissed:"Відхилено"},C={low:"#10B981",md:"#F59E0B",high:"#EF4444"};function V(){const{projectId:s}=A.useParams(),[r,a]=o.useState("recs");return t.jsxs("div",{children:[t.jsx("header",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16,gap:16,flexWrap:"wrap"},children:t.jsx("h1",{style:{fontSize:24,fontWeight:700,margin:0},children:"AI Рекомендації"})}),t.jsxs("div",{style:{display:"flex",gap:4,marginBottom:20,borderBottom:"1px solid #1E293B"},children:[t.jsx(S,{active:r==="recs",onClick:()=>a("recs"),children:"Рекомендації"}),t.jsx(S,{active:r==="changelog",onClick:()=>a("changelog"),children:"Changelog"})]}),r==="recs"?t.jsx(T,{projectId:s}):t.jsx(W,{projectId:s})]})}function S({active:s,onClick:r,children:a}){return t.jsx("button",{type:"button",onClick:r,style:{padding:"10px 16px",background:"transparent",border:"none",borderBottom:`2px solid ${s?"#ff3d7f":"transparent"}`,color:s?"#E2E8F0":"#94A3B8",cursor:"pointer",fontSize:14,fontWeight:s?600:500,marginBottom:-1},children:a})}function T({projectId:s}){const[r,a]=o.useState([]),[l,u]=o.useState("all"),[d,f]=o.useState(!1),[n,i]=o.useState(!1),[B,m]=o.useState(null);async function y(){f(!0);try{const e=await R({data:{projectId:s}});a(e.items)}catch(e){c(e)?p():console.error(e)}finally{f(!1)}}o.useEffect(()=>{y()},[s]),o.useEffect(()=>{const e=setInterval(y,2e4);return()=>clearInterval(e)},[s]);async function w(){i(!0),m(null);try{const e=await _({data:{projectId:s,days:7}});m(`Згенеровано ${e.inserted} рекомендацій`),await y()}catch(e){if(c(e))return p();m(e instanceof Error?e.message:"Помилка")}finally{i(!1)}}async function h(e,E){try{await v({data:{id:e,projectId:s,status:E}}),a(g=>g.map(b=>b.id===e?{...b,status:E}:b))}catch(g){c(g)?p():console.error(g)}}const j=r.filter(e=>l==="all"||e.status===l);return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16,gap:12,flexWrap:"wrap"},children:[t.jsx("div",{style:{display:"flex",gap:8},children:["all","new","applied","dismissed"].map(e=>t.jsx("button",{type:"button",onClick:()=>u(e),style:I(l===e),children:e==="all"?"Всі":k[e]},e))}),t.jsx("button",{type:"button",onClick:w,disabled:n,style:L(n),children:n?"Аналізую…":"Запустити AI-аналіз"})]}),B&&t.jsx("div",{style:{padding:12,background:"#1E293B",borderRadius:8,marginBottom:16,color:"#E2E8F0"},children:B}),d&&t.jsx("div",{style:{color:"#94A3B8"},children:"Завантаження…"}),!d&&j.length===0&&t.jsx("div",{style:{padding:24,background:"#0B1220",border:"1px dashed #1E293B",borderRadius:8,color:"#94A3B8",textAlign:"center"},children:"Немає рекомендацій. Натисни «Запустити AI-аналіз»."}),t.jsx("div",{style:{display:"grid",gap:12},children:j.map(e=>t.jsxs("div",{style:{padding:16,background:"#0B1220",border:"1px solid #1E293B",borderRadius:12},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8,flexWrap:"wrap"},children:[t.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:C[e.severity]??"#64748B"}}),t.jsxs("span",{style:{fontSize:12,color:"#94A3B8",textTransform:"uppercase"},children:[e.category," · ",e.severity]}),typeof e.expected_uplift_pct=="number"&&t.jsxs("span",{style:{fontSize:12,padding:"2px 8px",borderRadius:6,background:"#064E3B",color:"#A7F3D0",fontWeight:600},children:["+",e.expected_uplift_pct,"%"]}),t.jsx("span",{style:{flex:1}}),t.jsx("span",{style:{fontSize:12,padding:"4px 8px",borderRadius:6,background:e.status==="new"?"#1E40AF":e.status==="applied"?"#065F46":"#7F1D1D",color:"#fff"},children:k[e.status]??e.status})]}),t.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:16,color:"#fff"},children:e.title}),e.description&&t.jsx("p",{style:{margin:"0 0 8px 0",color:"#CBD5E1",fontSize:14},children:e.description}),t.jsxs("div",{style:{display:"flex",gap:8,marginTop:12,paddingTop:12,borderTop:"1px solid #1E293B"},children:[t.jsx("button",{type:"button",onClick:()=>h(e.id,"applied"),disabled:e.status==="applied",title:"Позначити прочитаним. НЕ запускає експеримент автоматично — для запуску перейди у /ab-tests.",style:x(e.status==="applied","#10B981"),children:"✓ Прочитано"}),t.jsx("button",{type:"button",onClick:()=>
1h(e.id,"dismissed"),disabled:e.status==="dismissed",style:x(e.status==="dismissed","#EF4444"),children:"Відхилити"}),e.experiment_id&&t.jsx("a",{href:`/admin/p/${e.project_id}/ab-tests`,style:{...x(!1,"#3B82F6"),textDecoration:"none",display:"inline-flex",alignItems:"center",gap:4},children:"↗ Відкрити експеримент"}),e.status!=="new"&&t.jsx("button",{type:"button",onClick:()=>h(e.id,"new"),style:x(!1,"#64748B"),children:"Скинути"})]})]},e.id))})]})}const D={ai_auto:"#8B5CF6",manual:"#3B82F6",ab_winner:"#10B981",rollback:"#EF4444"};function W({projectId:s}){const[r,a]=o.useState([]),[l,u]=o.useState(!0);function d(){u(!0),F({data:{projectId:s}}).then(n=>a(n.rows)).catch(n=>c(n)?p():console.error(n)).finally(()=>u(!1))}o.useEffect(d,[s]);async function f(n){if(confirm("Відкотити цю зміну? Пов'язаний експеримент буде поставлено на паузу."))try{await z({data:{projectId:s,changelogId:n}}),d()}catch(i){if(c(i))return p();alert(i instanceof Error?i.message:"Помилка")}}return l?t.jsx("p",{style:{color:"#94A3B8"},children:"Завантаження…"}):r.length?t.jsx("div",{style:{display:"grid",gap:8},children:r.map(n=>t.jsxs("div",{style:{background:"#0F172A",border:"1px solid #1E293B",borderRadius:12,padding:16,opacity:n.status==="rolled_back"?.55:1},children:[t.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:8},children:[t.jsx("span",{style:{padding:"3px 10px",borderRadius:4,background:D[n.type]??"#475569",color:"#fff",fontSize:11,fontWeight:700,textTransform:"uppercase"},children:n.type}),t.jsx("span",{style:{color:"#94A3B8",fontSize:12},children:new Date(n.created_at).toLocaleString("uk-UA")}),typeof n.impact_metric=="number"&&t.jsxs("span",{style:{marginLeft:"auto",color:n.impact_metric>=0?"#10B981":"#EF4444",fontWeight:700,fontSize:13},children:[n.impact_metric>0?"+":"",n.impact_metric,"%"]})]}),t.jsx("div",{style:{fontWeight:600,color:"#fff",marginBottom:4},children:n.title}),n.description&&t.jsx("div",{style:{color:"#CBD5E1",fontSize:13},children:n.description}),n.status!=="rolled_back"&&t.jsx("div",{style:{marginTop:10},children:t.jsx("button",{type:"button",onClick:()=>f(n.id),style:P,children:"Відкат"})}),n.status==="rolled_back"&&n.rolled_back_at&&t.jsxs("div",{style:{marginTop:6,color:"#EF4444",fontSize:12},children:["Відкочено ",new Date(n.rolled_back_at).toLocaleString("uk-UA")]})]},n.id))}):t.jsx("div",{style:{padding:24,background:"#0B1220",border:"1px dashed #1E293B",borderRadius:8,color:"#94A3B8",textAlign:"center"},children:"Історія змін порожня. Застосовані рекомендації та A/B winners з'являться тут."})}function L(s){return{padding:"10px 16px",borderRadius:8,background:s?"#1E293B":"#3B82F6",color:"#fff",border:"none",cursor:s?"not-allowed":"pointer",fontSize:14,fontWeight:600}}function I(s){return{padding:"6px 12px",borderRadius:999,background:s?"#3B82F6":"transparent",color:s?"#fff":"#94A3B8",border:`1px solid ${s?"#3B82F6":"#1E293B"}`,cursor:"pointer",fontSize:13}}function x(s,r){return{padding:"6px 12px",borderRadius:6,background:"transparent",color:s?"#64748B":r,border:`1px solid ${s?"#1E293B":r}`,cursor:s?"not-allowed":"pointer",fontSize:12,fontWeight:600}}const P={padding:"6px 14px",background:"transparent",color:"#EF4444",border:"1px solid #7F1D1D",borderRadius:6,fontSize:12,cursor:"pointer"};export{V as component};

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.