mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
major tidy
This commit is contained in:
parent
67b1fa2d37
commit
c19f24de87
24 changed files with 339 additions and 17 deletions
21
src/pages/_app.js
Normal file
21
src/pages/_app.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
// import App from 'next/app'
|
||||
|
||||
import '../defaultStyles.css'
|
||||
|
||||
function MyApp ({ Component, pageProps }) {
|
||||
return <Component {...pageProps} />
|
||||
}
|
||||
|
||||
// Only uncomment this method if you have blocking data requirements for
|
||||
// every single page in your application. This disables the ability to
|
||||
// perform automatic static optimization, causing every page in your app to
|
||||
// be server-side rendered.
|
||||
//
|
||||
// MyApp.getInitialProps = async (appContext) => {
|
||||
// // calls page's `getInitialProps` and fills `appProps.pageProps`
|
||||
// const appProps = await App.getInitialProps(appContext);
|
||||
//
|
||||
// return { ...appProps }
|
||||
// }
|
||||
|
||||
export default MyApp
|
22
src/pages/_document.js
Normal file
22
src/pages/_document.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
import Document, { Html, Head, Main, NextScript } from 'next/document'
|
||||
|
||||
class MyDocument extends Document {
|
||||
static async getInitialProps (ctx) {
|
||||
const initialProps = await Document.getInitialProps(ctx)
|
||||
return { ...initialProps }
|
||||
}
|
||||
|
||||
render () {
|
||||
return (
|
||||
<Html>
|
||||
<Head />
|
||||
<body bgcolor='#212127'>
|
||||
<Main />
|
||||
<NextScript />
|
||||
</body>
|
||||
</Html>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default MyDocument
|
99
src/pages/allQuestions.js
Normal file
99
src/pages/allQuestions.js
Normal file
|
@ -0,0 +1,99 @@
|
|||
import React, { PureComponent } from 'react'
|
||||
|
||||
import LoadingIndicator from '../LoadingIndicator'
|
||||
import Subject from '../../components/Subject'
|
||||
|
||||
import constants from '../../constants.json'
|
||||
|
||||
class AllQuestions extends PureComponent {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
loaded: false,
|
||||
activeSubjName: '',
|
||||
searchTerm: ''
|
||||
}
|
||||
|
||||
console.info('Fetching data')
|
||||
fetch(`${constants.serverUrl}data.json`) // eslint-disable-line
|
||||
.then((resp) => {
|
||||
return resp.json()
|
||||
})
|
||||
.then((data) => {
|
||||
this.data = data
|
||||
this.setState({
|
||||
loaded: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
onSubjSelect (name) {
|
||||
this.setState({
|
||||
activeSubjName: name
|
||||
})
|
||||
}
|
||||
|
||||
searchBarOnChange (e) {
|
||||
let text = e.target.value
|
||||
this.setState({
|
||||
searchTerm: text
|
||||
})
|
||||
}
|
||||
|
||||
render () {
|
||||
const { loaded, activeSubjName, searchTerm } = this.state
|
||||
|
||||
if (loaded) {
|
||||
let currSubj = this.data.Subjects.find((subj) => {
|
||||
return subj.Name === activeSubjName
|
||||
})
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<input
|
||||
placeholder='Keresés...'
|
||||
className='searchBar'
|
||||
type='text'
|
||||
value={searchTerm}
|
||||
onChange={this.searchBarOnChange.bind(this)}
|
||||
/>
|
||||
</div>
|
||||
<div className='subjectSelector'>
|
||||
{this.data.Subjects.map((subj, i) => {
|
||||
if (!subj.Name.toLowerCase().includes(searchTerm.toLowerCase())) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={activeSubjName === subj.Name
|
||||
? 'subjItem activeSubjItem'
|
||||
: 'subjItem'
|
||||
}
|
||||
key={i}
|
||||
onClick={() => this.onSubjSelect(subj.Name)}
|
||||
>
|
||||
{subj.Name}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
<hr />
|
||||
<div>
|
||||
<Subject
|
||||
subj={currSubj}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<LoadingIndicator />
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default AllQuestions
|
13
src/pages/feedback.js
Normal file
13
src/pages/feedback.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import React, { PureComponent } from 'react'
|
||||
|
||||
class Feedback extends PureComponent {
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
hello Feedback
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Feedback
|
29
src/pages/home.js
Normal file
29
src/pages/home.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
import React, { PureComponent } from 'react'
|
||||
|
||||
import links from './links.json'
|
||||
|
||||
class HomeTab extends PureComponent {
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
{Object.keys(links).map((key) => {
|
||||
let link = links[key]
|
||||
return (
|
||||
<div
|
||||
className='link'
|
||||
key={key}
|
||||
>
|
||||
<a
|
||||
href={link.href}
|
||||
>
|
||||
{link.text}
|
||||
</a>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default HomeTab
|
35
src/pages/index.js
Normal file
35
src/pages/index.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
|
||||
// TODO: css remove unnecesarry stuff
|
||||
// TODO: resizing
|
||||
// TODO: fetch data only once?
|
||||
// TODO: move manual to this module instead of api
|
||||
// TODO: feedback tab
|
||||
// TODO: motd
|
||||
import Layout from '../components/layout'
|
||||
|
||||
import links from '../data/links.json'
|
||||
// import constants from '../constants.json'
|
||||
|
||||
export default function Index (props) {
|
||||
return (
|
||||
<Layout>
|
||||
<div>
|
||||
{Object.keys(links).map((key) => {
|
||||
let link = links[key]
|
||||
return (
|
||||
<div
|
||||
className='link'
|
||||
key={key}
|
||||
>
|
||||
<a
|
||||
href={link.href}
|
||||
>
|
||||
{link.text}
|
||||
</a>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</Layout>
|
||||
)
|
||||
}
|
49
src/pages/manual.js
Normal file
49
src/pages/manual.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
import React, { PureComponent } from 'react'
|
||||
import fetch from 'unfetch'
|
||||
|
||||
import LoadingIndicator from '../components/LoadingIndicator'
|
||||
|
||||
import constants from '../constants.json'
|
||||
|
||||
class Manual extends PureComponent {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
loaded: false
|
||||
}
|
||||
|
||||
console.info('Fetching manual')
|
||||
fetch(`${constants.serverUrl}manual`) // eslint-disable-line
|
||||
.then((resp) => {
|
||||
return resp.text()
|
||||
})
|
||||
.then((data) => {
|
||||
this.manual = {
|
||||
__html: data
|
||||
}
|
||||
|
||||
this.setState({
|
||||
loaded: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
render () {
|
||||
const { loaded } = this.state
|
||||
|
||||
if (loaded) {
|
||||
return (
|
||||
<div>
|
||||
<div dangerouslySetInnerHTML={this.manual} />
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<LoadingIndicator />
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Manual
|
65
src/pages/userQuestions.js
Normal file
65
src/pages/userQuestions.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
import React, { PureComponent } from 'react'
|
||||
|
||||
import LoadingIndicator from '../LoadingIndicator'
|
||||
|
||||
import constants from '../../constants.json'
|
||||
|
||||
class UserQuestions extends PureComponent {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
loaded: false
|
||||
}
|
||||
|
||||
console.info('Fetching qa.json')
|
||||
fetch(`${constants.serverUrl}qa.json`) // eslint-disable-line
|
||||
.then((resp) => {
|
||||
return resp.json()
|
||||
})
|
||||
.then((data) => {
|
||||
this.qa = data
|
||||
|
||||
this.setState({
|
||||
loaded: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
render () {
|
||||
const { loaded } = this.state
|
||||
|
||||
if (loaded) {
|
||||
let questions = Object.keys(this.qa).map((key, i) => {
|
||||
let q = this.qa[key]
|
||||
return (
|
||||
<div key={key} className='uquestioncontainer'>
|
||||
<div >
|
||||
<div className='uquestionnumber'>
|
||||
{key}:
|
||||
</div>
|
||||
<div className='uquestion'>
|
||||
{q.q}
|
||||
</div>
|
||||
</div>
|
||||
<div className='uanswer'>
|
||||
{q.a}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}).reverse()
|
||||
|
||||
return (
|
||||
<div className='uquestionscontainer'>
|
||||
{questions}
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<LoadingIndicator />
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default UserQuestions
|
Loading…
Add table
Add a link
Reference in a new issue