diff --git a/.env.local.sample b/.env.local.sample index 97d25ab1..4c6ebb54 100644 --- a/.env.local.sample +++ b/.env.local.sample @@ -3,9 +3,10 @@ AUTH_SECRET=random-string DB_NAME=as4 EMAIL_SERVER_USER=example EMAIL_SERVER_PASSWORD=password -EMAIL_SERVER_HOST=smpt.example.net +EMAIL_SERVER_HOST=smtp.example.net EMAIL_SERVER_PORT=587 EMAIL_FROM=webmaster@email.com +SUPPORT_EMAIL=aai-support@mit.edu MONGODB_URI=mongodb://localhost:27017/as4 NEXTAUTH_URL=http://localhost:3000 NEXT_PUBLIC_SIGNING_URL=CLOUDFRONT_URL diff --git a/src/components/FeedbackButton/FeedbackButton.js b/src/components/FeedbackButton/FeedbackButton.js new file mode 100644 index 00000000..7fa616ff --- /dev/null +++ b/src/components/FeedbackButton/FeedbackButton.js @@ -0,0 +1,117 @@ +import React, { useState } from 'react'; +import { + Button, + Form, + Modal, + Nav, +} from 'react-bootstrap'; +import { Formik } from 'formik'; +import unfetch from 'unfetch'; + +const sendEmail = async (user, text) => { + const url = '/api/feedback'; + const res = await unfetch(url, { + method: 'POST', + body: JSON.stringify({ name: user.name, text }), + headers: { + 'Content-Type': 'application/json', + }, + }); + if (res.status === 200) { + const result = await res.json(); + return Promise.resolve(result); + } return Promise.reject(Error(`Unable to send email: error ${res.status} received from server`)); +}; + +const FeedbackModal = ({ show, setShow, session }) => ( + { + await sendEmail(session.user, values.feedback) + .catch((error) => { + setShow(false); + actions.setSubmitting(false); + throw new Error('SEND_FEEDBACK_EMAIL_ERROR', error); + }); + setShow(false); + actions.setSubmitting(false); + }} + > + {(props) => ( +
+ { + setShow(false); + }} + size="lg" + aria-labelledby="feedback-modal-title" + centered + > + + + Submit Feedback + + + +
Thank you for testing out this early version of Annotation Studio 4.
+ + + Here you may submit feedback directly + to the Annotation Studio team. + + + + {props.errors.feedback &&
{props.errors.feedback}
} +
+ + + + +
+
+ )} +
+); + +const FeedbackButton = ({ session }) => { + const [modalShow, setModalShow] = useState(false); + return ( + <> + {session && ( + <> + setModalShow(true)} + style={{ color: '#f5c83a', textDecoration: 'none' }} + > + Feedback + + + + + )} + + ); +}; + +export default FeedbackButton; diff --git a/src/components/FeedbackButton/index.js b/src/components/FeedbackButton/index.js new file mode 100644 index 00000000..a0354084 --- /dev/null +++ b/src/components/FeedbackButton/index.js @@ -0,0 +1,3 @@ +import FeedbackButton from './FeedbackButton'; + +export default FeedbackButton; diff --git a/src/components/Header/Header.js b/src/components/Header/Header.js index fc35529f..0426ef70 100644 --- a/src/components/Header/Header.js +++ b/src/components/Header/Header.js @@ -8,6 +8,7 @@ import { BoxArrowUpRight, BoxArrowInRight, BoxArrowRight, GearWideConnected, } from 'react-bootstrap-icons'; import SecondNavbar from '../SecondNavbar'; +import FeedbackButton from '../FeedbackButton'; function getEditProfileUrl(email) { const slug = email.replace(/[*+~.()'"!:@]/g, '-'); @@ -33,6 +34,7 @@ function Header({