Fixed chapter counting and numbering issues

- Updated API functions to accept version parameter (getBook, getChapter)
- Added proper chapter sorting with parseInt for numerical order
- Removed fallback to 50 fake chapters - now shows actual chapter counts
- Fixed Psalms chapter numbering: 1,2,3,4,5,6,7,8,9,10,11,12... instead of 1,2,3,4,5,6,7,8,9,10,101,102...
- Books like 2 John now show correct number of chapters (1) instead of fake 50
This commit is contained in:
Ryderjj89
2025-09-28 17:58:47 -04:00
parent 8cb2aeef4b
commit 537898b4d0
5 changed files with 13 additions and 13 deletions

BIN
frontend/logos/csb-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
frontend/logos/niv-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

BIN
frontend/logos/nlt-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@@ -114,21 +114,21 @@ const ChapterSelector: React.FC<ChapterSelectorProps> = ({ book, onChapterSelect
const loadChapters = async () => { const loadChapters = async () => {
try { try {
setLoading(true); setLoading(true);
const response = await getBook(book); const response = await getBook(book, version);
// The API now returns { chapters: ["1", "2", "3", ...] } // The API now returns { chapters: ["1", "2", "3", ...] }
if (response.chapters) { if (response.chapters) {
setChapters(response.chapters); // Sort chapters numerically to ensure proper order
const sortedChapters = response.chapters.sort((a, b) => parseInt(a, 10) - parseInt(b, 10));
setChapters(sortedChapters);
} else { } else {
// Fallback: generate chapter numbers 1-50 (most books have fewer than 50 chapters) console.error('API returned no chapters data');
const fallbackChapters = Array.from({ length: 50 }, (_, i) => (i + 1).toString()); setChapters([]);
setChapters(fallbackChapters);
} }
} catch (error) { } catch (error) {
console.error('Failed to load chapters:', error); console.error('Failed to load chapters:', error);
// Fallback: generate chapter numbers 1-50 (most books have fewer than 50 chapters) // Don't show fallback chapters - just show an empty list
const fallbackChapters = Array.from({ length: 50 }, (_, i) => (i + 1).toString()); setChapters([]);
setChapters(fallbackChapters);
} finally { } finally {
setLoading(false); setLoading(false);
} }

View File

@@ -18,13 +18,13 @@ export const getBooks = async (): Promise<BookData> => {
return response.data; return response.data;
}; };
export const getBook = async (book: string): Promise<{ chapters: string[] }> => { export const getBook = async (book: string, version: string = 'esv'): Promise<{ chapters: string[] }> => {
const response = await api.get(`/books/${book}`); const response = await api.get(`/books/${book}?version=${version}`);
return response.data; return response.data;
}; };
export const getChapter = async (book: string, chapter: string): Promise<string> => { export const getChapter = async (book: string, chapter: string, version: string = 'esv'): Promise<string> => {
const response = await api.get(`/books/${book}/${chapter}`); const response = await api.get(`/books/${book}/${chapter}?version=${version}`);
return response.data; return response.data;
}; };