PageSourceSearch

https://capitaldart.com/assets/admin.referrals-h4Ir82-u.js

js capitaldart.com collected 2026-10-08 12:40:23 UTC 6,116 bytes, 2 lines download raw bytes

1import{A as u,C as h,D as b,J as L,K as m,M as A,r as s,q as F,j as e,L as q,v as d,I as i,B as E}from"./main-rwWalgtK.js";import{S as B}from"./switch-CsjKD6gF.js";import"./index-CLVOXAhG.js";const D=u({method:"GET"}).middleware([h]).handler(b("e875d909b56eebbc8cf77ebc8bf4869ef7956b7a31090a9260c774bcbd4cc5fb")),R=u({method:"POST"}).middleware([h]).handler(b("5478fc6471b6431cdcbfef51328c2d8fe4c27cc262715b8b8ef5a73ebcd944cf")),I=u({method:"POST"}).middleware([h]).handler(b("c09189d2ee3d74180942ed2e996911450fa8b3b355f3331d5b95901cd39e71e8"));function Q(){const a=L(),l=m(D),o=m(R),c=m(I),r=A({queryKey:["admin-referral-codes"],queryFn:()=>l()}),[x,f]=s.useState(""),[j,y]=s.useState(""),[N,g]=s.useState("25"),[p,C]=s.useState(""),[v,S]=s.useState(null),[k,_]=s.useState(!1),n=F({mutationFn:async()=>{const t=x.trim().toUpperCase();if(/\s/.test(t))throw new Error("Code cannot contain whitespace.");return o({data:{code:t,influencer_name:j.trim(),bonus_pct:parseInt(N,10)||0,expires_at:p?new Date(`${p}T00:00:00Z`).toISOString():null}})},onSuccess:t=>{if(!t.ok){_(!0);return}S(`Created ${x.trim().toUpperCase()}.`),f(""),y(""),g("25"),C(""),a.invalidateQueries({queryKey:["admin-referral-codes"]})}});return e.jsxs("main",{className:"mx-auto max-w-[960px] px-4 pb-16 pt-6",children:[e.jsxs("header",{className:"mb-6",children:[e.jsx(q,{to:"/admin",className:"text-[12.5px] text-brand-muted no-underline hover:text-brand-ink",children:"← Back to admin"}),e.jsx("h1",{className:"mt-2 font-serif text-[32px] font-normal leading-tight tracking-tight text-brand-ink",children:"Referrals."}),e.jsx("p",{className:"mt-1 text-[14px] text-brand-muted",children:"Create referral codes and review redemption history. Codes are never deleted so payout history stays intact. Deactivate a code with the Active toggle."})]}),e.jsxs("section",{className:"mb-8 rounded-2xl border border-brand-line bg-brand-paper p-5",children:[e.jsx("h2",{className:"mb-4 font-serif text-[20px] text-brand-ink",children:"Create a code"}),e.jsxs("form",{onSubmit:t=>{t.preventDefault(),S(null),_(!1),n.mutate()},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(d,{htmlFor:"rc-code",children:"Code"}),e.jsx(i,{id:"rc-code",required:!0,maxLength:64,value:x,onChange:t=>f(t.target.value),placeholder:"ACME25",autoCapitalize:"characters",autoCorrect:"off",spellCheck:!1,style:{textTransform:"uppercase"}}),e.jsx("p",{className:"mt-1 text-[11.5px] text-brand-muted",children:"Stored uppercase. No spaces. 64 characters or fewer."})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"rc-name",children:"Influencer name"}),e.jsx(i,{id:"rc-name",required:!0,maxLength:200,value:j,onChange:t=>y(t.target.value),placeholder:"Acme Media LLC"})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"rc-bonus",children:"Bonus percent"}),e.jsx(i,{id:"rc-bonus",type:"number",min:1,max:100,required:!0,value:N,onChange:t=>g(t.target.value)}),e.jsx("p",{className:"mt-1 text-[11.5px] text-brand-muted",children:"Integer from 1 to 100. Applied as bonus credits on top of the tier the buyer purchases."})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"rc-expires",children:"Expires at (optional)"}),e.jsx(i,{id:"rc-expires",type:"date",value:p,onChange:t=>C(t.target.value)}),e.jsx("p",{className:"mt-1 text-[11.5px] text-brand-muted",children:"Leave blank for no expiry."})]}),e.jsx(E,{type:"submit",disabled:n.isPending,children:n.isPending?"Creating…":"Create code"}),k&&e.jsx("p",{className:"text-[12.5px] text-destructive",children:"That code is already taken. Pick a different code."}),n.error&&!k&&e.jsx("p",{className:"text-[12.5px] text-destructive",children:n.error instanceof Error?n.error.message:"Create failed"}),v&&e.jsx("p",{className:"text-[12.5px] text-[oklch(0.45_0.087_155.7)]",children:v})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 font-serif text-[20px] text-brand-ink",children:"Existing codes"}),r.isLoading?e.jsx("p",{className:"text-[14px] text-brand-muted",children:"Loading…"}):!r.data||r.data.length===0?e.jsx("p",{className:"text-[14px] text-brand-muted",children:"No codes yet."}):e.jsx("div",{className:"overflow-x-auto rounded-xl border border-brand-line bg-brand-paper",children:e.jsxs("table",{className:"w-full text-[14px]",children:[e.jsx("thead",{className:"bg-brand-paper-2 text-left text-[11.5px] uppercase tracking-wider text-brand-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"Code"}),e.jsx("th",{className:"px-3 py-2",children:"Influencer"}),e.jsx("th",{className:"px-3 py-2",children:"Bonus %"}),e.jsx("th",{className:"px-3 py-2",children:"Active"}),e.jsx("th",{className:"px-3 py-2",children:"Expires"}),e.jsx("th",{className:"px-3 py-2",children:"Redemptions"}),e.jsx("th",{className:"px-3 py-2",children:"Credits granted"}),e.jsx("th",{className:"px-3 py-2",children:"Bonus credits"}),e.jsx("th",{className:"px-3 py-2",children:"Created"})]})}),e.jsx("tbody",{children:r.data.map(t=>e.jsx(T,{row:t,onToggle:async w=>{await c({data:{id:t.id,active:w}}),a.invalidateQueries({queryKey:["admin-referral-codes"]})}},t.id))})]})})]})]})}function T({row:a,onToggle:l}){const[o,c]=s.useState(!1);return e.jsxs("tr",{className:"border-t border-brand-line",children:[e.jsx("td",{className:"px-3 py-2 font-mono text-[13px]",children:a.code}),e.jsx("td",{className:"px-3 py-2",children:a.influencer_name}),e.jsx("td",{className:"px-3 py-2 tabular-nums",children:a.bonus_pct}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(B,{checked:a.active,disabled:o,onCheckedChange:async r=>{c(!0);try{await l(!!r)}finally{c(!1)}}})}),e.jsx("td",{className:"px-3 py-2 text-brand-muted",children:a.expires_at?new Date(a.expires_at).toLocaleDateString():"None"}),e.jsx("td",{className:"px-3 py-2 tabular-nums",children:a.redemptions}),e.jsx("td",{className:"px-3 py-2 tabular-nums",children:a.credits_granted_total}),e.jsx("td",{className:"px-3 py-2 tabular-nums",children:a.bonus_credits_total}),e.jsx("td",{className:"px-3 py-2 text-brand-muted",children:new Date(a.created_at).toLocaleDateString()})]})}export{Q as component};
2//# sourceMappingURL=admin.referrals-h4Ir82-u.js.map

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.