Feedback and test sender implement, minor fixes with links

This commit is contained in:
MrFry 2020-03-15 10:53:28 +01:00
parent 8a1149d223
commit c5d6518ceb
11 changed files with 154 additions and 89 deletions

View file

@ -1,10 +1,11 @@
import Link from 'next/link' import Link from 'next/link'
import tabs from '../data/tabs.json' import tabs from '../data/tabs.json'
import constants from '../constants.json'
// TODO: activelink prop to set link to active // TODO: activelink prop to set link to active
export default function Layout (props) { export default function Layout (props) {
const { currPageName } = props const href = '' // TODO
return ( return (
<div> <div>
@ -24,11 +25,14 @@ export default function Layout (props) {
return ( return (
<Link href={item.href} key={key} > <Link href={item.href} key={key} >
<a <a
className={currPageName === key ? 'active' : ''} className={href.includes(key) ? 'active' : ''}
>{item.text}</a> >{item.text}</a>
</Link> </Link>
) )
})} })}
<a href={constants.serverUrl + 'donate'}>
Donate
</a>
</div> </div>
<div className='content'> <div className='content'>
{props.children} {props.children}

View file

@ -1,18 +1,22 @@
{ {
"install": { "install": {
"href": "/install", "href": "install",
"text": "Install" "text": "Install"
}, },
"data": {
"href": "data.json",
"text": "Összes kérdés JSON"
},
"server": { "server": {
"href": "/servergit", "href": "servergit",
"text": "Szerver repó" "text": "Szerver repó"
}, },
"client": { "client": {
"href": "/scriptgit", "href": "scriptgit",
"text": "Script git" "text": "Script git"
}, },
"classes": { "classes": {
"href": "/classesgit", "href": "classesgit",
"text": "Classes git" "text": "Classes git"
} }
} }

View file

@ -11,6 +11,14 @@
"href": "/allQuestions", "href": "/allQuestions",
"text": "All question" "text": "All question"
}, },
"feedback": {
"href": "/feedback",
"text": "Feedback"
},
"testSender": {
"href": "/testSender",
"text": "Test Sender"
},
"userQuestions": { "userQuestions": {
"href": "/userQuestions", "href": "/userQuestions",
"text": "User Questions" "text": "User Questions"

View file

@ -20,6 +20,16 @@ body {
text-decoration: none; text-decoration: none;
} }
.motdHeader {
text-align: center;
font-size: 24px;
}
.motd {
text-align: center;
font-size: 20px;
}
.sidebar { .sidebar {
margin: 0; margin: 0;
padding: 0; padding: 0;

View file

@ -1,9 +1,14 @@
// import App from 'next/app' // import App from 'next/app'
import '../defaultStyles.css' import '../defaultStyles.css'
import Layout from '../components/layout'
function MyApp ({ Component, pageProps }) { function MyApp ({ Component, pageProps }) {
return <Component {...pageProps} /> return (
<Layout>
<Component {...pageProps} />
</Layout>
)
} }
// Only uncomment this method if you have blocking data requirements for // Only uncomment this method if you have blocking data requirements for

View file

@ -4,7 +4,6 @@ import fetch from 'unfetch'
import LoadingIndicator from '../components/LoadingIndicator.js' import LoadingIndicator from '../components/LoadingIndicator.js'
import Subject from '../components/Subject.js' import Subject from '../components/Subject.js'
import SubjectSelector from '../components/SubjectSelector.js' import SubjectSelector from '../components/SubjectSelector.js'
import Layout from '../components/layout'
import constants from '../constants.json' import constants from '../constants.json'
@ -30,37 +29,33 @@ export default function AllQuestions (props) {
}) })
return ( return (
<Layout currPageName='allQuestions' > <div>
<div> <div>
<div> <input
<input placeholder='Keresés...'
placeholder='Keresés...' className='searchBar'
className='searchBar' type='text'
type='text' value={searchTerm}
value={searchTerm} onChange={(e) => { setSearchTerm(e.target.value) }}
onChange={(e) => { setSearchTerm(e.target.value) }}
/>
</div>
<SubjectSelector
data={data}
activeSubjName={activeSubjName}
searchTerm={searchTerm}
onSubjSelect={(subjName) => { setActiveSubjName(subjName) }}
/> />
<hr />
<div>
<Subject
subj={currSubj}
/>
</div>
</div> </div>
</Layout> <SubjectSelector
data={data}
activeSubjName={activeSubjName}
searchTerm={searchTerm}
onSubjSelect={(subjName) => { setActiveSubjName(subjName) }}
/>
<hr />
<div>
<Subject
subj={currSubj}
/>
</div>
</div>
) )
} else { } else {
return ( return (
<Layout currPageName='allQuestions' > <LoadingIndicator />
<LoadingIndicator />
</Layout>
) )
} }
} }

