"use client"; import { useState } from "react"; import { api } from "@/lib/api"; import { useToast } from "@/lib/toast-context"; import { RotateCcw } from "lucide-react"; import { Modal } from "@/components/ui/Modal"; import { Button } from "@/components/ui/Button"; interface RemoveProgressButtonProps { audiobookId: string; onProgressRemoved?: () => void; } export function RemoveProgressButton({ audiobookId, onProgressRemoved, }: RemoveProgressButtonProps) { const [isRemoving, setIsRemoving] = useState(false); const [showConfirmModal, setShowConfirmModal] = useState(false); const { toast } = useToast(); const handleRemoveProgress = async () => { setShowConfirmModal(false); setIsRemoving(true); try { await api.deleteAudiobookProgress(audiobookId); toast.success("Progress removed"); onProgressRemoved?.(); } catch (error) { console.error("Failed to remove progress:", error); toast.error("Failed to remove progress"); } finally { setIsRemoving(false); } }; return ( <> setShowConfirmModal(true)} disabled={isRemoving} className="flex items-center gap-2 px-4 py-2 text-sm text-gray-400 hover:text-red-400 transition-colors disabled:opacity-50 rounded-lg hover:bg-white/5" title="Start over from the beginning" > {isRemoving ? "Removing..." : "Start Over"} setShowConfirmModal(false)} title="Remove Progress" footer={ <> setShowConfirmModal(false)} > Cancel Remove Progress > } > Remove your progress for this audiobook? This will reset your position to the beginning. This action cannot be undone. > ); }
Remove your progress for this audiobook? This will reset your position to the beginning.
This action cannot be undone.