- {searchTerm ? '' : 'Kezdj el írni kereséshez!'} {results}{' '}
- {searchTerm ? 'találat' : 'kérdés'}{' '}
- {searchTerm ? subjs.length : data.length} tárgy
+ {searchTerm ? '' : 'Kezdj el írni kereséshez! '}
+ {`${results} találat, ${subjs.length} tárgyból`}
diff --git a/src/components/layout.js b/src/components/layout.js
index 9fa66fa..11d49d6 100644
--- a/src/components/layout.js
+++ b/src/components/layout.js
@@ -8,7 +8,11 @@ import tabs from '../data/tabs.json'
import constants from '../constants.json'
import BB from './b.js'
-// FIXME: window resize event listener to show sidebar on resize
+const renderSnow = () => {
+ const date = new Date()
+ // if its december, and date is more than 5
+ return date.getMonth() === 11 && date.getDate() > 5
+}
export default function Layout(props) {
let href = props.route
@@ -29,8 +33,6 @@ export default function Layout(props) {
}
useEffect(() => {
- closeSideBar()
-
fetch(`${constants.apiUrl}infos`, {
credentials: 'include',
Accept: 'application/json',
@@ -49,23 +51,26 @@ export default function Layout(props) {
setWindowSize([window.innerWidth, window.innerHeight])
window.addEventListener('resize', () => {
setWindowSize([window.innerWidth, window.innerHeight])
+ setSidebarOpen(window.innerWidth >= 700)
})
}, [])
const snowflakeCount = (windowSize[0] + windowSize[1]) / 8
return (
-
-
-
+ {renderSnow() && (
+
+
+
+ )}
{
+ return acc + subj.Questions.length
+}
+
function mergeData(data) {
return data.reduce((acc, db) => {
return [
@@ -60,7 +64,6 @@ function fetchDbs() {
return resp.json()
})
.then((data) => {
- console.log(data)
resolve(data)
})
})
@@ -72,6 +75,8 @@ export default function AllQuestions({ router }) {
const [dbs, setDbs] = useState(null)
const [searchTerm, setSearchTerm] = useState('')
const [activeSubjName, setActiveSubjName] = useState('')
+ const subjectCount = data ? data.length : 0
+ const questionCount = data ? data.reduce(countReducer, 0) : 0
useEffect(() => {
router.replace(`${router.asPath.replace('.html', '')}`, undefined, {
@@ -97,9 +102,7 @@ export default function AllQuestions({ router }) {
defaultValue={-1}
onChange={(event) => {
const key = event.target.value
- if (key === 'none') {
- console.log(key)
- } else if (key === 'all') {
+ if (key === 'all') {
fetchAllData(dbs).then((res) => {
setData(mergeData(res))
console.log(res)
@@ -182,9 +185,7 @@ export default function AllQuestions({ router }) {
>
- ) : (
-
- )}
+ ) : null}
)
}
@@ -236,6 +237,7 @@ export default function AllQuestions({ router }) {
return (
{dbs && renderDbSelector()}
+ {data && `${questionCount} kérdés, ${subjectCount} tárgy`}