View file

@ -1,7 +1,24 @@
import constants from '../constants.json'
export default function Feedback (props) { export default function Feedback (props) {
// TODO: textarea style to css
// TODO: response to user that msg is sucessfully sent
return ( return (
<div> <div>
hello Feedback <form action={constants.serverUrl + 'postfeedback'} method='post'>
<div>Észrevételek: (közeledő teszt miatti kérdés-karbantartás, bug, feature vagy egyéb dolog, ami nyomja a lelked)</div>
<textarea
type='text'
name='message_field'
style={{
width: '100%',
boxSizing: 'border-box',
height: '400px'
}}
/>
<div>Rengeteg spam-et kapok, nyugodtan küldd el ezerszer, akkor hátha észreveszem a spam között :)</div>
<button>Küldés</button>
</form>
</div> </div>
) )
} }

View file

@ -1,28 +1,31 @@
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import links from './links.json' import links from './links.json'
import constants from '../constants.json'
// TODO: aludni
class HomeTab extends PureComponent { class HomeTab extends PureComponent {
render () { render () {
return ( return (<div>HAAAAAAAAAA</div>)
<div> // return (
{Object.keys(links).map((key) => { // <div>
let link = links[key] // {Object.keys(links).map((key) => {
return ( // const link = links[key]
<div // return (
className='link' // <div
key={key} // className='link'
> // key={key}
<a // >
href={link.href} // <a
> // href={constants.serverUrl + link.href}
{link.text} // >
</a> // {link.text}
</div> // </a>
) // </div>
})} // )
</div> // })}
) // </div>
// )
} }
} }

View file

@ -1,35 +1,60 @@
// TODO: css remove unnecesarry stuff // TODO: css remove unnecesarry stuff
// TODO: resizing // TODO: resizing
// TODO: fetch data only once?
// TODO: move manual to this module instead of api
// TODO: feedback tab
// TODO: motd // TODO: motd
import Layout from '../components/layout' // TODO: aludni
// TODO: fetch only once
import React, { useState, useEffect } from 'react'
import fetch from 'unfetch'
import links from '../data/links.json' import links from '../data/links.json'
// import constants from '../constants.json' import constants from '../constants.json'
export default function Index (props) { export default function Index (props) {
return ( const [motd, setMotd] = useState('loading...')
<Layout currPageName='index'>
useEffect(() => {
console.info('Fetching data')
fetch(`${constants.serverUrl}motd`)
.then((resp) => {
return resp.text()
})
.then((data) => {
setMotd(data)
})
}, [])
const renderMotd = () => {
return (
<div> <div>
{Object.keys(links).map((key) => { <div className='motdHeader'>
let link = links[key] MOTD:
return ( </div>
<div <div
className='link' className='motd'
key={key} dangerouslySetInnerHTML={{ __html: motd }}
> />
<a
href={link.href}
>
{link.text}
</a>
</div>
)
})}
</div> </div>
</Layout> )
}
return (
<div>
{renderMotd()}
{Object.keys(links).map((key) => {
let link = links[key]
return (
<div
className='link'
key={key}
>
<a
href={constants.serverUrl + link.href}
>
{link.text}
</a>
</div>
)
})}
</div>
) )
} }

View file

@ -1,10 +1,9 @@
import Layout from '../components/layout'
export default function Manual (props) { export default function Manual (props) {
return ( return (
<Layout currPageName='manual' > <div>
{renderMaual()} {renderMaual()}
</Layout> </div>
) )
} }

View file

@ -1,7 +1,6 @@
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import LoadingIndicator from '../components/LoadingIndicator' import LoadingIndicator from '../components/LoadingIndicator'
import Layout from '../components/layout'
import constants from '../constants.json' import constants from '../constants.json'
@ -40,17 +39,13 @@ export default function UserQuestions (props) {
}).reverse() }).reverse()
return ( return (
<Layout currPageName='UserQuestions' > <div className='uquestionscontainer'>
<div className='uquestionscontainer'> {questions}
{questions} </div>
</div>
</Layout>
) )
} else { } else {
return ( return (
<Layout currPageName='UserQuestions' > <LoadingIndicator />
<LoadingIndicator />
</Layout>
) )
} }
} }