Add Sonner-based notifications and UX polish

This commit is contained in:
MOH
2026-03-10 17:43:26 +01:00
parent eceb0f3a54
commit 77cc9dca87
32 changed files with 279 additions and 310 deletions
+16
View File
@@ -13,16 +13,20 @@ import {
import { AppLocale, getLocalizedPath, stripLocalePrefix } from "@/lib/locale";
import { cn } from "@/lib/utils";
const PENDING_TOAST_STORAGE_KEY = "mohfarawati-pending-toast";
type LocaleToggleProps = {
locale: string;
className?: string;
showLabel?: boolean;
localeChangedLabels?: Partial<Record<AppLocale, string>>;
};
export function LocaleToggle({
locale,
className,
showLabel = false,
localeChangedLabels,
}: LocaleToggleProps) {
const pathname = usePathname();
const locales: AppLocale[] = ["de", "en", "ar"];
@@ -75,6 +79,18 @@ export function LocaleToggle({
>
<a
href={getLocalizedPath(targetLocale, currentPath)}
onClick={() => {
const message = localeChangedLabels?.[targetLocale];
if (!message) {
return;
}
window.sessionStorage.setItem(
PENDING_TOAST_STORAGE_KEY,
JSON.stringify({ message, type: "success" }),
);
}}
className="group flex h-10 w-10 items-center justify-center rounded-full"
>
<Image