refactor toast system to use react-hot-toast
CI / quality (push) Waiting to run

This commit is contained in:
MOH
2026-03-11 21:09:45 +01:00
parent 03384c1bda
commit cff416dd83
12 changed files with 151 additions and 132 deletions
+12 -4
View File
@@ -19,14 +19,18 @@ type LocaleToggleProps = {
locale: string;
className?: string;
showLabel?: boolean;
localeChangedLabels?: Partial<Record<AppLocale, string>>;
};
const localeChangedMessages: Record<AppLocale, string> = {
de: "Sprache auf Deutsch gewechselt",
en: "Language changed to English",
ar: "تم تغيير اللغة إلى العربية",
};
export function LocaleToggle({
locale,
className,
showLabel = false,
localeChangedLabels,
}: LocaleToggleProps) {
const pathname = usePathname();
const locales: AppLocale[] = ["de", "en", "ar"];
@@ -80,7 +84,7 @@ export function LocaleToggle({
<a
href={getLocalizedPath(targetLocale, currentPath)}
onClick={() => {
const message = localeChangedLabels?.[targetLocale];
const message = localeChangedMessages[targetLocale];
if (!message) {
return;
@@ -88,7 +92,11 @@ export function LocaleToggle({
window.sessionStorage.setItem(
PENDING_TOAST_STORAGE_KEY,
JSON.stringify({ message, type: "success" }),
JSON.stringify({
type: "success",
message,
targetLocale,
}),
);
}}
className="group flex h-10 w-10 items-center justify-center rounded-full"