Skip to content

Commit

Permalink
Create notificationSettings.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Dec 4, 2024
1 parent cf48a77 commit e29a920
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/customization/notificationSettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// notificationSettings.js

class NotificationSettings {
constructor(userId) {
this.userId = userId;
this.preferences = {
email: true,
sms: false,
push: true,
newsletter: true,
};
}

// Get current notification preferences
getPreferences() {
return this.preferences;
}

// Update notification preferences
updatePreferences(newPreferences) {
this.preferences = { ...this.preferences, ...newPreferences };
console.log(`Notification preferences updated for user ${this.userId}:`, this.preferences);
}

// Reset to default preferences
resetToDefault() {
this.preferences = {
email: true,
sms: false,
push: true,
newsletter: true,
};
console.log(`Notification preferences reset to default for user ${this.userId}.`);
}
}

// Example usage
const userNotificationSettings = new NotificationSettings('user123');
console.log('Current Preferences:', userNotificationSettings.getPreferences());

userNotificationSettings.updatePreferences({ sms: true, newsletter: false });
console.log('Updated Preferences:', userNotificationSettings.getPreferences());

userNotificationSettings.resetToDefault();
console.log('Preferences after reset:', userNotificationSettings.getPreferences());

0 comments on commit e29a920

Please sign in to comment.