diff --git a/frontend/src/components/toast.tsx b/frontend/src/components/toast.tsx index 4a36596..3c124b1 100644 --- a/frontend/src/components/toast.tsx +++ b/frontend/src/components/toast.tsx @@ -1,5 +1,6 @@ import { createContext, useCallback, useContext, useState, type ReactNode } from "react"; import { cn } from "../ui/index.js"; +import { useI18n } from "../lib/i18n.js"; import { CloseIcon } from "./icons.js"; type ToastTone = "success" | "error" | "info"; @@ -29,6 +30,7 @@ export const useToast = () => { let toastId = 0; export const ToastProvider = ({ children }: { children: ReactNode }) => { + const { t } = useI18n(); const [toasts, setToasts] = useState([]); const remove = useCallback((id: number) => { @@ -51,23 +53,23 @@ export const ToastProvider = ({ children }: { children: ReactNode }) => { {children}
- {toasts.map((t) => ( + {toasts.map((toastItem) => (
-

{t.message}

+

{toastItem.message}

diff --git a/frontend/src/lib/i18n.tsx b/frontend/src/lib/i18n.tsx index 1759980..fe3de90 100644 --- a/frontend/src/lib/i18n.tsx +++ b/frontend/src/lib/i18n.tsx @@ -192,6 +192,18 @@ const en: Record = { "Déposez vos fichiers ici": "Drop your files here", "{count} fichier(s) déposé(s) dans {name}.": "{count} file(s) uploaded to {name}.", "{count} fichier(s) déposé(s) dans ce dossier.": "{count} file(s) uploaded to this folder.", + "Envoi en cours": "Uploading", + "Envoi {current}/{total}…": "Uploading {current}/{total}…", + "{current}/{total}": "{current}/{total}", + + // --- Sélection multiple ----------------------------------------------- + "Sélectionner {name}": "Select {name}", + "{count} élément(s) sélectionné(s).": "{count} item(s) selected.", + "Annuler la sélection": "Clear selection", + "Déplacer {count} éléments": "Move {count} items", + "{count} éléments seront déplacés.": "{count} items will be moved.", + "{count} élément(s) seront placés dans la corbeille.": + "{count} item(s) will be moved to the trash.", // --- Visionneuse ------------------------------------------------------- "Lecture impossible.": "Unable to read.", diff --git a/frontend/src/pages/Browser.tsx b/frontend/src/pages/Browser.tsx index 9186820..dd632eb 100644 --- a/frontend/src/pages/Browser.tsx +++ b/frontend/src/pages/Browser.tsx @@ -339,6 +339,35 @@ export const Browser = () => { } }; + const removeSelected = async () => { + const ok = await confirm({ + title: t("Mettre à la corbeille"), + message: t("{count} élément(s) seront placés dans la corbeille.", { + count: selectedItems.length, + }), + confirmLabel: t("Corbeille"), + tone: "danger", + }); + if (!ok) return; + setError(null); + try { + for (const target of selectedItems) { + if (target.type === "folder") await api.deleteFolder(target.id); + else await api.deleteFile(target.id); + } + clearSelection(); + await reload(); + void refresh(); + } catch (caught) { + const msg = + caught instanceof ApiError + ? caught.message + : t("Suppression impossible."); + setError(msg); + toast.error(msg); + } + }; + const toggleStar = async (file: UploadedFile) => { setError(null); try { @@ -603,21 +632,26 @@ export const Browser = () => { > {t("Déplacer")} + @@ -677,15 +711,17 @@ export const Browser = () => { aria-label={t("Sélectionner {name}", { name: folder.name, })} - onChange={(event) => { - event.stopPropagation(); - toggleSelection(`f:${folder.id}`); - }} + onClick={(event) => event.stopPropagation()} + onChange={() => toggleSelection(`f:${folder.id}`)} />