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, includingid
,login
,name
, andemail
.
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, includingname
,email
, andmessage
.
Returns:
Promise<boolean>
: A promise that resolves totrue
if both emails were successfully sent, andfalse
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);
};
==========