PageSourceSearch

https://glowpeptides.com/assets/AffiliateAssets-Dr2YL7eC.js

js glowpeptides.com collected 2026-10-08 16:16:23 UTC 10,247 bytes, 1 lines download raw bytes

1import{r as i,j as e}from"./react-CURgexgJ.js";import{D as X,dq as J,B as l,c as Q,bi as Z,d as ee,g as se,h as r,S as te,y as ae,z as ie,H as le,K as re,I as p,bk as oe,L as U,bc as L,aT as ne,aS as de,a$ as ce,b as o,bK as z,M as me,b7 as xe}from"./index-Bigpg4hO.js";import{T as B}from"./textarea-D4FwsVkb.js";import{C as c,a as pe}from"./card-Ck2GTjlN.js";import{A as he,h as ue,a as ge,b as fe,c as je,d as ye,e as ve,f as Ne,g as be}from"./alert-dialog-MuklPaiE.js";import{u as Ce,a as we,b as Ae,c as _e,A as y,V as H,P as De}from"./useAffiliateAssets-BYgNDp-_.js";import{A as Te}from"./AffiliatesSubNav-CKPPJpvN.js";import{I as v}from"./image-plus-C81n4mnY.js";import{m as Se}from"./framer-motion-T2vzDAm3.js";import{D as Fe}from"./download-CdhCtQXH.js";import{C as Ie}from"./copy-DxjobD4t.js";import{M}from"./megaphone-DzwsKmkM.js";import{I as P}from"./image-C3WXEmSH.js";import"./radix-ui-DjK_dfS_.js";import"./query-CSsWuzYv.js";import"./user-plus-DSRfoQZ2.js";import"./chart-column-z5k5xGB4.js";const Oe={organic_social:M,paid_ad:M,banner:P,email_template:me,copy_snippet:De,video:H,logo:P,product_image:xe,other:z},ke=["copy_snippet"];function Je(){const{data:n=[],isLoading:R}=Ce({includeInactive:!0}),h=we(),V=Ae(),G=_e(),[K,u]=i.useState(!1),[g,N]=i.useState(""),[b,C]=i.useState(""),[f,w]=i.useState("paid_ad"),[A,_]=i.useState(""),[m,D]=i.useState(null),[j,T]=i.useState(""),[S,F]=i.useState(0),d=ke.includes(f),I=()=>{N(""),C(""),w("paid_ad"),_(""),D(null),T(""),F(0)},W=async()=>{if(!g.trim()){o.error("Title is required");return}if(d&&!j.trim()){o.error("Copy snippets need body text");return}if(!d&&!m){o.error("Pick a file to upload");return}const s=A.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean);try{await h.mutateAsync({title:g.trim(),description:b.trim()||void 0,category:f,tags:s,display_order:S,file:d?null:m,body_text:d?j.trim():null}),o.success("Asset uploaded"),u(!1),I()}catch(a){const x=a instanceof Error?a.message:"Upload failed";o.error(`Upload failed: ${x}`)}},Y=async s=>{try{await navigator.clipboard.writeText(s),o.success("Copied to clipboard")}catch{o.error("Could not copy — select and copy manually")}},$=n.reduce((s,a)=>(s[a.category]||(s[a.category]=[]),s[a.category].push(a),s),{});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Te,{}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-display font-bold flex items-center gap-3",children:[e.jsx(v,{className:"w-8 h-8 text-primary"}),"Affiliate Asset Library"]}),e.jsxs("p",{className:"text-muted-foreground mt-1",children:["Upload organic and paid creative, banners, copy snippets, and logos. Approved affiliates can browse + download from"," ",e.jsx("code",{className:"text-xs",children:"/affiliate/assets"}),"."]})]}),e.jsxs(X,{open:K,onOpenChange:u,children:[e.jsx(J,{asChild:!0,children:e.jsxs(l,{size:"lg",className:"gap-2",children:[e.jsx(v,{className:"w-4 h-4"})," Upload Asset"]})}),e.jsxs(Q,{className:"max-w-lg",children:[e.jsxs(Z,{children:[e.jsx(ee,{children:"Upload a new asset"}),e.jsxs(se,{children:["Lands at ",e.jsx("code",{children:"/affiliate/assets"})," immediately. Use the Active toggle later to hide without deleting."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{htmlFor:"asset-category",children:"Category"}),e.jsxs(te,{value:f,onValueChange:s=>w(s),children:[e.jsx(ae,{id:"asset-category",children:e.jsx(ie,{})}),e.jsx(le,{children:Object.keys(y).map(s=>e.jsx(re,{value:s,children:y[s]},s))})]}),d&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Copy snippets are pure text — affiliates copy the body to clipboard."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{htmlFor:"asset-title",children:"Title"}),e.jsx(p,{id:"asset-title",placeholder:"BPC-157 Meta carousel — May launch",value:g,onChange:s=>N(s.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{htmlFor:"asset-description",children:"Description (optional)"}),e.jsx(B,{id:"asset-description",placeholder:"Where this was used, who it's for, any usage notes.",value:b,onChange:s=>C(s.target.value),rows:2})]}),d?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{htmlFor:"asset-body",children:"Body text"}),e.jsx(B,{id:"asset-body",placeholder:"The actual copy affiliates will paste — caption, tagline, CTA.",value:j,onChange:s=>T(s.target.value),rows:6})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{htmlFor:"asset-file",children:"File"}),e.jsx(p,{id:"asset-file",type:"file",onChange:s=>{var a;return D(((a=s.target.files)==null?void 0:a[0])??null)},accept:"image/*,video/*,application/pdf"}),m&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[m.name," · ",(m.size/1024).toFixed(0)," KB"]}
1)]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{htmlFor:"asset-tags",children:"Tags (comma-separated)"}),e.jsx(p,{id:"asset-tags",placeholder:"bpc-157, evergreen, meta",value:A,onChange:s=>_(s.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{htmlFor:"asset-order",children:"Display order"}),e.jsx(p,{id:"asset-order",type:"number",value:S,onChange:s=>F(parseInt(s.target.value||"0",10))})]})]})]}),e.jsxs(oe,{children:[e.jsx(l,{variant:"outline",onClick:()=>{u(!1),I()},children:"Cancel"}),e.jsx(l,{onClick:W,disabled:h.isPending,children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"w-4 h-4 animate-spin mr-2"})," Uploading…"]}):"Upload"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs(c,{className:"p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total assets"}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:n.length})]}),e.jsxs(c,{className:"p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active"}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-primary",children:n.filter(s=>s.is_active).length})]}),e.jsxs(c,{className:"p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Paid ads"}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:n.filter(s=>s.category==="paid_ad").length})]}),e.jsxs(c,{className:"p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Organic"}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:n.filter(s=>s.category==="organic_social").length})]})]}),R?e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(U,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):n.length===0?e.jsxs(c,{className:"p-12 text-center",children:[e.jsx(v,{className:"w-12 h-12 mx-auto text-muted-foreground/40 mb-3"}),e.jsx("h3",{className:"font-semibold",children:"No assets yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Upload your first organic post or paid ad to get started. Approved affiliates will see them at /affiliate/assets."})]}):e.jsx("div",{className:"space-y-6",children:Object.entries($).map(([s,a])=>{const x=Oe[s]||z;return e.jsx(c,{children:e.jsxs(pe,{className:"p-0",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b",children:[e.jsx(x,{className:"w-4 h-4 text-primary"}),e.jsx("h2",{className:"font-semibold",children:y[s]}),e.jsx(L,{variant:"outline",className:"ml-auto",children:a.length})]}),e.jsx("div",{className:"divide-y divide-border",children:a.map((t,q)=>{var O,k;return e.jsxs(Se.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{delay:q*.02},className:`flex items-start gap-4 p-4 ${t.is_active?"":"opacity-50"}`,children:[t.file_url&&((O=t.mime_type)!=null&&O.startsWith("image/"))?e.jsx("img",{src:t.file_url,alt:t.title,className:"w-20 h-20 rounded-md object-cover bg-muted shrink-0"}):t.file_url&&((k=t.mime_type)!=null&&k.startsWith("video/"))?e.jsx("div",{className:"w-20 h-20 rounded-md bg-muted flex items-center justify-center shrink-0",children:e.jsx(H,{className:"w-6 h-6 text-muted-foreground"})}):e.jsx("div",{className:"w-20 h-20 rounded-md bg-muted flex items-center justify-center shrink-0",children:e.jsx(x,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:t.description}),t.body_text&&e.jsx("p",{className:"text-xs text-muted-foreground font-mono mt-1 line-clamp-3 bg-muted/40 rounded p-2",children:t.body_text}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:t.tags.map(E=>e.jsx(L,{variant:"secondary",className:"text-[10px]",children:E},E))})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.file_url&&e.jsx(l,{size:"icon",variant:"ghost",asChild:!0,title:"Download",children:e.jsx("a",{href:t.file_url,target:"_blank",rel:"noreferrer",children:e.jsx(Fe,{className:"w-4 h-4"})})}),t.body_text&&e.jsx(l,{size:"icon",variant:"ghost",onClick:()=>Y(t.body_text),title:"Copy text",children:e.jsx(Ie,{className:"w-4 h-4"})}),e.jsx(l,{size:"icon",variant:"ghost",onClick:()=>V.mutate({id:t.id,is_active:!t.is_active}),title:t.is_active?"Hide from affiliates":"Show to affiliates",children:t.is_active?e.jsx(ne,{className:"w-4 h-4"}):e.jsx(de,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs(he,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(l,{size:"icon",variant:"ghost",title:"Delete",children:e.jsx(ce,{className:"w-4 h-4 text-destructive"})})}),e.jsxs(ge,{children:[e.jsxs(fe,{children:[e.jsx(je,{children:"Delete this asset?"}),e.jsxs(ye,{children:['"',t.title,'" will be permanently removed. If you just want to hide it from affiliates, use the eye icon to deactivate instead.']})]}),e.jsxs(ve,{children:[e.jsx(Ne,{children:"Cancel"}),e.jsx(be,{onClick:()=>G.mutate(t),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete permanently"})]})]})]})]})]})})]},t.id)})})]})},s)})})]})}export{Je 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.