PageSourceSearch

https://nguyentudo.me/assets/AdminSalepageProposalsPage-BOgMWPag.js

js nguyentudo.me collected 2026-10-04 14:32:26 UTC 11,375 bytes, 6 lines download raw bytes

1import{V as k,r as N,aJ as w,W as C,aK as x,j as s,h as c,g as S,ap as v,s as o,n as l}from"./index-CyZ-pQAp.js";import{C as _}from"./card-DrHtq4Bk.js";import{E as A}from"./external-link-rilHTH9s.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const j=k("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]),b={hero:{label:"Hero",position:"Phần đầu trang — banner + CTA chính"},case_studies:{label:"Case Studies",position:"Ngay dưới Hero — kết quả học viên"},details:{label:"Chi tiết khoá",position:"Khối thông tin nhanh dưới case studies"},problem:{label:"Vấn đề",position:"Khối 'Bạn đang gặp vấn đề gì?'"},solution:{label:"Giải pháp",position:"Khối giới thiệu giải pháp"},mentorship:{label:"Chữa bài 1-1",position:"Khối đồng hành chữa bài hàng ngày"},comparison:{label:"So sánh",position:"Bảng so sánh Base vs Pro / với khoá khác"},how_it_works:{label:"Cách hoạt động",position:"Khối 'Cách thử thách vận hành'"},daily_format:{label:"Lịch trình hàng ngày",position:"Khối lịch học mỗi ngày"},curriculum:{label:"Lộ trình 21 ngày",position:"Roadmap nội dung từng tuần"},for_who:{label:"Dành cho ai",position:"Khối 'Khoá học dành cho ai'"},no_excuses:{label:"Không lý do",position:"Khối phá vỡ phản đối"},winning_ideas:{label:"Ý tưởng thắng",position:"Khối ý tưởng mẫu / win"},guarantee:{label:"Cam kết",position:"Khối cam kết hoàn tiền"},refund_flow:{label:"Quy trình hoàn tiền",position:"Khối chi tiết flow hoàn tiền"},pricing:{label:"Bảng giá",position:"Khối Base vs Pro + nút mua"},faq:{label:"FAQ",position:"Câu hỏi thường gặp gần cuối trang"},final_cta:{label:"CTA cuối",position:"Khối CTA cuối trang"},urgency_bar:{label:"Thanh khẩn cấp",position:"Sticky bar phía trên/dưới"},exit_intent:{label:"Exit intent",position:"Popup khi rời trang"}};function F(){const[r,a]=N.useState("pending"),i=w(),{data:h=[],isLoading:u}=C({queryKey:["proposals",r],queryFn:async()=>{let e=o.from("salepage_proposals").select("*").order("created_at",{ascending:!1});r!=="all"&&(e=e.eq("status",r));const{data:t}=await e;return t||[]}}),d=x({mutationFn:async()=>{const{data:e,error:t}=await o.functions.invoke("weekly-salepage-analyst",{body:{}});if(t)throw t;return e},onSuccess:()=>{l.success("Đã chạy AI Analyst"),i.invalidateQueries({queryKey:["proposals"]})},onError:e=>l.error((e==null?void 0:e.message)||"Chạy thất bại")}),y=x({mutationFn:async e=>{const{data:t,error:n}=await o.from("salepage_content_overrides").insert({page_key:"thu-thach",section_key:e.section_key,field_key:e.field_key,value:e.proposed_value,is_active:!0,created_by_ai:!0,proposal_id:e.id}).select().single();if(n)throw n;await o.from("salepage_content_overrides").update({is_active:!1}).eq("page_key","thu-thach").eq("section_key",e.section_key).eq("field_key",e.field_key).neq("id",t.id);const{error:p}=await o.from("salepage_proposals").update({status:"approved",decided_at:new Date().toISOString(),applied_override_id:t.id}).eq("id",e.id);if(p)throw p},onSuccess:()=>{l.success("Đã duyệt & áp dụng"),i.invalidateQueries({queryKey:["proposals"]}),i.invalidateQueries({queryKey:["salepage-overrides"]})},onError:e=>l.error((e==null?void 0:e.message)||"Lỗi")}),f=x({mutationFn:async e=>{const{error:t}=await o.from("salepage_proposals").update({status:"rejected",decided_at:new Date().toISOString()}).eq("id",e.id);if(t)throw t},onSuccess:()=>{l.success("Đã bỏ qua"),i.invalidateQueries({queryKey:["proposals"]})}}),m=x({mutationFn:async e=>{if(!e.applied_override_id)return;const{error:t}=await o.from("salepage_content_overrides").update({is_active:!1}).eq("id",e.applied_override_id);if(t)throw t},onSuccess:()=>l.success("Đã khôi phục bản gốc")}),g=x({mutationFn:async e=>{const t={[e.field_key]:e.current_value},n={[e.field_key]:e.proposed_value},{error:p}=await o.from("salepage_ab_tests").insert({proposal_id:e.id,section_key:e.section_key,variant_a_content:t,variant_b_content:n,status:"running",traffic_split:50});if(p)throw p;await o.from("salepage_proposals").update({status:"approved",decided_at:new Date().toISOString()}).eq("id",e.id)},onSuccess:()=>{l.success("Đã khởi chạy A/B test (50/50)"),i.invalidateQueries({queryKey:["proposals"]}),i.invalidateQueries({queryKey:["salepage-ab-tests-running"]})},onError:e=>l.error((e==null?void 0:e.message)||"Lỗi tạo test")});return s.jsxs("div",{className:"p-6 space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Đề xuất tối ưu salepage"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"AI phân tích heatmap + replay → đề xuất sửa. Duyệt = áp dụng ngay."})]}),s.jsxs("div",{className:"flex gap-2 flex-wrap",children:[["pending","approved","rejected","all"].map(e=>s.jsx(c,{size:"sm",variant:r===e?"default":"outline",onClick:()=>a(e),children:e},e)),s.jsx(c,{asChild:!0,size:"sm",variant:"outline",children:s.jsxs(S,{to:"/admin/salepage-ab-tests",children:[s.jsx(j,{className:"w-4 h-4 mr-1"}),"A/B tests"]})}),s.jsx(c,{size:"sm",onClick:()=>d.mutate(),disabled:d.isPending,children:d.isPending?"Đang chạy…":"Chạy AI Analyst ngay"})]})]}),u&&s.jsx("p",{className:"text-sm text-muted-foreground",children:"Đang tải…"}),!u&&h.length===0&&s.jsxs(_,{className:"p-8 text-center text-sm text-muted-foreground",children:['Chưa có đề xuất nào ở trạng thái "',r,'". Bấm "Chạy AI Analyst ngay" để khởi tạo.']}),s.jsx("div",{className:"grid gap-3",children:h.map(e=>{var t;return s.jsxs(_,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[s.jsx(v,{variant:"outline",children:((t=b[e.section_key])==null?void 0:t.label)||e.section_key}),s.jsx(v,{variant:"secondary",children:e.field_key}),e.severity&&s.jsx(v,{className:e.severity==="high"?"bg-red-600":"bg-yellow-600",children:e.severity}),e.expected_lift&&s.jsxs("span",{className:"text-xs text-green-500",children:["▲ ",e.expected_lift]})]}),b[e.section_key]&&s.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["📍 Vị trí: ",b[e.section_key].position]}),s.jsx("p",{className:"text-sm",children:e.rationale}),s.jsxs("a",{href:`/thu-thach#sec-${e.section_key}`,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline mt-2",children:[s.jsx(A,{className:"w-3 h-3"})," Xem vị trí trên salepage"]})]}),e.status==="pending"&&s.jsxs("div",{className:"flex flex-col gap-2 shrink-0",children:[s.jsx(c,{size:"sm",onClick:()=>y.mutate(e),children:"Duyệt & áp dụng 100%"}),s.jsxs(c,{size:"sm",variant:"secondary",onClick:()=>g.mutate(e),disabled:g.isPending,children:[s.jsx(j,{className:"w-4 h-4 mr-1"})," Chạy A/B test 50/50"]}),s.jsx(c,{size:"sm",variant:"outline",onClick:()=>f.mutate(e),children:"Bỏ qua"})]}),e.status==="approved"&&e.applied_override_id&&s.jsx(c,{size:"sm",variant:"outline",onClick:()=>m.mutate(e),children:"Khôi phục bản gốc"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-xs",children:[s.jsxs("div",{className:"bg-red-950/20 border border-red-900/40 rounded p-2",children:[s.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Hiện tại"}),s.jsx("pre",{className:"whitespace-pre-wrap break-words",children:JSON.stringify(e.current_value,null,2)})]}),s.jsxs("div",{className:"bg-green-950/20 border border-green-900/40 rounded p-2",children:[s.jsx("div",{className:"text-green-400 font-medium mb-1",children:"Đề xuất"}),s.jsx("pre",{className:"whitespace-pre-wrap break-words",children:JSON.stringify(e.proposed_value,null,2)})]})]}),s.jsx(K,{evidence:e.evidence})]},e.id)})})]})}function K({evidence:r}){if(!r||typeof r!="object")return null;const a=r.global||{},i=r.metrics||{},h=r.funnel_25,u=r.funnel_50,d=r.funnel_75;if(!(h||u||d||a.medianTtfcSec!=null||a.rageRate!=null||i.rage_clicks!=null))return null;const f=t=>t==null?"text-muted-foreground":t>=40?"text-red-400":t>=20?"text-yellow-400":"text-green-400",m=({label:t,f:n})=>s.jsxs("div",{className:"rounded border border-border bg-muted/20 p-2",children:[s.jsx("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:t}),n?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"text-sm font-semibold",children:[n.sessions_reached," session"]}),s.jsx("div",{className:`text-xs ${f(n.drop_pct_from_prev)}`,children:n.drop_pct_from_prev>0?`↓ ${n.drop_pct_from_prev}% vs section trước`:"Không rớt"})]}):s.jsx("div",{className:"text-xs text-muted-foreground",children:"Không ai đọc tới"})]}),g=a.medianTtfcSec==null?"text-yellow-400":a.medianTtfcSec<10?"text-red-400":a.medianTtfcSec>120?"text-yellow-400":"text-green-400",e=Number(a.rageRate)>=10?"text-red-400":Number(a.rageRate)>0?"text-yellow-400":"text-green-400";return s.jsxs("div",{className:"mt-3 rounded border border-border/60 bg-background/40 p-3 space-y-2",children:[s.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"📊 Bằng chứng AI dựa vào"}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsx(m,{label:"Reach 25%",f:h}),s.jsx(m,{label:"Reach 50%",f:u}),s.jsx(m,{label:"Reach 75%",f:d})]}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 text-xs",children:[s.jsxs("div",{className:"rounded border border-border bg-muted/20 p-2",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Rage-click section"}),s.jsxs("div",{className:`text-sm font-semibold ${i.rage_clicks>0?"text-red-400":"text-foreground"}`,children:[i.rage_clicks??0," lần"]})]}),s.jsxs("div",{className:"rounded border border-border bg-muted/20 p-2",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Avg scroll depth"}),s.jsxs("div",{className:"text-sm font-semibold",children:[i.avg_depth??0,"%"]})]}),s.jsxs("div",{className:"rounded border border-border bg-muted/20 p-2",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Median TTFC"}),s.jsx("div",{className:`text-sm font-semibold ${g}`,children:a.medianTtfcSec!=null?`${a.medianTtfcSec}s`:"Chưa ai click CTA"})]}),s.jsxs("div",{className:"rounded border border-border bg-muted/20 p-2",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Rage-rate page"}),s.jsxs("div",{className:`text-sm font-semibold ${e}`,children:[a.rageRate??0,"%"]})]})]}),s.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Tổng ",a.totalSessions??"?"," session · chốt ",a.conversionRate??"?","% · CTA click rate ",a.ctaClickRate??"?","%",i.views!=null&&` · section views ${i.views}, clicks ${i.clicks??0}`]})]})}export{F 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.