react-icons/fa#FaComment JavaScript Examples

The following examples show how to use react-icons/fa#FaComment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Comments.js    From viade_en1b with MIT License 5 votes vote down vote up
export function Comments(props) {
  const [state, setState] = useState({});
  const { userWebId } = props;

  const CommentButtonText = (
    <span data-testid="Leave-Cooment-text">
      <FormattedMessage id="LeaveComment" />
    </span>
  );
  const handleOpen = () => {
    setState({ ...state, theRoute: props.selectedRoute.name });
  };
  const handleOnSave = () => {
    if (state.comment !== null && state.comment !== "") {
      //Call whatever function to save the comment
      // The comment is save in state.comment
      let routeUri =
        "https://" +
        props.selectedRoute.author +
        "/viade/comments/" +
        props.selectedRoute.id +
        ".jsonld";

      uploadComment(userWebId, routeUri, state.comment).then((response) => {
        props.loadRoutesRequest();
        props.clearRoute();
      });
    }
  };
  const handlerTextArea = (event) => {
    //Call whatever function to save the comment
    setState({ ...state, comment: event.target.value });
  };

  return (
    <div className="GeneralComponent" data-testid="general-component">
      <ViadeModal
        className={props.style}
        data-testid="Modal-component"
        disabled={false}
        toggleText={<FaComment></FaComment>}
        title={
          <FormattedMessage
            id="CommentsModelTitle"
            values={{ theRoute: state.theRoute }}
          />
        }
        closeText={<FormattedMessage id="Close" />}
        onOpen={handleOpen}
        handleClose={() => {}}
        saveText={CommentButtonText}
        onSave={handleOnSave}
      >
        <form id="myForm" data-testid="form-component">
          <label data-testid="label-component">
            <FormattedMessage id="Comments" />
            <br></br>
            <textarea
              id="myTextArea"
              data-testid="textarea-component"
              onChange={handlerTextArea}
            ></textarea>
          </label>
        </form>
      </ViadeModal>
    </div>
  );
}