From d9ede44d7d63cf93fdfc3678a8cd9b2eb399837a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Mon, 10 Apr 2023 22:43:28 +0200 Subject: [PATCH] moved functionnal NotificationView into it's dedicated file --- front/views/settings/NotificationView.tsx | 96 +++++++++++++++-------- front/views/settings/SettingsView.tsx | 38 +-------- 2 files changed, 65 insertions(+), 69 deletions(-) diff --git a/front/views/settings/NotificationView.tsx b/front/views/settings/NotificationView.tsx index facbe6b..b0c66d9 100644 --- a/front/views/settings/NotificationView.tsx +++ b/front/views/settings/NotificationView.tsx @@ -1,36 +1,68 @@ import React from "react"; -import { View } from 'react-native'; +import { View } from "react-native"; import { Center, Button, Text, Switch, Heading } from "native-base"; -import { translate } from "../../i18n/i18n"; +import { translate, Translate } from "../../i18n/i18n"; +import { useDispatch } from "react-redux"; +import { RootState, useSelector } from "../../state/Store"; +import { useLanguage } from "../../state/LanguageSlice"; +import { SettingsState, updateSettings } from '../../state/SettingsSlice'; -const NotificationsView = ({navigation}) => { - return ( -
+const NotificationsView = ({ navigation }) => { + const dispatch = useDispatch(); + const settings: SettingsState = useSelector( + (state: RootState) => state.settings + ); + return ( +
+ + + + + Push notifications + { + dispatch(updateSettings({ enablePushNotifications: value })); + }} + /> + + + Email notifications + { + dispatch(updateSettings({ enableMailNotifications: value })); + }} + /> + + + Training reminder + { + dispatch(updateSettings({ enableLessongsReminders: value })); + }} + /> + + + New songs + { + dispatch(updateSettings({ enableReleaseAlerts: value })); + }} + /> + +
+ ); +}; - { translate('notifBtn')} - - - - Push notifications - - - - - Email notifications - - - - - Training reminder - - - - - New songs - - -
- ) -} - -export default NotificationsView; \ No newline at end of file +export default NotificationsView; diff --git a/front/views/settings/SettingsView.tsx b/front/views/settings/SettingsView.tsx index 7251a10..db03126 100644 --- a/front/views/settings/SettingsView.tsx +++ b/front/views/settings/SettingsView.tsx @@ -14,6 +14,7 @@ import { FontAwesome, MaterialCommunityIcons, FontAwesome5 } from '@expo/vector- import ChangePasswordForm from '../../components/forms/changePasswordForm'; import ChangeEmailForm from '../../components/forms/changeEmailForm'; import ProfileSettings from './SettingsProfileView'; +import NotificationsView from './NotificationView'; import API, { APIError } from '../../API'; @@ -158,43 +159,6 @@ export const PreferencesView = ({navigation}) => { ) } -const NotificationsView = ({navigation}) => { - const dispatch = useDispatch(); - const settings: SettingsState = useSelector((state: RootState) => state.settings); - return ( -
- - - - - - Push notifications - { dispatch(updateSettings({ enablePushNotifications: value })) }} - /> - - - Email notifications - { dispatch(updateSettings({ enableMailNotifications: value })) }} - /> - - - Training reminder - { dispatch(updateSettings({ enableLessongsReminders: value })) }} - /> - - - New songs - { dispatch(updateSettings({ enableReleaseAlerts: value })) }} - /> - -
- ) -} - export const PrivacyView = ({navigation}) => { return (