[WEB-2419] chore: add toast alerts post access change of a page#5569
[WEB-2419] chore: add toast alerts post access change of a page#5569
Conversation
WalkthroughThe pull request updates the Changes
Possibly related PRs
Suggested labels
Poem
Tip New featuresWalkthrough comment now includes:
Notes:
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
| action: async () => { | ||
| const changedPageType = access === 0 ? "private" : "public"; | ||
|
|
||
| try { | ||
| if (access === 0) await makePrivate(); | ||
| else await makePublic(); | ||
|
|
||
| setToast({ | ||
| type: TOAST_TYPE.SUCCESS, | ||
| title: "Success!", | ||
| message: `The page has been marked ${changedPageType} and moved to the ${changedPageType} section.`, | ||
| }); | ||
| } catch (err) { | ||
| setToast({ | ||
| type: TOAST_TYPE.ERROR, | ||
| title: "Error!", | ||
| message: `The page couldn't be marked ${changedPageType}. Please try again.`, | ||
| }); | ||
| } | ||
| }, |
There was a problem hiding this comment.
Approve changes with suggestions for enhanced error handling.
The asynchronous function within the action property of MENU_ITEMS is well-implemented, providing clear user feedback through toast notifications. The use of a try-catch block for error handling is a good practice.
However, consider enhancing the error handling by logging the error or providing more detailed feedback to the user. This could help in diagnosing issues more effectively in production.
+ import { logError } from "@/helpers/error.helper";
try {
if (access === 0) await makePrivate();
else await makePublic();
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: `The page has been marked ${changedPageType} and moved to the ${changedPageType} section.`,
});
} catch (err) {
logError(err); // Log the error for better diagnostics
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: `The page couldn't be marked ${changedPageType}. Please try again. Error: ${err.message}`,
});
}Committable suggestion was skipped due to low confidence.
Improvements:
A toast alert now appears when the user changes the access of a page.
Media:
Screen.Recording.2024-09-09.at.20.47.49.mov
Plane issue: WEB-2419
Summary by CodeRabbit
New Features
Bug Fixes