feat: updated notification preferences unsubscribe flow (#1778)
This commit is contained in:
committed by
GitHub
parent
2b4a9661a5
commit
579bd0365b
@@ -22,7 +22,7 @@ export const DECODE_ROUTES = {
|
|||||||
|
|
||||||
export const ROUTES = {
|
export const ROUTES = {
|
||||||
UNSUBSCRIBE: '/goal-unsubscribe/:token',
|
UNSUBSCRIBE: '/goal-unsubscribe/:token',
|
||||||
PREFERENCES_UNSUBSCRIBE: '/preferences-unsubscribe/:userToken/:updatePatch',
|
PREFERENCES_UNSUBSCRIBE: '/preferences-unsubscribe/:userToken/:updatePatch?',
|
||||||
REDIRECT: '/redirect/*',
|
REDIRECT: '/redirect/*',
|
||||||
DASHBOARD: 'dashboard',
|
DASHBOARD: 'dashboard',
|
||||||
ENTERPRISE_LEARNER_DASHBOARD: 'enterprise-learner-dashboard',
|
ENTERPRISE_LEARNER_DASHBOARD: 'enterprise-learner-dashboard',
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { getConfig } from '@edx/frontend-platform';
|
import { getConfig } from '@edx/frontend-platform';
|
||||||
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
|
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
|
||||||
|
|
||||||
export const getUnsubscribeUrl = (userToken, updatePatch) => (
|
export const getUnsubscribeUrl = (userToken) => (
|
||||||
`${getConfig().LMS_BASE_URL}/api/notifications/preferences/update/${userToken}/${updatePatch}/`
|
`${getConfig().LMS_BASE_URL}/api/notifications/preferences/update/${userToken}/`
|
||||||
);
|
);
|
||||||
|
|
||||||
export async function unsubscribeNotificationPreferences(userToken, updatePatch) {
|
export async function unsubscribeNotificationPreferences(userToken) {
|
||||||
const url = getUnsubscribeUrl(userToken, updatePatch);
|
const url = getUnsubscribeUrl(userToken);
|
||||||
return getAuthenticatedHttpClient().get(url);
|
return getAuthenticatedHttpClient().get(url);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,18 +17,18 @@ import messages from './messages';
|
|||||||
|
|
||||||
const PreferencesUnsubscribe = () => {
|
const PreferencesUnsubscribe = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { userToken, updatePatch } = useParams();
|
const { userToken } = useParams();
|
||||||
const [status, setStatus] = useState(LOADING);
|
const [status, setStatus] = useState(LOADING);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
unsubscribeNotificationPreferences(userToken, updatePatch).then(
|
unsubscribeNotificationPreferences(userToken).then(
|
||||||
() => setStatus(LOADED),
|
() => setStatus(LOADED),
|
||||||
(error) => {
|
(error) => {
|
||||||
setStatus(FAILED);
|
setStatus(FAILED);
|
||||||
logError(error);
|
logError(error);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
sendTrackEvent('edx.ui.lms.notifications.preferences.unsubscribe', { userToken, updatePatch });
|
sendTrackEvent('edx.ui.lms.notifications.preferences.unsubscribe', { userToken });
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const pageContent = {
|
const pageContent = {
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ describe('Notification Preferences One Click Unsubscribe', () => {
|
|||||||
let component;
|
let component;
|
||||||
let store;
|
let store;
|
||||||
const userToken = '1234';
|
const userToken = '1234';
|
||||||
const updatePatch = 'abc123';
|
const url = getUnsubscribeUrl(userToken);
|
||||||
const url = getUnsubscribeUrl(userToken, updatePatch);
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await initializeTestStore();
|
await initializeTestStore();
|
||||||
@@ -39,7 +38,7 @@ describe('Notification Preferences One Click Unsubscribe', () => {
|
|||||||
component = (
|
component = (
|
||||||
<AppProvider store={store} wrapWithRouter={false}>
|
<AppProvider store={store} wrapWithRouter={false}>
|
||||||
<UserMessagesProvider>
|
<UserMessagesProvider>
|
||||||
<MemoryRouter initialEntries={[`${`/preferences-unsubscribe/${userToken}/${updatePatch}/`}`]}>
|
<MemoryRouter initialEntries={[`${`/preferences-unsubscribe/${userToken}/`}`]}>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path={ROUTES.PREFERENCES_UNSUBSCRIBE} element={<PreferencesUnsubscribe />} />
|
<Route path={ROUTES.PREFERENCES_UNSUBSCRIBE} element={<PreferencesUnsubscribe />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
@@ -69,7 +68,6 @@ describe('Notification Preferences One Click Unsubscribe', () => {
|
|||||||
expect(screen.getByTestId('heading-text')).toHaveTextContent('Error unsubscribing from preference');
|
expect(screen.getByTestId('heading-text')).toHaveTextContent('Error unsubscribing from preference');
|
||||||
expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.notifications.preferences.unsubscribe', {
|
expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.notifications.preferences.unsubscribe', {
|
||||||
userToken,
|
userToken,
|
||||||
updatePatch,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user