diff --git a/components/settings/settings-page.tsx b/components/settings/settings-page.tsx index a3d3160..2ea5aee 100644 --- a/components/settings/settings-page.tsx +++ b/components/settings/settings-page.tsx @@ -2,6 +2,7 @@ import { useEffect, useMemo, useState } from "react"; import { Bell, BellRing, Clock3, Languages, MapPinned, Palette, Settings, Smartphone } from "lucide-react"; +import type { LucideIcon } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { LanguageToggle } from "@/components/ui/language-toggle"; @@ -56,6 +57,49 @@ function SettingsRow({ icon: Icon, title, description, children }: { icon: typeo ); } +function SwitchIndicator({ checked, disabled }: { checked: boolean; disabled?: boolean }) { + return ( + + + + ); +} + +function NotificationSwitchLabel({ icon: Icon, title, description, checked, disabled, onChange }: { icon: LucideIcon; title: string; description: string; checked: boolean; disabled?: boolean; onChange: (checked: boolean) => void }) { + return ( + + onChange(event.target.checked)} + className="sr-only" + /> + + + + {title} + + {description} + + + + ); +} + export function SettingsPage() { const { language, t } = useI18n(); const [notificationStatus, setNotificationStatus] = useState("checking"); @@ -371,55 +415,55 @@ export function SettingsPage() { - - {t("settings.notifications.enable")} - {t("settings.notifications.enableDescription")} - {notificationMessage && {notificationMessage}} - - - - updateMorningBriefPreference(event.target.checked)} - className="mt-1 accent-accent" - /> - + + - - {t("settings.notifications.morningBrief")} + + {t("settings.notifications.enable")} - {t("settings.notifications.morningBriefDescription")} - - - - - updateTomorrowBriefPreference(event.target.checked)} - className="mt-1 accent-accent" - /> - - - - {t("settings.notifications.tomorrowBrief")} + {t("settings.notifications.enableDescription")} + + {isSavingSubscription + ? t("settings.notifications.saving") + : notificationsEnabled + ? t("settings.notifications.enabledStatus") + : t("settings.notifications.disabledStatus")} - {t("settings.notifications.tomorrowBriefDescription")} - + + + {notificationMessage && {notificationMessage}} - - - - {isSavingSubscription - ? t("settings.notifications.saving") - : notificationsEnabled - ? t("settings.notifications.disable") - : t("settings.notifications.enableDevice")} - + + + + + {isSendingTestNotification ? t("settings.notifications.sendingTest") : t("settings.notifications.sendTest")} diff --git a/lib/i18n.tsx b/lib/i18n.tsx index 44078c3..74231fa 100644 --- a/lib/i18n.tsx +++ b/lib/i18n.tsx @@ -42,6 +42,8 @@ const translations = { "settings.notifications.tomorrowBriefDescription": "Wysyła wieczorem krótką prognozę na kolejny dzień, w tym sygnały burz i opadów z modelu.", "settings.notifications.enableDevice": "Włącz na tym urządzeniu", "settings.notifications.disable": "Wyłącz na tym urządzeniu", + "settings.notifications.enabledStatus": "Włączone", + "settings.notifications.disabledStatus": "Wyłączone", "settings.notifications.saving": "Zapisuję…", "settings.notifications.saveSuccess": "Powiadomienia są włączone dla tego urządzenia.", "settings.notifications.disableSuccess": "Powiadomienia są wyłączone dla tego urządzenia.", @@ -276,6 +278,8 @@ const translations = { "settings.notifications.tomorrowBriefDescription": "Sends a short evening forecast for the next day, including storm and rain signals from the model.", "settings.notifications.enableDevice": "Enable on this device", "settings.notifications.disable": "Disable on this device", + "settings.notifications.enabledStatus": "Enabled", + "settings.notifications.disabledStatus": "Disabled", "settings.notifications.saving": "Saving…", "settings.notifications.saveSuccess": "Notifications are enabled for this device.", "settings.notifications.disableSuccess": "Notifications are disabled for this device.",
{t("settings.notifications.enable")}
{t("settings.notifications.enableDescription")}
{notificationMessage}