diff --git a/src/App.js b/src/App.js index a37e170a..36bc76cc 100644 --- a/src/App.js +++ b/src/App.js @@ -2,6 +2,7 @@ import React, { useCallback } from "react"; import { connect } from "react-redux"; import Head from "./Head"; import About from "./About"; +import Feedback from "./Feedback"; import Header from "./Header"; import Overlay from "./Overlay"; import SkinTable from "./SkinTable"; @@ -27,10 +28,8 @@ const getTableDimensions = (windowWidth, scale) => { function App(props) { const scrollbarWidth = useScrollbarWidth(); - const { - windowWidth: windowWidthWithScrollabar, - windowHeight, - } = useWindowSize(); + const { windowWidth: windowWidthWithScrollabar, windowHeight } = + useWindowSize(); const { columnWidth, rowHeight, columnCount } = getTableDimensions( windowWidthWithScrollabar - scrollbarWidth, @@ -75,7 +74,11 @@ function App(props) { windowWidth={windowWidthWithScrollabar} /> )} - {props.page === ABOUT_PAGE ? ( + {props.showFeedbackForm ? ( + + + + ) : props.page === ABOUT_PAGE ? ( @@ -104,6 +107,7 @@ const mapStateToProps = (state) => ({ page: Selectors.getActiveContentPage(state), scale: state.scale, uploadViewOpen: Selectors.getUploadViewOpen(state), + showFeedbackForm: state.showFeedbackForm, }); export default connect(mapStateToProps)(App); diff --git a/src/Feedback.js b/src/Feedback.js new file mode 100644 index 00000000..8badbc75 --- /dev/null +++ b/src/Feedback.js @@ -0,0 +1,87 @@ +import React, { useState } from "react"; +import { API_URL } from "./constants"; +import { getUrl } from "./redux/selectors"; +import * as Actions from "./redux/actionCreators"; +import { useActionCreator } from "./hooks"; + +import { useCallback } from "react"; +import { useSelector } from "react-redux"; + +export default function Feedback() { + const close = useActionCreator(Actions.closeFeedbackForm); + const [message, setMessage] = useState(""); + const [email, setEmail] = useState(""); + const [sending, setSending] = useState(false); + const [sent, setSent] = useState(false); + const url = useSelector(getUrl); + const send = useCallback(async () => { + const body = { message, email, url: "https://skins/webamp.org" + url }; + setSending(true); + await fetch(`${API_URL}/feedback`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(body), + }); + setSent(true); + }, [message, email, url]); + + if (sent) { + return ( +
+

Sent!

+

+ Thanks for your feedback. I appreciate you taking the time to share + your thoughts. +

+
+ +
+
+ ); + } + + return ( +
+

Feedback

+

+ Let me know what you think about the Winamp Skin Museum. Bug reports, + feature suggestions, personal anecdotes, or criticism are all welcome. +

+

+