Skip to content

Commit fd476f4

Browse files
authored
Merge branch 'develop' into fix-foxprogs-linter
2 parents 724580a + 1990abc commit fd476f4

3 files changed

Lines changed: 28 additions & 23 deletions

File tree

src/components/BibleBookList/BibleBookList.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
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

88
function 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={{

src/components/BibleBookList/BibleBookList.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,20 @@ const onClickBook = (bookId) => setSelectedBookId(bookId);
1717

1818
const availableBookList = ['gen', 'exo', 'lev', 'num', 'mat', 'mrk', 'luk', 'tit'];
1919

20+
const NTBookList = [
21+
'mat', 'mrk', 'luk', 'jhn', 'act', 'rom', '1co',
22+
'2co', 'gal', 'eph', 'php', 'col', '1th', '2th',
23+
'1ti', '2ti', 'tit', 'phm', 'heb', 'jas', '1pe',
24+
'2pe', '1jn', '2jn', '3jn', 'jud', 'rev'];
25+
2026
<BibleBookList
2127
testaments="all"
2228
sortFirstNT={true}
2329
showInactive={false}
2430
titleOT="Old Testament"
2531
titleNT="New Testament"
2632
titleBooks={titleBooks}
27-
availableBookList={availableBookList}
33+
availableBookList={availableBookList} // replace to NTBookList
2834
selectedBookId={selectedBookId}
2935
onClickBook={onClickBook}
3036
/>;

src/components/BibleBookList/config.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,3 @@ export const NEW_TESTAMENT_LIST = [
475475
},
476476
];
477477
export const BIBLE_LIST = OLD_TESTAMENT_LIST.concat(NEW_TESTAMENT_LIST);
478-
export const isEqual = (a, b) => {
479-
if (a.length !== b.length) {
480-
return false;
481-
}
482-
a.forEach((item) => {
483-
if (!b.includes(item)) {
484-
return false;
485-
}
486-
});
487-
return true;
488-
};

0 commit comments

Comments
 (0)