caelum0x d56639a594
Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

105 lines
3.1 KiB
TypeScript

"use client";
import * as React from "react";
import { Coins, Gift, Users } from "lucide-react";
import type { Referral } from "@/lib/types";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { CopyButton } from "./CopyButton";
interface ReferralCardProps {
readonly referral: Referral;
/**
* Fully-qualified shareable sign-up link embedding the referral code. Empty
* until the browser origin resolves on the client (avoids SSR mismatch).
*/
readonly shareUrl: string;
}
/**
* Displays the caller's referral code, a shareable invite link, and lifetime
* stats (people referred + credits earned), each with copy-to-clipboard.
*/
export function ReferralCard({ referral, shareUrl }: ReferralCardProps) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Gift className="size-5 text-primary" aria-hidden />
Invite friends, earn credits
</CardTitle>
<CardDescription>
Share your code or link. When a friend signs up and redeems it, you
both get bonus render credits.
</CardDescription>
</CardHeader>
<CardContent className="space-y-6">
<div className="space-y-2">
<Label htmlFor="referral-code">Your referral code</Label>
<div className="flex items-center gap-2">
<Input
id="referral-code"
readOnly
value={referral.code}
onFocus={(e) => e.currentTarget.select()}
className="font-mono tracking-wide"
/>
<CopyButton value={referral.code} label="Copy code" />
</div>
</div>
<div className="space-y-2">
<Label htmlFor="referral-link">Shareable link</Label>
<div className="flex items-center gap-2">
<Input
id="referral-link"
readOnly
value={shareUrl}
onFocus={(e) => e.currentTarget.select()}
className="truncate"
/>
<CopyButton value={shareUrl} label="Copy link" />
</div>
</div>
<div className="grid grid-cols-2 gap-3">
<Stat
icon={<Users className="size-4 text-primary" aria-hidden />}
label="Friends referred"
value={referral.referred_count}
/>
<Stat
icon={<Coins className="size-4 text-accent" aria-hidden />}
label="Credits earned"
value={referral.credits_earned}
/>
</div>
</CardContent>
</Card>
);
}
function Stat({
icon,
label,
value,
}: Readonly<{ icon: React.ReactNode; label: string; value: number }>) {
return (
<div className="rounded-lg border border-border bg-secondary/30 p-4">
<div className="flex items-center gap-1.5 text-xs text-muted-foreground">
{icon}
{label}
</div>
<p className="mt-1 text-2xl font-semibold tabular-nums">{value}</p>
</div>
);
}