-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[FEAT]: Allow user to set support email #726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT]: Allow user to set support email #726
Conversation
frontend/src/components/UserMenu/index.jsxConsider using the useCallback hook for the handleClose function in the UserButton component. This will prevent unnecessary re-renders of the component when the function is recreated on each render. const handleClose = useCallback((event) => {
if (
menuRef.current &&
!menuRef.current.contains(event.target) &&
!buttonRef.current.contains(event.target)
) {
setShowMenu(false);
}
}, []);Consider using the useCallback hook for the handleOpenAccountModal function in the UserButton component. This will prevent unnecessary re-renders of the component when the function is recreated on each render. const handleOpenAccountModal = useCallback(() => {
setShowAccountSettings(true);
setShowMenu(false);
}, []);frontend/src/pages/GeneralSettings/Appearance/SupportEmail/index.jsxConsider using the useCallback hook for the updateSupportEmail function in the SupportEmail component. This will prevent unnecessary re-renders of the component when the function is recreated on each render. const updateSupportEmail = useCallback(async (e) => {
e.preventDefault();
const form = new FormData(e.target);
const supportEmail = form.get("supportEmail");
const { success, error } = await Admin.updateSystemPreferences({
support_email: supportEmail,
});
if (!success) {
showToast(`Failed to update support email: ${error}`, "error");
return;
} else {
showToast("Successfully updated support email.", "success");
window.localStorage.removeItem(System.cacheKeys.supportEmail);
setHasChanges(false);
}
}, []);Consider using the useCallback hook for the removeEmail function in the SupportEmail component. This will prevent unnecessary re-renders of the component when the function is recreated on each render. const removeEmail = useCallback(async (e) => {
e.preventDefault();
const { success, error } = await Admin.updateSystemPreferences({
support_email: null,
});
if (!success) {
showToast(`Failed to remove support email: ${error}`, "error");
return;
} else {
setSupportEmail("");
showToast("Successfully removed support email.", "success");
window.localStorage.removeItem(System.cacheKeys.supportEmail);
setHasChanges(false);
}
}, []);Consider using the useCallback hook for the onEmailChange function in the SupportEmail component. This will prevent unnecessary re-renders of the component when the function is recreated on each render. const onEmailChange = useCallback((e) => {
setSupportEmail(e.target.value);
setHasChanges(true);
}, []);server/endpoints/admin.jsCreate Issue catch (e) {
console.error(`Error occurred in adminEndpoints: ${e.message}`);
response.sendStatus(500).end();
}Create Issue const settings = await SystemSettings.getAll(); |
* implement custom support email for usermenu support button * small refactor --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
Pull Request Type
Relevant Issues
resolves #707
What is in this change?
Describe the changes in this PR that are impactful to the repo.
Additional Information
Add any other context about the Pull Request here that was not captured above.
Developer Validations
yarn lintfrom the root of the repo & committed changes