Class: Contact

Description: This component is a functional React component responsible for rendering a contact form modal. It allows users to send messages through a pre-configured email system.

Parameters:

  • user (Object): An object containing user information, including id, login, name, and email.

Methods


Method: send

Description: This async method handles the submission of the contact form. It extracts the user's input, constructs email data, and sends emails to both the administrator and the user.

Parameters:

  • elements (Object): An object containing form fields, including name, email, and message.

Returns:

  • Promise<boolean>: A promise that resolves to true if both emails were successfully sent, and false otherwise.

Throws:

  • Error: This method may throw an error if there is an issue sending the emails.

Example:

// Example usage within the Contact component
const send = async (elements) => {
  try {
    // ... code implementation
  } catch (error) {
    console.log("Error saving data:", error);
    return false;
  }
};

Method: close

Description: This method closes the contact form modal and removes the contact hashtag from the URL.

Returns:

  • void

Example:

// Example usage within the Contact component
const close = () => {
  history.replace(window.location.pathname + window.location.search);
  setType(null);
};

==========