Set notification settings based on session
This commit is contained in:
parent
af72b25932
commit
85dc440fe8
1 changed files with 26 additions and 5 deletions
|
@ -11,6 +11,7 @@ import { ThemedView } from '@/lib/components/ThemedView';
|
|||
import { ThemedText } from '@/lib/components/ThemedText';
|
||||
import { Request } from '@/lib/services/request';
|
||||
import { useToken } from '@/lib/context/AppProvider';
|
||||
import { Message } from '@/lib/services/message';
|
||||
|
||||
export default function CategoryScreen() {
|
||||
const colorScheme = useColorScheme() ?? 'light';
|
||||
|
@ -26,15 +27,33 @@ export default function CategoryScreen() {
|
|||
|
||||
let currentEdit = '';
|
||||
|
||||
// Load item from storage
|
||||
// Set page title
|
||||
useEffect( () => {
|
||||
// Set page title
|
||||
navigation.setOptions( { title: ( 'Notificaties' ) } );
|
||||
}, [] );
|
||||
|
||||
// Set session data
|
||||
useEffect( () => {
|
||||
if (session.notifications.dayBefore === 'off') {
|
||||
setIsDayBeforeEnabled( false );
|
||||
} else {
|
||||
setIsDayBeforeEnabled( true );
|
||||
setDayBefore( session.notifications.dayBefore );
|
||||
}
|
||||
|
||||
if (session.notifications.sameDay === 'off') {
|
||||
setIsSameDayEnabled( false );
|
||||
} else {
|
||||
setIsSameDayEnabled( true );
|
||||
setSameDay( session.notifications.dayBefore );
|
||||
}
|
||||
}, [ session ] );
|
||||
|
||||
// Update session when something changes
|
||||
useEffect( () => {
|
||||
updateSession();
|
||||
}, [isSameDayEnabled, sameDay, isDayBeforeEnabled, dayBefore] );
|
||||
}, [ isSameDayEnabled, sameDay, isDayBeforeEnabled, dayBefore ] );
|
||||
|
||||
// Open time picker
|
||||
const selectTime = (type: string) => {
|
||||
|
@ -88,9 +107,11 @@ export default function CategoryScreen() {
|
|||
notification_same_day: isSameDayEnabled ? sameDay : 'off',
|
||||
};
|
||||
|
||||
Request.post('sessions/update', postData).then((response) => {
|
||||
console.log('response', response);
|
||||
})
|
||||
Request.post( 'sessions/update', postData ).then( (response) => {
|
||||
if (!response.success) {
|
||||
Message.error( 'Er ging iets mis. Probeer het later opnieuw.' );
|
||||
}
|
||||
} )
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue