Sync layouts, typography, and watermark studio for self-hosted OSS.

Unlock features without credits/Stripe, point docs to docs.songs2vid.com, and drop leftover billing admin surfaces.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Songs2YT
2026-07-25 03:50:06 +02:00
co-authored by Cursor
parent bcca0a6e6f
commit d951ecb489
53 changed files with 3258 additions and 1977 deletions
+16 -117
View File
@@ -4,21 +4,12 @@ import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
import { prisma } from "@/lib/db";
import { AccountPrivacyActions } from "@/components/AccountPrivacyActions";
import { PlanBillingActions } from "@/components/PlanBillingActions";
import { DashboardShell } from "@/components/DashboardShell";
import { UpgradeProLink } from "@/components/UpgradeProLink";
import { getUserApiKeyStatus } from "@/lib/api-keys";
import { getApiRateLimitStatus } from "@/lib/api-rate-limit";
import { ApiKeySettings } from "@/components/ApiKeySettings";
import { hasProFeatures, isSelfHostedEdition } from "@/lib/edition";
import { EXTENSION_KIND, getQuotaExtensionUsage } from "@/lib/quota-extensions";
import { getQuotaInfo } from "@/lib/quota";
const PLAN_LABELS = {
FREE: "Bedroom Producer",
PREMIUM: "Pro",
} as const;
function InfoRow({ label, value }: { label: string; value: string }) {
return (
<div className="flex justify-between gap-4">
@@ -39,16 +30,8 @@ export default async function SettingsPage() {
if (!user) redirect("/");
const quota = await getQuotaInfo(user.id);
const selfHosted = isSelfHostedEdition();
const proFeatures = hasProFeatures(user.plan);
const extensionUsage =
!selfHosted && user.plan === "PREMIUM" ? await getQuotaExtensionUsage(user.id) : null;
const apiRateExtensionUsage = proFeatures
? await getQuotaExtensionUsage(user.id, EXTENSION_KIND.API_RATE_LIMIT)
: null;
const apiKeyStatus = proFeatures ? await getUserApiKeyStatus(user.id) : null;
const apiRateLimit = proFeatures ? await getApiRateLimitStatus(user.id) : null;
const planLabel = selfHosted ? "Self-hosted" : PLAN_LABELS[user.plan];
const apiKeyStatus = await getUserApiKeyStatus(user.id);
const apiRateLimit = await getApiRateLimitStatus(user.id);
const youtube = user.youtubeConnection;
const channelUrl = youtube ? `https://www.youtube.com/channel/${youtube.channelId}` : null;
@@ -100,115 +83,31 @@ export default async function SettingsPage() {
</section>
<section className="rounded-lg border border-gray-700 bg-surface-light p-6">
<h2 className="mb-4 text-lg font-semibold text-white">
{selfHosted ? "Usage" : "Plan & billing"}
</h2>
<h2 className="mb-4 text-lg font-semibold text-white">Usage</h2>
<div className="mb-6 rounded border border-gray-800 bg-surface p-4">
<div className="flex flex-wrap items-end justify-between gap-2">
<div>
<p className="text-xs font-semibold uppercase tracking-wider text-gray-500">
Videos processed
</p>
<p className="mt-1 text-2xl font-semibold text-white">
{selfHosted ? (
quota.used
) : (
<>
{quota.remaining}
<span className="text-base font-normal text-gray-400">
{" "}
of {quota.limit} videos
</span>
</>
)}
</p>
</div>
{!selfHosted && (
<p className="text-sm text-gray-400">
{quota.used} used
{quota.bonusQuota > 0 ? ` · +${quota.bonusQuota} bonus` : ""}
</p>
)}
</div>
{!selfHosted && (
<>
<div className="mt-3 h-2 overflow-hidden rounded bg-gray-800">
<div
className={`h-full rounded ${
quota.remaining <= 0
? "bg-red-500"
: quota.remaining / Math.max(1, quota.limit) <= 0.2
? "bg-amber-500"
: "bg-accent"
}`}
style={{
width: `${Math.min(100, Math.round((quota.used / Math.max(1, quota.limit)) * 100))}%`,
}}
/>
</div>
<p className="mt-2 text-xs text-gray-500">
{user.plan === "PREMIUM"
? `Monthly quota resets on ${quota.resetsIn}`
: `Quota resets in ${quota.resetsIn}`}
</p>
</>
)}
{selfHosted && (
<p className="mt-2 text-xs text-gray-500">
Self-hosted edition: no video or API quotas.
<div>
<p className="text-xs font-semibold uppercase tracking-wider text-gray-500">
Videos processed
</p>
)}
<p className="mt-1 text-2xl font-semibold text-white">{quota.used}</p>
</div>
<p className="mt-2 text-xs text-gray-500">
Self-hosted edition: no video credits or quotas.
</p>
</div>
<dl className="space-y-3 text-sm">
<InfoRow label="Current plan" value={planLabel} />
{!selfHosted && user.plan === "PREMIUM" && user.subscribedAt && (
<InfoRow
label="Subscribed since"
value={user.subscribedAt.toLocaleDateString(undefined, {
year: "numeric",
month: "long",
day: "numeric",
})}
/>
)}
{!selfHosted && user.plan === "PREMIUM" && (
<InfoRow
label="Payment method"
value={user.cardLast4 ? `•••• ${user.cardLast4}` : "No card on file"}
/>
)}
{extensionUsage && (
<InfoRow
label="Extension requests (this year)"
value={`${extensionUsage.used} / ${extensionUsage.limit}`}
/>
)}
<InfoRow label="Edition" value="Self-hosted" />
<InfoRow label="Max batch size" value={`${quota.maxBatchSize} videos`} />
<InfoRow label="Max resolution" value={`${quota.maxResolutionHeight}p`} />
</dl>
{!selfHosted && user.plan === "FREE" && (
<p className="mt-4 text-sm text-gray-400">
<UpgradeProLink /> for more videos, 1080p, and lossless audio.
</p>
)}
{!selfHosted && user.plan === "PREMIUM" && extensionUsage && (
<PlanBillingActions initialUsage={extensionUsage} />
)}
</section>
{proFeatures && apiKeyStatus && apiRateLimit && apiRateExtensionUsage && (
<section className="rounded-lg border border-gray-700 bg-surface-light p-6">
<h2 className="mb-4 text-lg font-semibold text-white">API access</h2>
<ApiKeySettings
initialStatus={apiKeyStatus}
initialRateLimit={apiRateLimit}
initialExtensionUsage={apiRateExtensionUsage}
/>
</section>
)}
<section className="rounded-lg border border-gray-700 bg-surface-light p-6">
<h2 className="mb-4 text-lg font-semibold text-white">API access</h2>
<ApiKeySettings initialStatus={apiKeyStatus} initialRateLimit={apiRateLimit} />
</section>
<section className="rounded-lg border border-gray-700 bg-surface-light p-6">
<h2 className="mb-2 text-lg font-semibold text-white">Account deletion &amp; data</h2>