fix: fixed issue to update email cadence for account notification type
This commit is contained in:
@@ -28,7 +28,9 @@ const NotificationPreferenceColumn = ({ appId, channel, appPreference }) => {
|
||||
|
||||
const onToggle = useCallback((event, notificationType) => {
|
||||
const { name: notificationChannel } = event.target;
|
||||
const value = notificationChannel === 'email_cadence' ? event.target.innerText : event.target.checked;
|
||||
const appNotificationPreference = appPreferences.find(x => x.id === notificationType);
|
||||
const value = notificationChannel === 'email_cadence' && courseId ? event.target.innerText : event.target.checked;
|
||||
const emailCadence = notificationChannel === 'email_cadence' ? event.target.innerText : appNotificationPreference.emailCadence;
|
||||
|
||||
dispatch(updatePreferenceToggle(
|
||||
courseId,
|
||||
@@ -36,9 +38,10 @@ const NotificationPreferenceColumn = ({ appId, channel, appPreference }) => {
|
||||
notificationType,
|
||||
notificationChannel,
|
||||
value,
|
||||
emailCadence,
|
||||
));
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [appId]);
|
||||
}, [appId, appPreferences]);
|
||||
|
||||
const renderPreference = (preference) => (
|
||||
(preference?.coreNotificationTypes?.length > 0 || preference.id !== 'core') && (
|
||||
|
||||
@@ -38,12 +38,14 @@ export const postPreferenceToggle = async (
|
||||
notificationType,
|
||||
notificationChannel,
|
||||
value,
|
||||
emailCadence,
|
||||
) => {
|
||||
const patchData = snakeCaseObject({
|
||||
notificationApp,
|
||||
notificationType: snakeCase(notificationType),
|
||||
notificationChannel,
|
||||
value,
|
||||
emailCadence,
|
||||
});
|
||||
const url = `${getConfig().LMS_BASE_URL}/api/notifications/preferences/update-all/`;
|
||||
const { data } = await getAuthenticatedHttpClient().post(url, patchData);
|
||||
|
||||
@@ -48,7 +48,7 @@ export const normalizeAccountPreferences = (originalData, updateInfo) => {
|
||||
);
|
||||
|
||||
if (preferenceToUpdate) {
|
||||
preferenceToUpdate[channel] = updatedValue;
|
||||
preferenceToUpdate[camelCase(channel)] = updatedValue;
|
||||
}
|
||||
|
||||
return originalData;
|
||||
@@ -135,6 +135,7 @@ export const updatePreferenceToggle = (
|
||||
notificationType,
|
||||
notificationChannel,
|
||||
value,
|
||||
emailCadence,
|
||||
) => (
|
||||
async (dispatch) => {
|
||||
try {
|
||||
@@ -161,6 +162,7 @@ export const updatePreferenceToggle = (
|
||||
notificationType,
|
||||
notificationChannel,
|
||||
value,
|
||||
emailCadence,
|
||||
);
|
||||
dispatch(fetchNotificationPreferenceSuccess(courseId, camelCaseObject(data), true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user