11import React , { useState } from 'react' ;
22import BookList from '../BookList' ;
33import PropTypes from 'prop-types' ;
4- import { BIBLE_LIST , BIBLE_BOOKS } from './config' ;
4+ import {
5+ OLD_TESTAMENT_LIST ,
6+ NEW_TESTAMENT_LIST ,
7+ OBS_LIST ,
8+ OLD_TESTAMENT ,
9+ NEW_TESTAMENT ,
10+ OBS ,
11+ } from './config' ;
512import Checkbox from '@material-ui/core/Checkbox' ;
613import { FormControlLabel } from '@material-ui/core' ;
714
@@ -13,25 +20,39 @@ function BibleBookList({
1320 selectedBookId,
1421 titleOT,
1522 titleNT,
23+ titleOBS,
1624 availableBookList,
1725 titleBooks,
1826 BibleBookListClasses,
1927 bookClasses,
2028 testaments,
2129 sortFirstNT,
30+ showOBS,
2231} ) {
2332 const [ checkState , setCheckState ] = useState ( ! showInactive ) ;
24- const currentBookList = BIBLE_LIST . map ( ( el ) => {
33+ let bibleList ;
34+ if ( showOBS ) {
35+ bibleList = OLD_TESTAMENT_LIST . concat ( NEW_TESTAMENT_LIST ) . concat ( OBS_LIST ) ;
36+ } else {
37+ bibleList = OLD_TESTAMENT_LIST . concat ( NEW_TESTAMENT_LIST ) ;
38+ }
39+ let bibleBooks ;
40+ if ( showOBS ) {
41+ bibleBooks = { ...OLD_TESTAMENT , ...NEW_TESTAMENT , ...OBS } ;
42+ } else {
43+ bibleBooks = { ...OLD_TESTAMENT , ...NEW_TESTAMENT } ;
44+ }
45+ const currentBookList = bibleList . map ( ( el ) => {
2546 return {
2647 ...el ,
27- text : titleBooks [ el . identifier ] ?? BIBLE_BOOKS [ el . identifier ] ,
48+ text : titleBooks [ el . identifier ] ?? bibleBooks [ el . identifier ] ,
2849 isset : availableBookList . includes ( el . identifier ) ,
2950 } ;
3051 } ) ;
3152
3253 const currentBookListOT = currentBookList . filter ( ( el ) => el . categories === 'bible-ot' ) ;
33-
3454 const currentBookListNT = currentBookList . filter ( ( el ) => el . categories === 'bible-nt' ) ;
55+ const currentBookListOBS = currentBookList . filter ( ( el ) => el . categories === 'obs' ) ;
3556 const handleChange = ( ) => {
3657 setCheckState ( ( prev ) => ! prev ) ;
3758 } ;
@@ -85,6 +106,16 @@ function BibleBookList({
85106 break ;
86107 }
87108
109+ if ( showOBS ) {
110+ testamentList = testamentList . concat ( {
111+ title : titleOBS ,
112+ bookList : currentBookListOBS ,
113+ } ) ;
114+ if ( showCheckbox ) {
115+ showCheckbox = allBooksIsSet ( currentBookListOBS ) ;
116+ }
117+ }
118+
88119 const checkboxRender = showCheckbox ? (
89120 < FormControlLabel
90121 classes = { {
@@ -125,10 +156,12 @@ const bookListRender = testamentList.map((el, index) => {
125156
126157BibleBookList . defaultProps = {
127158 showCheckbox : true ,
159+ showOBS : false ,
128160 sortFirstNT : false ,
129161 testaments : 'all' ,
130162 titleOT : '' ,
131163 titleNT : '' ,
164+ titleOBS : '' ,
132165 showInactive : true ,
133166 onClickBook : ( bookId ) => { } ,
134167 labelForCheckbox : 'Show only existing books' ,
@@ -140,6 +173,8 @@ BibleBookList.propTypes = {
140173 testaments : PropTypes . oneOf ( [ 'all' , 'nt' , 'ot' ] ) ,
141174 /** block header of "New Testament" */
142175 titleNT : PropTypes . string ,
176+ /** block header of "OBS" */
177+ titleOBS : PropTypes . string ,
143178 /** block header of "Old Testament" */
144179 titleOT : PropTypes . string ,
145180 /** when true, show first New Testament, second - Old Testament */
@@ -150,6 +185,8 @@ BibleBookList.propTypes = {
150185 titleBooks : PropTypes . object ,
151186 /** show or hide checkbox that show only existing books */
152187 showCheckbox : PropTypes . bool ,
188+ /** show or hide OBS block */
189+ showOBS : PropTypes . bool ,
153190 /** whether to display inactive books */
154191 showInactive : PropTypes . bool ,
155192 /** label of checkbox */
0 commit comments