feat(i18n): components pack translated

This commit is contained in:
Julien Froidefond
2025-03-02 06:31:41 +01:00
parent d94232e531
commit 2289753b84
8 changed files with 190 additions and 42 deletions

View File

@@ -5,6 +5,7 @@ import { Button } from "./button";
import { useToast } from "./use-toast";
import { ClientOfflineBookService } from "@/lib/services/client-offlinebook.service";
import { useState } from "react";
import { useTranslation } from "react-i18next";
interface MarkAsUnreadButtonProps {
bookId: string;
@@ -15,6 +16,7 @@ interface MarkAsUnreadButtonProps {
export function MarkAsUnreadButton({ bookId, onSuccess, className }: MarkAsUnreadButtonProps) {
const { toast } = useToast();
const [isLoading, setIsLoading] = useState(false);
const { t } = useTranslation();
const handleMarkAsUnread = async (e: React.MouseEvent) => {
e.stopPropagation(); // Empêcher la propagation au parent
@@ -26,19 +28,19 @@ export function MarkAsUnreadButton({ bookId, onSuccess, className }: MarkAsUnrea
});
if (!response.ok) {
throw new Error("Erreur lors de la mise à jour");
throw new Error(t("books.actions.markAsUnread.error.update"));
}
toast({
title: "Succès",
description: "Le tome a été marqué comme non lu",
title: t("books.actions.markAsUnread.success.title"),
description: t("books.actions.markAsUnread.success.description"),
});
onSuccess?.();
} catch (error) {
console.error("Erreur lors de la mise à jour du progresseur de lecture:", error);
toast({
title: "Erreur",
description: "Impossible de marquer le tome comme non lu",
title: t("books.actions.markAsUnread.error.title"),
description: t("books.actions.markAsUnread.error.description"),
variant: "destructive",
});
} finally {
@@ -53,7 +55,7 @@ export function MarkAsUnreadButton({ bookId, onSuccess, className }: MarkAsUnrea
onClick={handleMarkAsUnread}
className={`h-8 w-8 p-0 rounded-br-lg rounded-tl-lg ${className}`}
disabled={isLoading}
aria-label="Marquer comme non lu"
aria-label={t("books.actions.markAsUnread.button")}
>
{isLoading ? <Loader2 className="h-5 w-5 animate-spin" /> : <BookX className="h-5 w-5" />}
</Button>