♻️(frontend) refactor notification preferences to use Field switch

Adopt unified switch component pattern for notification preferences to
enable future addition of descriptive text per notification type,
improving consistency and providing clearer explanation capability
for notification behaviors.
This commit is contained in:
lebaudantoine
2025-10-22 04:59:06 +02:00
committed by aleb_the_flash
parent dbc66c2f07
commit 0c3bcd81c9
5 changed files with 46 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
import { TabPanel, TabPanelProps } from '@/primitives/Tabs' import { TabPanel, TabPanelProps } from '@/primitives/Tabs'
import { H, Switch } from '@/primitives' import { Field, H } from '@/primitives'
import { css } from '@/styled-system/css' import { css } from '@/styled-system/css'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { useSnapshot } from 'valtio' import { useSnapshot } from 'valtio'
@@ -23,15 +23,19 @@ export const NotificationsTab = ({ id }: NotificationsTabProps) => {
{Array.from(notificationsSnap.soundNotifications).map( {Array.from(notificationsSnap.soundNotifications).map(
([key, value]) => ( ([key, value]) => (
<li key={key}> <li key={key}>
<Switch <Field
aria-label={`${t(`actions.${value ? 'disable' : 'enable'}`)} ${t('label')} "${t(`items.${key}`)}"`} type="switch"
aria-label={`${t(`actions.${value ? 'disable' : 'enable'}`)} ${t('label')} "${t(`items.${key}.label`)}"`}
label={t(`items.${key}.label`)}
isSelected={value} isSelected={value}
onChange={(v) => { onChange={(v) => {
notificationsStore.soundNotifications.set(key, v) notificationsStore.soundNotifications.set(key, v)
}} }}
> wrapperProps={{
{t(`items.${key}`)} noMargin: true,
</Switch> fullWidth: true,
}}
/>
</li> </li>
) )
)} )}

View File

@@ -76,9 +76,15 @@
"enable": "Aktivieren" "enable": "Aktivieren"
}, },
"items": { "items": {
"participantJoined": "Teilnehmer beigetreten", "participantJoined": {
"handRaised": "Hand gehoben", "label": "Teilnehmer beigetreten"
"messageReceived": "Nachricht erhalten" },
"handRaised": {
"label": "Hand gehoben"
},
"messageReceived": {
"label": "Nachricht erhalten"
}
} }
}, },
"dialog": { "dialog": {

View File

@@ -76,9 +76,15 @@
"enable": "Enable" "enable": "Enable"
}, },
"items": { "items": {
"participantJoined": "Participant joined", "participantJoined": {
"handRaised": "Hand raised", "label": "Participant joined"
"messageReceived": "Message received" },
"handRaised": {
"label": "Hand raised"
},
"messageReceived": {
"label": "Message received"
}
} }
}, },
"dialog": { "dialog": {

View File

@@ -76,9 +76,15 @@
"enable": "Activer" "enable": "Activer"
}, },
"items": { "items": {
"participantJoined": "Un nouveau participant", "participantJoined": {
"handRaised": "Une main levée", "label": "Un nouveau participant"
"messageReceived": "Un message reçu" },
"handRaised": {
"label": "Une main levée"
},
"messageReceived": {
"label": "Un message reçu"
}
} }
}, },
"dialog": { "dialog": {

View File

@@ -76,9 +76,15 @@
"enable": "Inschakelen" "enable": "Inschakelen"
}, },
"items": { "items": {
"participantJoined": "Deelnemer is toegevoegd", "participantJoined": {
"handRaised": "Hand opgestoken", "label": "Deelnemer is toegevoegd"
"messageReceived": "Bericht ontvangen" },
"handRaised": {
"label": "Hand opgestoken"
},
"messageReceived": {
"label": "Bericht ontvangen"
}
} }
}, },
"dialog": { "dialog": {