mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
feat: in-app Buy Credits dialog and pricing updates (#434)
## Summary - Fix broken "Buy More Credits" flow for logged-in users — replaces redirect (which bounced back to `/app`) with an in-app dialog - Add `BuyCreditsDialog` component following the existing `FeedbackDialog` pattern - Make credits count in header clickable to open the buy dialog - Update "Made For You" pricing from $15 to $50 (frontend labels + Stripe backend) - Update hero section: "Create It Yourself ($5)", green "2 free credits" message, remove redundant line, tighten spacing ## Test plan - [ ] Log in, click "Buy More Credits" in dropdown — dialog opens with package grid - [ ] Click credits count in header — same dialog opens - [ ] Select package, click "Continue to Payment" — redirects to Stripe checkout - [ ] Landing page pricing still works for unauthenticated users - [ ] Made For You order form shows $50 pricing - [ ] Hero section shows updated copy and tighter spacing <!-- @coderabbitai ignore --> 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
9511d03912
commit
a8ea9e6d38
6 files changed
+169
-20
No files matched your search
@@ -48,7 +48,7 @@ CREDIT_PACKAGES = {
|
||||
|
||||
# Made-for-you service package (not a credit package - creates a job directly)
|
||||
MADE_FOR_YOU_PACKAGE = {
|
||||
"price_cents": 1500, # $15.00
|
||||
"price_cents": 5000, # $50.00
|
||||
"name": "Made For You Karaoke Video",
|
||||
"description": "Professional 4K karaoke video with perfectly synced lyrics, delivered to your email within 24 hours",
|
||||
"images": ["https://gen.nomadkaraoke.com/nomad-logo.png"],
|
||||
|
||||
+7
-10
@@ -212,7 +212,7 @@ export default function LandingPage() {
|
||||
</nav>
|
||||
|
||||
{/* Hero Section */}
|
||||
<section className="pt-32 pb-16 px-4">
|
||||
<section className="pt-32 pb-6 px-4">
|
||||
<div className="max-w-4xl mx-auto text-center">
|
||||
<h1 className="text-4xl sm:text-5xl md:text-6xl font-extrabold mb-6 leading-tight">
|
||||
Create a <span className="gradient-text">Karaoke Video</span> for Any Song
|
||||
@@ -231,9 +231,9 @@ export default function LandingPage() {
|
||||
>
|
||||
<Video className="w-5 h-5" />
|
||||
Create It Yourself
|
||||
<span className="ml-1 px-2 py-0.5 bg-white/20 rounded-full text-sm">Free</span>
|
||||
<span className="ml-1 px-2 py-0.5 bg-white/20 rounded-full text-sm">$5</span>
|
||||
</button>
|
||||
<span className="text-dark-400 text-sm">2 free credits included — review lyrics yourself</span>
|
||||
<span className="text-green-400 text-sm">2 free credits included - no payment required</span>
|
||||
</div>
|
||||
<div className="flex flex-col items-center gap-2">
|
||||
<a
|
||||
@@ -242,15 +242,12 @@ export default function LandingPage() {
|
||||
>
|
||||
<Gift className="w-5 h-5" />
|
||||
We'll Make It For You
|
||||
<span className="ml-1 px-2 py-0.5 bg-yellow-500/20 rounded-full text-sm">$15</span>
|
||||
<span className="ml-1 px-2 py-0.5 bg-yellow-500/20 rounded-full text-sm">$50</span>
|
||||
</a>
|
||||
<span className="text-yellow-400/70 text-sm">We handle everything, delivered in 24h</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className="text-green-400 text-sm font-medium mt-2">
|
||||
Every account includes 2 free credits — no payment required
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -529,7 +526,7 @@ export default function LandingPage() {
|
||||
<h2 className="text-3xl font-bold mb-4">We'll Make It For You</h2>
|
||||
<p className="text-dark-400 max-w-2xl mx-auto mb-4">
|
||||
Don't want to use the Generator and review the lyrics yourself? No problem.
|
||||
Tell us the song, pay $15, and we'll deliver your karaoke video within 24 hours.
|
||||
Tell us the song, pay $50, and we'll deliver your karaoke video within 24 hours.
|
||||
</p>
|
||||
<p className="text-dark-500 text-sm max-w-xl mx-auto">
|
||||
Don't want to spend 10 minutes reviewing lyrics? For just $10 more than DIY, we handle everything.
|
||||
@@ -624,7 +621,7 @@ export default function LandingPage() {
|
||||
<div className="bg-dark-800 border border-dark-700 rounded-2xl p-6 sm:p-8">
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<h3 className="text-xl font-semibold">Order a Video</h3>
|
||||
<div className="text-2xl font-bold text-primary-400">$15</div>
|
||||
<div className="text-2xl font-bold text-primary-400">$50</div>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleMadeForYouSubmit} className="space-y-5">
|
||||
@@ -774,7 +771,7 @@ export default function LandingPage() {
|
||||
) : (
|
||||
<>
|
||||
<CreditCard className="w-5 h-5" />
|
||||
Pay $15 & Order
|
||||
Pay $50 & Order
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
|
||||
@@ -17,6 +17,7 @@ import { useAuth } from "@/lib/auth"
|
||||
import { useAdminSettings } from "@/lib/admin-settings"
|
||||
import { AuthDialog } from "./AuthDialog"
|
||||
import { FeedbackDialog } from "@/components/feedback/FeedbackDialog"
|
||||
import { BuyCreditsDialog } from "@/components/credits/BuyCreditsDialog"
|
||||
|
||||
interface AuthStatusProps {
|
||||
onAuthChange?: () => void
|
||||
@@ -27,6 +28,7 @@ export function AuthStatus({ onAuthChange }: AuthStatusProps) {
|
||||
const { showTestData, setShowTestData } = useAdminSettings()
|
||||
const [showAuthDialog, setShowAuthDialog] = useState(false)
|
||||
const [showFeedbackDialog, setShowFeedbackDialog] = useState(false)
|
||||
const [showBuyCreditsDialog, setShowBuyCreditsDialog] = useState(false)
|
||||
const [mounted, setMounted] = useState(false)
|
||||
|
||||
// Avoid hydration mismatch
|
||||
@@ -47,12 +49,7 @@ export function AuthStatus({ onAuthChange }: AuthStatusProps) {
|
||||
}
|
||||
|
||||
const handleBuyCredits = () => {
|
||||
// Navigate to landing page pricing section with email prefilled if available
|
||||
const buyUrl = new URL('/#pricing', window.location.origin)
|
||||
if (user?.email) {
|
||||
buyUrl.searchParams.set("email", user.email)
|
||||
}
|
||||
window.location.href = buyUrl.toString()
|
||||
setShowBuyCreditsDialog(true)
|
||||
}
|
||||
|
||||
// Don't render until mounted (avoids hydration issues)
|
||||
@@ -74,7 +71,14 @@ export function AuthStatus({ onAuthChange }: AuthStatusProps) {
|
||||
<span className="hidden sm:inline max-w-[150px] truncate">
|
||||
{user.display_name || user.email}
|
||||
</span>
|
||||
<span className="flex items-center gap-1 text-warning font-medium">
|
||||
<span
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleBuyCredits()
|
||||
}}
|
||||
className="flex items-center gap-1 text-warning font-medium hover:text-warning/80 transition-colors cursor-pointer"
|
||||
title="Buy more credits"
|
||||
>
|
||||
<Coins className="w-3 h-3" />
|
||||
{user.credits} {user.credits === 1 ? 'credit' : 'credits'}
|
||||
</span>
|
||||
@@ -150,6 +154,10 @@ export function AuthStatus({ onAuthChange }: AuthStatusProps) {
|
||||
open={showFeedbackDialog}
|
||||
onClose={() => setShowFeedbackDialog(false)}
|
||||
/>
|
||||
<BuyCreditsDialog
|
||||
open={showBuyCreditsDialog}
|
||||
onClose={() => setShowBuyCreditsDialog(false)}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect } from 'react'
|
||||
import { CreditCard, Loader2 } from 'lucide-react'
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { api, CreditPackage } from '@/lib/api'
|
||||
import { useAuth } from '@/lib/auth'
|
||||
|
||||
interface BuyCreditsDialogProps {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
const formatPrice = (cents: number) => `$${(cents / 100).toFixed(0)}`
|
||||
const pricePerVideo = (pkg: CreditPackage) =>
|
||||
`$${(pkg.price_cents / 100 / pkg.credits).toFixed(2)}`
|
||||
|
||||
export function BuyCreditsDialog({ open, onClose }: BuyCreditsDialogProps) {
|
||||
const { user } = useAuth()
|
||||
const [packages, setPackages] = useState<CreditPackage[]>([])
|
||||
const [selectedPackage, setSelectedPackage] = useState<CreditPackage | null>(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [checkoutLoading, setCheckoutLoading] = useState(false)
|
||||
const [error, setError] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
setError('')
|
||||
setLoading(true)
|
||||
api.getCreditPackages()
|
||||
.then((pkgs) => {
|
||||
setPackages(pkgs)
|
||||
// Pre-select best value package (5 credits) or first
|
||||
const bestValue = pkgs.find((p) => p.credits === 5) || pkgs[0]
|
||||
setSelectedPackage(bestValue)
|
||||
})
|
||||
.catch((err) => {
|
||||
setError(err instanceof Error ? err.message : 'Failed to load packages')
|
||||
})
|
||||
.finally(() => setLoading(false))
|
||||
}, [open])
|
||||
|
||||
const handleCheckout = async () => {
|
||||
if (!selectedPackage || !user?.email) return
|
||||
setCheckoutLoading(true)
|
||||
setError('')
|
||||
try {
|
||||
const checkoutUrl = await api.createCheckout(selectedPackage.id, user.email)
|
||||
window.location.href = checkoutUrl
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to create checkout session')
|
||||
setCheckoutLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={(isOpen) => !isOpen && onClose()}>
|
||||
<DialogContent className="sm:max-w-md bg-card border-border">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-foreground flex items-center gap-2">
|
||||
<CreditCard className="w-5 h-5 text-primary" />
|
||||
Buy More Credits
|
||||
</DialogTitle>
|
||||
<DialogDescription className="text-muted-foreground">
|
||||
Each credit creates one karaoke video. Pick a package below.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="space-y-4 mt-2">
|
||||
{loading && (
|
||||
<div className="flex justify-center py-8">
|
||||
<Loader2 className="w-6 h-6 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{error && (
|
||||
<div className="text-center py-4 text-sm text-destructive">{error}</div>
|
||||
)}
|
||||
|
||||
{!loading && !error && packages.length > 0 && (
|
||||
<>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
{packages.map((pkg) => {
|
||||
const isSelected = selectedPackage?.id === pkg.id
|
||||
const isBestValue = pkg.credits === 5
|
||||
const savings = pkg.credits > 1
|
||||
? Math.round((1 - pkg.price_cents / (pkg.credits * 500)) * 100)
|
||||
: 0
|
||||
|
||||
return (
|
||||
<button
|
||||
key={pkg.id}
|
||||
onClick={() => setSelectedPackage(pkg)}
|
||||
className={`relative p-4 rounded-xl border-2 transition-all text-left ${
|
||||
isSelected
|
||||
? 'border-primary bg-primary/10'
|
||||
: 'border-border hover:border-muted-foreground/50 bg-secondary/50'
|
||||
}`}
|
||||
>
|
||||
{isBestValue && (
|
||||
<span className="absolute -top-2.5 left-1/2 -translate-x-1/2 bg-primary text-primary-foreground text-xs font-semibold px-2 py-0.5 rounded-full">
|
||||
Best Value
|
||||
</span>
|
||||
)}
|
||||
<div className="text-2xl font-bold">{pkg.credits}</div>
|
||||
<div className="text-sm text-muted-foreground mb-1">
|
||||
{pkg.credits === 1 ? 'credit' : 'credits'}
|
||||
</div>
|
||||
<div className="text-lg font-semibold text-primary">
|
||||
{formatPrice(pkg.price_cents)}
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground">{pricePerVideo(pkg)}/video</div>
|
||||
{savings > 0 && (
|
||||
<div className="text-xs text-green-500 mt-1">Save {savings}%</div>
|
||||
)}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
onClick={handleCheckout}
|
||||
disabled={!selectedPackage || checkoutLoading}
|
||||
className="w-full"
|
||||
>
|
||||
{checkoutLoading ? (
|
||||
<>
|
||||
<Loader2 className="w-4 h-4 mr-2 animate-spin" />
|
||||
Redirecting to payment...
|
||||
</>
|
||||
) : selectedPackage ? (
|
||||
`Continue to Payment — ${formatPrice(selectedPackage.price_cents)}`
|
||||
) : (
|
||||
'Select a package'
|
||||
)}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "karaoke-gen"
|
||||
version = "0.121.0"
|
||||
version = "0.122.0"
|
||||
description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens."
|
||||
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
|
||||
license = "MIT"
|
||||
|
||||
@@ -130,7 +130,7 @@ def create_made_for_you_checkout(
|
||||
'description': "Professional 4K karaoke video with perfectly synced lyrics",
|
||||
'images': ['https://gen.nomadkaraoke.com/nomad-logo.png'],
|
||||
},
|
||||
'unit_amount': 1500, # $15.00
|
||||
'unit_amount': 5000, # $50.00
|
||||
},
|
||||
'quantity': 1,
|
||||
}],
|
||||
|
||||
Reference in new issue
Block a user