"use client"; import { useState } from "react"; import { useI18n } from "@/translations/provider"; import { LoadingSkeleton } from "./loading-skeleton"; import { LoadingThreeDot } from "./loading-three-dot"; type SwipeButtonProps = { onSuccess: () => void; onCancel?: () => void; text: string; cancelText?: string; disabled?: boolean; isLoading?: boolean; theme?: "default" | "green"; }; export function SwipeButton({ onSuccess, onCancel, text, cancelText, disabled = false, isLoading = false, theme = "default", }: SwipeButtonProps) { const { dictionary: t } = useI18n(); const [clicked, setClicked] = useState(false); if (isLoading) { if (onCancel) { return (
); } return (
); } const handleClick = () => { setClicked(true); onSuccess(); }; const cancelLabel = cancelText || t?.["Cancel"] || "Cancel"; const isGreen = theme === "green"; const buttonBg = isGreen ? "bg-[#00AC78]" : "bg-[#F0445B]"; const actionButton = ( ); if (onCancel) { return (
{/* Cancel Button */} {/* Action Button */} {actionButton}
); } // Single Button full width return
{actionButton}
; } export default SwipeButton;