Update remote soul-content with local content
This commit is contained in:
56
components/buy-full-book-button.tsx
Normal file
56
components/buy-full-book-button.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
"use client"
|
||||
|
||||
import { useState } from "react"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { useStore } from "@/lib/store"
|
||||
import { PaymentModal } from "@/components/modules/payment/payment-modal"
|
||||
import { AuthModal } from "@/components/modules/auth/auth-modal"
|
||||
|
||||
interface BuyFullBookButtonProps {
|
||||
price: number
|
||||
className?: string
|
||||
size?: "default" | "sm" | "lg" | "icon"
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export function BuyFullBookButton({ price, className, size = "default", children }: BuyFullBookButtonProps) {
|
||||
const [isPaymentOpen, setIsPaymentOpen] = useState(false)
|
||||
const [isAuthOpen, setIsAuthOpen] = useState(false)
|
||||
const { isLoggedIn } = useStore()
|
||||
|
||||
const handleClick = () => {
|
||||
if (!isLoggedIn) {
|
||||
setIsAuthOpen(true)
|
||||
return
|
||||
}
|
||||
setIsPaymentOpen(true)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
size={size}
|
||||
className={className}
|
||||
onClick={handleClick}
|
||||
>
|
||||
{children || `购买全书 ¥${price}`}
|
||||
</Button>
|
||||
|
||||
<AuthModal
|
||||
isOpen={isAuthOpen}
|
||||
onClose={() => setIsAuthOpen(false)}
|
||||
/>
|
||||
|
||||
<PaymentModal
|
||||
isOpen={isPaymentOpen}
|
||||
onClose={() => setIsPaymentOpen(false)}
|
||||
type="fullbook"
|
||||
amount={price}
|
||||
onSuccess={() => {
|
||||
// Refresh or redirect
|
||||
window.location.reload()
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user