import { ReactNode } from "react" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion" import { Badge } from "@/components/ui/badge" import { Label } from "@/components/ui/label" import { Input } from "@/components/ui/input" import { Switch } from "@/components/ui/switch" import { Checkbox } from "@/components/ui/checkbox" import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group" import { Slider } from "@/components/ui/slider" import { usePro } from "@/contexts/pro-context" import { ProIndicator } from "@/components/pro/pro-indicator" import { AddedToCartSettings, displayPageOptions } from "../../config" interface SettingsTabProps { settings: AddedToCartSettings updateSettings: (key: K, value: AddedToCartSettings[K]) => void } function PopupSettingsSection({ id, title, description, summary, pro = false, children }: { id: string; title: string; description: string; summary: string; pro?: boolean; children: ReactNode }) { return ( {title}{pro && <> (Pro)} {description} {summary} {children} ) } const popupButtons = [ { toggle: 'showViewCartButton', text: 'viewCartButtonText', label: 'View Cart Button', description: 'Takes the customer to the cart page.' }, { toggle: 'showCheckoutButton', text: 'checkoutButtonText', label: 'Checkout Button', description: 'Takes the customer directly to checkout.' }, { toggle: 'showContinueShoppingButton', text: 'continueShoppingButtonText', label: 'Continue Shopping Button', description: 'Closes the popup and continues shopping.' }, ] as const export function SettingsTab({ settings, updateSettings }: SettingsTabProps) { const { isPro } = usePro() const buttonCount = popupButtons.filter(button => settings[button.toggle]).length return (
Display settings Choose where the popup appears after a product is added to the cart. updateSettings('displayPages', value as AddedToCartSettings['displayPages'])} className="gap-0 divide-y"> {displayPageOptions.map(option => ( ))} {isPro && (
updateSettings('showOnMobile', checked)} />
)}
updateSettings('autoCloseEnabled', checked)} />
{settings.autoCloseEnabled && (
updateSettings('autoCloseDelay', value)} min={2000} max={15000} step={1000} />
)}
updateSettings('animationDuration', value)} min={100} max={500} step={50} />
{isPro && ( <>
{popupButtons.map(button => (
{settings[button.toggle] && updateSettings(button.text, event.target.value)} placeholder="Button text" />}
))}
updateSettings('showRelatedProducts', checked)} />
{settings.showRelatedProducts && (
updateSettings('relatedProductsCount', value)} min={2} max={8} step={1} />
)}
updateSettings('showRecommendedProducts', checked)} />
)}
) }