mirror of
https://gitlab.com/MrFry/qmining-data-editor
synced 2025-04-01 20:24:01 +02:00
Subject view displaying subj/question count, subj selector height change
This commit is contained in:
parent
48d531ca1d
commit
0ba12f4d67
5 changed files with 24 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
|||
import React, { useState } from 'react'
|
||||
import React, { useState, useEffect } from 'react'
|
||||
|
||||
import LoadingIndicator from '../components/LoadingIndicator.js'
|
||||
import Subject from '../components/Subject.js'
|
||||
|
@ -11,6 +11,16 @@ export default function SubjectView (props) {
|
|||
const [activeSubjName, setActiveSubjName] = useState('')
|
||||
const [searchTerm, setSearchTerm] = useState('')
|
||||
|
||||
const [sCount, setSCount] = useState(0)
|
||||
const [qCount, setQCount] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
setSCount(data.Subjects.length)
|
||||
setQCount(data.Subjects.reduce((acc, subj) => {
|
||||
return acc + subj.Questions.length
|
||||
}, 0))
|
||||
}, [])
|
||||
|
||||
if (data) {
|
||||
let currSubj = data.Subjects.find((subj) => {
|
||||
return subj.Name === activeSubjName
|
||||
|
@ -43,6 +53,9 @@ export default function SubjectView (props) {
|
|||
onSubjSelect={(subjName) => { setActiveSubjName(subjName) }}
|
||||
/>
|
||||
<hr />
|
||||
<div>
|
||||
{qCount} kérdés, {sCount} tárgy
|
||||
</div>
|
||||
<div>
|
||||
<Subject
|
||||
onChange={onChange}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue