Changing the alert message for setting page, broke the privacy setting alert message

in this PR feat(client): change setting alert messages to more descriptive messages by Sboonny · Pull Request #49396 · freeCodeCamp/freeCodeCamp (github.com), I tried to change the alert message into something more descriptive.

The issue is that changing the alert message broke the save API for privacy, as shown in the gif below.

rec-tab-3

Notes:

  • it saves the new change in the database.
  • it succeed the API call when press save.
  • it still shows error message, with the success.

here is the old function code

const updatePrivacyTerms = (req, res, next) => {
  const {
    user,
    body: { quincyEmails }
  } = req;
  const update = {
    acceptedPrivacyTerms: true,
    sendQuincyEmail: !!quincyEmails
  };
  return user.updateAttributes(update, err => {
    if (err) {
      res.status(500).json(standardErrorMessage);
      return next(err);
    }
    return res.status(200).json(standardSuccessMessage);
  });
};

The change I did is adding a parameter to createUpdateUserProperties.

function createUpdateUserProperties(buildUpdate, validate, successMessage) 

@Sboonny You are telling the error message to show: feat(client): change setting alert messages to more descriptive messages by Sboonny · Pull Request #49396 · freeCodeCamp/freeCodeCamp · GitHub

function updateMyProfileUI(req, res, next) {
  const {
    user,
    body: { profileUI }
  } = req;
  user.updateAttribute('profileUI', profileUI, err => {
    if (err) {
      res.status(500).json(standardErrorMessage);
      return next(err);
    }
    return res.status(200).json(standardErrorMessage); // LOOK HERE
  });
}
1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.