"use client"; import { useState } from "react"; import { useI18n } from "@/translations/provider"; import { LoadingSkeleton } from "./loading-skeleton"; import { LoadingBorderSpinner } from "@/components/ui/loading-border-spinner"; type SwipeButtonProps = { onSuccess: () => void | Promise; onCancel?: () => void; text: string; cancelText?: string; disabled?: boolean; isLoading?: boolean; isSubmitting?: boolean; theme?: "default" | "green" | "pink"; }; export function SwipeButton({ onSuccess, onCancel, text, cancelText, disabled = false, isLoading = false, isSubmitting = false, theme = "default", }: SwipeButtonProps) { const { dictionary: t } = useI18n(); const [internalSubmitting, setInternalSubmitting] = useState(false); if (isLoading) { if (onCancel) { return (
); } return (
); } const busy = isSubmitting || internalSubmitting; const handleClick = async () => { if (disabled || busy) return; setInternalSubmitting(true); try { await onSuccess(); } finally { setInternalSubmitting(false); } }; const cancelLabel = cancelText || t?.["Cancel"] || "Cancel"; const buttonBg = theme === "green" ? "bg-[#00AC78]" : theme === "pink" ? "bg-gradient-to-r from-[#FF6687] to-[#FF456C] shadow-[0_8px_16px_rgba(255,69,108,0.25)]" : "bg-[#F0445B]"; const actionButton = ( ); if (onCancel) { return (
{/* Cancel Button */} {/* Action Button */} {actionButton}
); } // Single Button full width return
{actionButton}
; } export default SwipeButton;