From 7bb7b919ae006804b84732ca3f98f30d9cd88abd Mon Sep 17 00:00:00 2001 From: mrfry Date: Tue, 23 Mar 2021 15:34:26 +0100 Subject: [PATCH] Changed lotsa stuff --- src/components/externalLinkIcon.js | 22 ++++ src/components/layout.js | 132 +++++++++++-------- src/data/links.json | 22 ---- src/data/tabs.json | 20 ++- src/defaultStyles.css | 49 +++++++ src/pages/allQuestions.js | 32 ++++- src/pages/allQuestions.module.css | 21 --- src/pages/contact.js | 65 ++++++++- src/pages/contact.module.css | 13 ++ src/pages/contribute.js | 54 +------- src/pages/contribute.module.css | 22 ---- src/pages/{manual.js => faq.js} | 204 +++++++++++------------------ src/pages/index.js | 73 ----------- src/pages/index.module.css | 30 ----- src/pages/pwRequest.js | 6 +- src/pages/pwRequest.module.css | 30 ----- src/pages/script.js | 109 +++++++++++++++ src/pages/script.module.css | 0 18 files changed, 457 insertions(+), 447 deletions(-) create mode 100644 src/components/externalLinkIcon.js delete mode 100644 src/data/links.json rename src/pages/{manual.js => faq.js} (65%) create mode 100644 src/pages/script.js create mode 100644 src/pages/script.module.css diff --git a/src/components/externalLinkIcon.js b/src/components/externalLinkIcon.js new file mode 100644 index 0000000..73c1aab --- /dev/null +++ b/src/components/externalLinkIcon.js @@ -0,0 +1,22 @@ +import React from 'react' + +export default function ExternalLinkIcon({ size }) { + return ( + + + + + + + + ) +} diff --git a/src/components/layout.js b/src/components/layout.js index d4a8c52..66204f8 100644 --- a/src/components/layout.js +++ b/src/components/layout.js @@ -15,6 +15,51 @@ const renderSnow = () => { return date.getMonth() === 11 && date.getDate() > 5 } +function MessageButton({ + userSpecificMotd, + setShowMotdModal, + refetchGlobalData, +}) { + return ( +
+
{ + if (!userSpecificMotd) { + return + } + setShowMotdModal(true) + if (userSpecificMotd.seen) { + return + } + fetch(constants.apiUrl + 'infos', { + method: 'POST', + credentials: 'include', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + userSpecificMotdSeen: true, + }), + }) + .then((resp) => { + return resp.json() + }) + .then(() => { + refetchGlobalData() + }) + }} + style={{ cursor: userSpecificMotd ? 'pointer' : 'default' }} + title={ + userSpecificMotd && !userSpecificMotd.seen ? "You've got Mail!" : '' + } + > + {userSpecificMotd && !userSpecificMotd.seen ? '📬' : '📭'} +
+
+ ) +} + export default function Layout({ children, route, @@ -25,6 +70,7 @@ export default function Layout({ const [sidebarOpen, setSidebarOpen] = useState(true) const [windowSize, setWindowSize] = useState([100, 200]) const [showMotdModal, setShowMotdModal] = useState(false) + const [donateShowing, setDonateShowing] = useState(false) const [showNewMsgModal, setShowNewMsgModal] = useState(true) const userId = globalData.userId @@ -109,55 +155,22 @@ export default function Layout({ ) })} { + console.log('AAAAAAAAA') + closeSideBar() + setDonateShowing(true) + }} > Donate
-
-
{ - if (!userSpecificMotd) { - return - } - setShowMotdModal(true) - if (userSpecificMotd.seen) { - return - } - fetch(constants.apiUrl + 'infos', { - method: 'POST', - credentials: 'include', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - userSpecificMotdSeen: true, - }), - }) - .then((resp) => { - return resp.json() - }) - .then(() => { - refetchGlobalData() - }) - }} - style={{ cursor: userSpecificMotd ? 'pointer' : 'default' }} - title={ - userSpecificMotd && !userSpecificMotd.seen - ? "You've got Mail!" - : '' - } - > - {userSpecificMotd && !userSpecificMotd.seen ? '📬' : '📭'} -
-
UID: {userId || '...'}
-
+ +
UID: {userId || '...'}
{ @@ -175,21 +188,28 @@ export default function Layout({ Logout
- {showMotdModal ? ( - { - setShowMotdModal(false) - }} - > -
Ăśzenet admintĂłl:
-
- - ) : null} ) : null}
+ {donateShowing ? ( + { + setDonateShowing(false) + }} + > +
hi
+
+ ) : null} + {showMotdModal ? ( + { + setShowMotdModal(false) + }} + > +
Ăśzenet admintĂłl:
+
+ + ) : null}
{children}
{userSpecificMotd && !userSpecificMotd.seen && showNewMsgModal ? ( span:hover { background-color: var(--hoover-color); } + +.buttonContainer { + display: flex; + align-content: center; + justify-content: center; + + margin: 10px 0px; + height: 50px; + display: flex; +} + +.buttonContainer > * { + display: flex; + align-items: center; + justify-content: center; + flex: 1; + + background-color: #f2cb05; + border: none; + color: black; + padding: 5px 10px; + font-weight: bold; + font-size: 15px; + margin: 8px 2px 2px 2px; + cursor: pointer; + text-shadow: 1px 1px 8px black; + transition: width 0.5s, height 0.5s, ease-in 0.5s; + + user-select: none; + cursor: pointer; + text-align: center; + text-decoration: none; +} + +.buttonContainer > *:active { + transform: translateY(2.5px); +} + +.buttonContainer > *:hover { + text-shadow: 2px 2px 8px black; + transition: width 0.5s, height 0.5s, ease-out 0.5s; + background-color: #a38c1a; +} + +.buttonContainer > .activeButton { + color: var(--text-color); +} diff --git a/src/pages/allQuestions.js b/src/pages/allQuestions.js index 5a82374..aea8007 100644 --- a/src/pages/allQuestions.js +++ b/src/pages/allQuestions.js @@ -74,6 +74,7 @@ export default function AllQuestions({ router }) { const [searchTerm, setSearchTerm] = useState('') const [activeSubjName, setActiveSubjName] = useState('') const [dbs, setDbs] = useState(null) + const [selectedDb, setSelectedDb] = useState('') const [data, setData] = useState(null) const [fetchingData, setFetchingData] = useState(false) const subjectCount = data ? data.length : 0 @@ -106,11 +107,13 @@ export default function AllQuestions({ router }) { setData(null) setFetchingData(true) if (key === 'all') { + setSelectedDb(key) fetchAllData(dbs).then((res) => { setData(mergeData(res)) setFetchingData(false) }) } else { + setSelectedDb(dbs[key].name) fetchData(dbs[key]).then((res) => { setData(res.data) setFetchingData(false) @@ -238,11 +241,11 @@ export default function AllQuestions({ router }) { return (
- {dbs ? ( + {dbs ? <>{renderDbSelector()} : } + {dbs && data ? ( <> - {renderDbSelector()} - {data && `${questionCount} kérdés, ${subjectCount} tárgy`} -
+ {`${questionCount} kérdés, ${subjectCount} tárgy`} + {fetchingData ? ( @@ -266,9 +286,7 @@ export default function AllQuestions({ router }) {
)} - ) : ( - - )} + ) : null}
) } diff --git a/src/pages/allQuestions.module.css b/src/pages/allQuestions.module.css index 9304a36..e60fd57 100644 --- a/src/pages/allQuestions.module.css +++ b/src/pages/allQuestions.module.css @@ -12,27 +12,6 @@ border: none; } -.typeSelector { - margin: 10px 0px; - height: 50px; - display: flex; -} - -.typeSelector div { - display: flex; - align-items: center; - justify-content: center; - flex: 1; - - font-size: 18px; - color: #fff; - cursor: pointer; -} - -.typeSelector div:hover { - background-color: #333; -} - .activeTypeSelector { background-color: #444; } diff --git a/src/pages/contact.js b/src/pages/contact.js index 17c568f..0624408 100644 --- a/src/pages/contact.js +++ b/src/pages/contact.js @@ -1,7 +1,8 @@ -import React from 'react' +import React, { useState } from 'react' import Head from 'next/head' import styles from './contact.module.css' +import constants from '../constants.json' const contactMethods = { irc: { @@ -20,12 +21,74 @@ const contactMethods = { }, } +function submitFeedback(msg) { + return new Promise((resolve) => { + fetch(constants.apiUrl + 'postfeedback', { + method: 'POST', + credentials: 'include', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + newTask: msg, + from: 'contribute', + }), + }) + .then((resp) => { + return resp.json() + }) + .then((resp) => { + if (resp.success) { + resolve() + } else { + alert('Hiba küldés közben') + } + }) + .catch((err) => { + alert('Hiba küldés közben') + console.error(err) + }) + }) +} + export default function Contact() { + const [feedback, setFeedback] = useState('') + + const feedbackArea = () => { + return ( +
+