1- import React , { useState } from ' react' ;
2- import BookList from ' ../BookList' ;
3- import PropTypes from ' prop-types' ;
4- import { BIBLE_LIST , BIBLE_BOOKS , isEqual } from ' ./config' ;
5- import Checkbox from ' @material-ui/core/Checkbox' ;
6- import { FormControlLabel } from ' @material-ui/core' ;
1+ import React , { useState } from " react" ;
2+ import BookList from " ../BookList" ;
3+ import PropTypes from " prop-types" ;
4+ import { BIBLE_LIST , BIBLE_BOOKS } from " ./config" ;
5+ import Checkbox from " @material-ui/core/Checkbox" ;
6+ import { FormControlLabel } from " @material-ui/core" ;
77
88function BibleBookList ( {
99 labelForCheckbox,
@@ -20,11 +20,6 @@ function BibleBookList({
2020 testaments,
2121 sortFirstNT,
2222} ) {
23- if ( isEqual ( availableBookList , Object . keys ( BIBLE_BOOKS ) ) ) {
24- showCheckbox = false ;
25- }
26- console . log ( availableBookList ) ;
27- console . log ( Object . keys ( BIBLE_BOOKS ) ) ;
2823 const [ checkState , setCheckState ] = useState ( ! showInactive ) ;
2924 const currentBookList = BIBLE_LIST . map ( ( el ) => {
3025 return {
@@ -41,6 +36,11 @@ function BibleBookList({
4136 setCheckState ( ( prev ) => ! prev ) ;
4237 } ;
4338
39+ const allBooksIsSet = ( bookList ) => {
40+ const allBooks = bookList . filter ( ( el ) => el . isset === false ) ;
41+ return allBooks . length > 0 ;
42+ } ;
43+
4444 let testamentList = [ ] ;
4545
4646 switch ( testaments ) {
@@ -51,6 +51,9 @@ function BibleBookList({
5151 bookList : currentBookListNT ,
5252 } ,
5353 ] ;
54+ if ( showCheckbox ) {
55+ showCheckbox = allBooksIsSet ( currentBookListNT ) ;
56+ }
5457 break ;
5558
5659 case 'ot' :
@@ -60,6 +63,9 @@ function BibleBookList({
6063 bookList : currentBookListOT ,
6164 } ,
6265 ] ;
66+ if ( showCheckbox ) {
67+ showCheckbox = allBooksIsSet ( currentBookListOT ) ;
68+ }
6369 break ;
6470 case 'all' :
6571 testamentList = [
@@ -69,12 +75,16 @@ function BibleBookList({
6975 if ( sortFirstNT ) {
7076 testamentList . reverse ( ) ;
7177 }
78+ if ( showCheckbox ) {
79+ showCheckbox = allBooksIsSet ( currentBookListOT ) || allBooksIsSet ( currentBookListNT ) ;
80+ }
7281 break ;
7382
7483 default :
7584 break ;
7685 }
7786
87+
7888 const checkboxRender = showCheckbox ? (
7989 < FormControlLabel
8090 classes = { {
0 commit comments