Skip to content

Commit 7fcea7f

Browse files
committed
feat: add success toast
1 parent 757f76f commit 7fcea7f

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/authz-module/libraries-manager/components/PublicReadToggle.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useIntl } from '@edx/frontend-platform/i18n';
22
import { Form } from '@openedx/paragon';
33
import { useLibrary, useUpdateLibrary } from '@src/authz-module/data/hooks';
4+
import { useToastManager } from '../ToastManagerContext';
45

56
import messages from './messages';
67

@@ -13,10 +14,14 @@ const PublicReadToggle = ({ libraryId, canEditToggle }: PublicReadToggleProps) =
1314
const intl = useIntl();
1415
const { data: library } = useLibrary(libraryId);
1516
const { mutate: updateLibrary, isPending } = useUpdateLibrary();
16-
17+
const { handleShowToast } = useToastManager()
1718
const onChangeToggle = () => updateLibrary({
1819
libraryId,
1920
updatedData: { allowPublicRead: !library.allowPublicRead },
21+
}, {
22+
onSuccess: () => {
23+
handleShowToast(intl.formatMessage(messages['libraries.authz.public.read.toggle.success']))
24+
}
2025
});
2126

2227
if (!library) return null;

src/authz-module/libraries-manager/components/messages.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ const messages = defineMessages({
7171
defaultMessage: 'Allows reuse of library content in courses.',
7272
description: 'Library description toggle to allow public read',
7373
},
74+
'libraries.authz.public.read.toggle.success': {
75+
id: 'libraries.authz.public.read.toggle.success',
76+
defaultMessage: 'The library setting has been updated successfully.',
77+
description: 'Sucessfull message for allow public read',
78+
},
7479
});
7580

7681
export default messages;

0 commit comments

Comments
 (0)