diff --git a/package-lock.json b/package-lock.json index d6c7c6758..03f46021a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11204,9 +11204,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001684", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001684.tgz", - "integrity": "sha512-G1LRwLIQjBQoyq0ZJGqGIJUXzJ8irpbjHLpVRXDvBEScFJ9b17sgK6vlx0GAJFE21okD7zXl08rRRUfq6HdoEQ==", + "version": "1.0.30001686", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001686.tgz", + "integrity": "sha512-Y7deg0Aergpa24M3qLC5xjNklnKnhsmSyR/V89dLZ1n0ucJIFNs7PgR2Yfa/Zf6W79SbBicgtGxZr2juHkEUIA==", "funding": [ { "type": "opencollective", diff --git a/public/compiled-lang/br.json b/public/compiled-lang/br.json index 6bcc873e4..f6c9e9b52 100644 --- a/public/compiled-lang/br.json +++ b/public/compiled-lang/br.json @@ -725,12 +725,6 @@ "value": "Versão da Bíblia" } ], - "bibleVersion__booksLabel": [ - { - "type": 0, - "value": "66 livros" - } - ], "bibleVersion__description": [ { "type": 0, @@ -743,24 +737,6 @@ "value": "Patrocinador" } ], - "bibleVersion__websiteLabel": [ - { - "type": 0, - "value": "Site" - } - ], - "bibleVersions__heading": [ - { - "type": 0, - "value": "Bíblia" - } - ], - "bibleVersions__intro": [ - { - "type": 0, - "value": "A melhor forma de aprender sobre a sã doutrina é por meio da Palavra de Deus. Com as nossas Bíblias em áudio, você poderá ouvir grandes ensinamentos do maior professor de todos." - } - ], "bible__title": [ { "type": 0, @@ -773,18 +749,6 @@ "value": "Histórico" } ], - "bibles__version1": [ - { - "type": 0, - "value": "version 1" - } - ], - "bibles__version2": [ - { - "type": 0, - "value": "version 2" - } - ], "blogDetailPage__moreBlogPosts": [ { "type": 0, diff --git a/public/compiled-lang/de.json b/public/compiled-lang/de.json index 9d777a296..8a2a918b8 100644 --- a/public/compiled-lang/de.json +++ b/public/compiled-lang/de.json @@ -725,12 +725,6 @@ "value": "Bibelversion" } ], - "bibleVersion__booksLabel": [ - { - "type": 0, - "value": "66 Bücher" - } - ], "bibleVersion__description": [ { "type": 0, @@ -743,24 +737,6 @@ "value": "Sponsor" } ], - "bibleVersion__websiteLabel": [ - { - "type": 0, - "value": "Website" - } - ], - "bibleVersions__heading": [ - { - "type": 0, - "value": "Bibel" - } - ], - "bibleVersions__intro": [ - { - "type": 0, - "value": "Gesunde Lehre wird am besten durch das Hören von Gottes Wort erlernt. Mit unseren Hörbuch-Bibeln kannst du den wertvollen Lektionen des größten Lehrers aller Zeiten lauschen." - } - ], "bible__title": [ { "type": 0, @@ -773,18 +749,6 @@ "value": "Verlauf" } ], - "bibles__version1": [ - { - "type": 0, - "value": "version 1" - } - ], - "bibles__version2": [ - { - "type": 0, - "value": "version 2" - } - ], "blogDetailPage__moreBlogPosts": [ { "type": 0, diff --git a/public/compiled-lang/en.json b/public/compiled-lang/en.json index 1e927d6c6..e3a09ec08 100644 --- a/public/compiled-lang/en.json +++ b/public/compiled-lang/en.json @@ -725,12 +725,6 @@ "value": "Bible Version" } ], - "bibleVersion__booksLabel": [ - { - "type": 0, - "value": "66 Books" - } - ], "bibleVersion__description": [ { "type": 0, @@ -743,24 +737,6 @@ "value": "Sponsor" } ], - "bibleVersion__websiteLabel": [ - { - "type": 0, - "value": "Website" - } - ], - "bibleVersions__heading": [ - { - "type": 0, - "value": "Bible" - } - ], - "bibleVersions__intro": [ - { - "type": 0, - "value": "The best way to learn sound doctrine is by listening to the Word of God. Our audio Bibles give you the ability to listen to great teachings from the greatest teacher of all." - } - ], "bible__title": [ { "type": 0, @@ -773,18 +749,6 @@ "value": "History" } ], - "bibles__version1": [ - { - "type": 0, - "value": "version 1" - } - ], - "bibles__version2": [ - { - "type": 0, - "value": "version 2" - } - ], "blogDetailPage__moreBlogPosts": [ { "type": 0, diff --git a/public/compiled-lang/es.json b/public/compiled-lang/es.json index 003b3a0b5..3566d90cf 100644 --- a/public/compiled-lang/es.json +++ b/public/compiled-lang/es.json @@ -725,12 +725,6 @@ "value": "Versión bíblica" } ], - "bibleVersion__booksLabel": [ - { - "type": 0, - "value": "66 Libros" - } - ], "bibleVersion__description": [ { "type": 0, @@ -743,24 +737,6 @@ "value": "Patrocinador" } ], - "bibleVersion__websiteLabel": [ - { - "type": 0, - "value": "Website" - } - ], - "bibleVersions__heading": [ - { - "type": 0, - "value": "Biblia" - } - ], - "bibleVersions__intro": [ - { - "type": 0, - "value": "La mejor manera de aprender la sana doctrina es escuchar la Palabra de Dios. Nuestras Audiobiblias le dan la posibilidad de escuchar grandes lecciones del mayor maestro de todos los tiempos." - } - ], "bible__title": [ { "type": 0, @@ -773,18 +749,6 @@ "value": "Historial" } ], - "bibles__version1": [ - { - "type": 0, - "value": "version 1" - } - ], - "bibles__version2": [ - { - "type": 0, - "value": "version 2" - } - ], "blogDetailPage__moreBlogPosts": [ { "type": 0, diff --git a/public/compiled-lang/fr.json b/public/compiled-lang/fr.json index e6e97ab42..eb1836c64 100644 --- a/public/compiled-lang/fr.json +++ b/public/compiled-lang/fr.json @@ -725,12 +725,6 @@ "value": "Version de la Bible" } ], - "bibleVersion__booksLabel": [ - { - "type": 0, - "value": "66 livres" - } - ], "bibleVersion__description": [ { "type": 0, @@ -743,24 +737,6 @@ "value": "Sponsor" } ], - "bibleVersion__websiteLabel": [ - { - "type": 0, - "value": "Website" - } - ], - "bibleVersions__heading": [ - { - "type": 0, - "value": "Bible" - } - ], - "bibleVersions__intro": [ - { - "type": 0, - "value": "La meilleure façon d'apprendre la saine doctrine est en écoutant la Parole de Dieu. Nos bibles audio vous donne la possibilité d'écouter de grands enseignements donnés par le plus grand enseignant de tous les temps." - } - ], "bible__title": [ { "type": 0, @@ -773,18 +749,6 @@ "value": "Historique" } ], - "bibles__version1": [ - { - "type": 0, - "value": "version 1" - } - ], - "bibles__version2": [ - { - "type": 0, - "value": "version 2" - } - ], "blogDetailPage__moreBlogPosts": [ { "type": 0, diff --git a/public/compiled-lang/ja.json b/public/compiled-lang/ja.json index 0c0658ecd..f3040f7ba 100644 --- a/public/compiled-lang/ja.json +++ b/public/compiled-lang/ja.json @@ -725,12 +725,6 @@ "value": "聖書バージョン" } ], - "bibleVersion__booksLabel": [ - { - "type": 0, - "value": "66巻" - } - ], "bibleVersion__description": [ { "type": 0, @@ -743,24 +737,6 @@ "value": "主催者" } ], - "bibleVersion__websiteLabel": [ - { - "type": 0, - "value": "Website" - } - ], - "bibleVersions__heading": [ - { - "type": 0, - "value": "聖書" - } - ], - "bibleVersions__intro": [ - { - "type": 0, - "value": "確実な教理を学ぶ方法は、神の御言葉を聞くのがベスト。オーディオバイブルを通して最も偉大な教師から最も大切な教え聞くことができます。" - } - ], "bible__title": [ { "type": 0, @@ -773,18 +749,6 @@ "value": "履歴" } ], - "bibles__version1": [ - { - "type": 0, - "value": "version 1" - } - ], - "bibles__version2": [ - { - "type": 0, - "value": "version 2" - } - ], "blogDetailPage__moreBlogPosts": [ { "type": 0, diff --git a/public/compiled-lang/ru.json b/public/compiled-lang/ru.json index 67f271148..a9b5bd942 100644 --- a/public/compiled-lang/ru.json +++ b/public/compiled-lang/ru.json @@ -725,12 +725,6 @@ "value": "Версия Библии" } ], - "bibleVersion__booksLabel": [ - { - "type": 0, - "value": "66 книг" - } - ], "bibleVersion__description": [ { "type": 0, @@ -743,24 +737,6 @@ "value": "Организатор" } ], - "bibleVersion__websiteLabel": [ - { - "type": 0, - "value": "Website" - } - ], - "bibleVersions__heading": [ - { - "type": 0, - "value": "Библия" - } - ], - "bibleVersions__intro": [ - { - "type": 0, - "value": "Лучший способ постичь здравое учение Иисеса Христа - слушать Слово Божье. Наша аудио Библия поможет вам в этом." - } - ], "bible__title": [ { "type": 0, @@ -773,18 +749,6 @@ "value": "История" } ], - "bibles__version1": [ - { - "type": 0, - "value": "version 1" - } - ], - "bibles__version2": [ - { - "type": 0, - "value": "version 2" - } - ], "blogDetailPage__moreBlogPosts": [ { "type": 0, diff --git a/public/compiled-lang/zh.json b/public/compiled-lang/zh.json index c023f13c4..4a109d9b0 100644 --- a/public/compiled-lang/zh.json +++ b/public/compiled-lang/zh.json @@ -725,12 +725,6 @@ "value": "圣经版本" } ], - "bibleVersion__booksLabel": [ - { - "type": 0, - "value": "66本书" - } - ], "bibleVersion__description": [ { "type": 0, @@ -743,24 +737,6 @@ "value": "赞助者" } ], - "bibleVersion__websiteLabel": [ - { - "type": 0, - "value": "Website" - } - ], - "bibleVersions__heading": [ - { - "type": 0, - "value": "圣经" - } - ], - "bibleVersions__intro": [ - { - "type": 0, - "value": "学习纯正教义的最佳方式是聆听“上帝的道”。我们的音频圣经让您能够聆听最伟大之教师的重要教导。" - } - ], "bible__title": [ { "type": 0, @@ -773,18 +749,6 @@ "value": "历史" } ], - "bibles__version1": [ - { - "type": 0, - "value": "version 1" - } - ], - "bibles__version2": [ - { - "type": 0, - "value": "version 2" - } - ], "blogDetailPage__moreBlogPosts": [ { "type": 0, diff --git a/public/lang/br.json b/public/lang/br.json index c7901058c..fb71aeca7 100644 --- a/public/lang/br.json +++ b/public/lang/br.json @@ -326,24 +326,12 @@ "bibleVersionTypeLockup__type": { "string": "Versão da Bíblia" }, - "bibleVersion__booksLabel": { - "string": "66 livros" - }, "bibleVersion__description": { "string": "Descrição" }, "bibleVersion__sponsorLabel": { "string": "Patrocinador" }, - "bibleVersion__websiteLabel": { - "string": "Site" - }, - "bibleVersions__heading": { - "string": "Bíblia" - }, - "bibleVersions__intro": { - "string": "A melhor forma de aprender sobre a sã doutrina é por meio da Palavra de Deus. Com as nossas Bíblias em áudio, você poderá ouvir grandes ensinamentos do maior professor de todos." - }, "bible__title": { "string": "Bíblia" }, @@ -2747,11 +2735,5 @@ }, "bibles__history": { "string": "Histórico" - }, - "bibles__version1": { - "string": "version 1" - }, - "bibles__version2": { - "string": "version 2" } } \ No newline at end of file diff --git a/public/lang/de.json b/public/lang/de.json index 8057e4b73..ba8e32e66 100644 --- a/public/lang/de.json +++ b/public/lang/de.json @@ -47,21 +47,12 @@ "bibleVersionTypeLockup__type": { "string": "Bibelversion" }, - "bibleVersion__booksLabel": { - "string": "66 Bücher" - }, "bibleVersion__description": { "string": "Beschreibung" }, "bibleVersion__sponsorLabel": { "string": "Sponsor" }, - "bibleVersions__heading": { - "string": "Bibel" - }, - "bibleVersions__intro": { - "string": "Gesunde Lehre wird am besten durch das Hören von Gottes Wort erlernt. Mit unseren Hörbuch-Bibeln kannst du den wertvollen Lektionen des größten Lehrers aller Zeiten lauschen." - }, "blogDetailPage__moreBlogPosts": { "comment": "Blog post detail more blog posts", "string": "Weitere Blog-Posts" @@ -1651,9 +1642,6 @@ "bibleBook__typeLabel": { "string": "KJV Bible" }, - "bibleVersion__websiteLabel": { - "string": "Website" - }, "bible__title": { "string": "Bibel" }, @@ -2747,11 +2735,5 @@ }, "bibles__history": { "string": "Verlauf" - }, - "bibles__version1": { - "string": "version 1" - }, - "bibles__version2": { - "string": "version 2" } } \ No newline at end of file diff --git a/public/lang/en.json b/public/lang/en.json index 9e7b8a5d7..17e59c891 100644 --- a/public/lang/en.json +++ b/public/lang/en.json @@ -374,36 +374,18 @@ "bibleVersionTypeLockup__type": { "string": "Bible Version" }, - "bibleVersion__booksLabel": { - "string": "66 Books" - }, "bibleVersion__description": { "string": "Description" }, "bibleVersion__sponsorLabel": { "string": "Sponsor" }, - "bibleVersion__websiteLabel": { - "string": "Website" - }, - "bibleVersions__heading": { - "string": "Bible" - }, - "bibleVersions__intro": { - "string": "The best way to learn sound doctrine is by listening to the Word of God. Our audio Bibles give you the ability to listen to great teachings from the greatest teacher of all." - }, "bible__title": { "string": "Bible" }, "bibles__history": { "string": "History" }, - "bibles__version1": { - "string": "version 1" - }, - "bibles__version2": { - "string": "version 2" - }, "blogDetailPage__moreBlogPosts": { "comment": "Blog post detail more blog posts", "string": "More Blog Posts" diff --git a/public/lang/es.json b/public/lang/es.json index e61b63cc4..2d413bdec 100644 --- a/public/lang/es.json +++ b/public/lang/es.json @@ -47,21 +47,12 @@ "bibleVersionTypeLockup__type": { "string": "Versión bíblica" }, - "bibleVersion__booksLabel": { - "string": "66 Libros" - }, "bibleVersion__description": { "string": "Descripción" }, "bibleVersion__sponsorLabel": { "string": "Patrocinador" }, - "bibleVersions__heading": { - "string": "Biblia" - }, - "bibleVersions__intro": { - "string": "La mejor manera de aprender la sana doctrina es escuchar la Palabra de Dios. Nuestras Audiobiblias le dan la posibilidad de escuchar grandes lecciones del mayor maestro de todos los tiempos." - }, "blogDetailPage__moreBlogPosts": { "comment": "Blog post detalle más entradas de blog", "string": "Más entradas de blog" @@ -1651,9 +1642,6 @@ "bibleBook__typeLabel": { "string": "KJV Bible" }, - "bibleVersion__websiteLabel": { - "string": "Website" - }, "bible__title": { "string": "Biblia" }, @@ -2747,11 +2735,5 @@ }, "bibles__history": { "string": "Historial" - }, - "bibles__version1": { - "string": "version 1" - }, - "bibles__version2": { - "string": "version 2" } } \ No newline at end of file diff --git a/public/lang/fr.json b/public/lang/fr.json index b1e2fc0e4..3c40ee7f7 100644 --- a/public/lang/fr.json +++ b/public/lang/fr.json @@ -47,21 +47,12 @@ "bibleVersionTypeLockup__type": { "string": "Version de la Bible" }, - "bibleVersion__booksLabel": { - "string": "66 livres" - }, "bibleVersion__description": { "string": "Description" }, "bibleVersion__sponsorLabel": { "string": "Sponsor" }, - "bibleVersions__heading": { - "string": "Bible" - }, - "bibleVersions__intro": { - "string": "La meilleure façon d'apprendre la saine doctrine est en écoutant la Parole de Dieu. Nos bibles audio vous donne la possibilité d'écouter de grands enseignements donnés par le plus grand enseignant de tous les temps." - }, "blogDetailPage__moreBlogPosts": { "comment": "Blog post detail more blog posts", "string": "Plus d'articles de blog" @@ -1651,9 +1642,6 @@ "bibleBook__typeLabel": { "string": "KJV Bible" }, - "bibleVersion__websiteLabel": { - "string": "Website" - }, "bible__title": { "string": "Bible" }, @@ -2747,11 +2735,5 @@ }, "bibles__history": { "string": "Historique" - }, - "bibles__version1": { - "string": "version 1" - }, - "bibles__version2": { - "string": "version 2" } } \ No newline at end of file diff --git a/public/lang/ja.json b/public/lang/ja.json index c5b1d5ace..7424b4c39 100644 --- a/public/lang/ja.json +++ b/public/lang/ja.json @@ -47,21 +47,12 @@ "bibleVersionTypeLockup__type": { "string": "聖書バージョン" }, - "bibleVersion__booksLabel": { - "string": "66巻" - }, "bibleVersion__description": { "string": "内容詳細" }, "bibleVersion__sponsorLabel": { "string": "主催者" }, - "bibleVersions__heading": { - "string": "聖書" - }, - "bibleVersions__intro": { - "string": "確実な教理を学ぶ方法は、神の御言葉を聞くのがベスト。オーディオバイブルを通して最も偉大な教師から最も大切な教え聞くことができます。" - }, "blogDetailPage__moreBlogPosts": { "comment": "Blog post detail more blog posts", "string": "その他のブログ投稿" @@ -1651,9 +1642,6 @@ "bibleBook__typeLabel": { "string": "KJV Bible" }, - "bibleVersion__websiteLabel": { - "string": "Website" - }, "bible__title": { "string": "聖書" }, @@ -2747,11 +2735,5 @@ }, "bibles__history": { "string": "履歴" - }, - "bibles__version1": { - "string": "version 1" - }, - "bibles__version2": { - "string": "version 2" } } \ No newline at end of file diff --git a/public/lang/ru.json b/public/lang/ru.json index e9cfb07b0..59c1afd65 100644 --- a/public/lang/ru.json +++ b/public/lang/ru.json @@ -47,21 +47,12 @@ "bibleVersionTypeLockup__type": { "string": "Версия Библии" }, - "bibleVersion__booksLabel": { - "string": "66 книг" - }, "bibleVersion__description": { "string": "Описание" }, "bibleVersion__sponsorLabel": { "string": "Организатор" }, - "bibleVersions__heading": { - "string": "Библия" - }, - "bibleVersions__intro": { - "string": "Лучший способ постичь здравое учение Иисеса Христа - слушать Слово Божье. Наша аудио Библия поможет вам в этом." - }, "blogDetailPage__moreBlogPosts": { "comment": "Blog post detail more blog posts", "string": "Другие записи блога" @@ -1648,9 +1639,6 @@ "bibleBook__typeLabel": { "string": "KJV Bible" }, - "bibleVersion__websiteLabel": { - "string": "Website" - }, "bible__title": { "string": "Библия" }, @@ -2747,11 +2735,5 @@ }, "bibles__history": { "string": "История" - }, - "bibles__version1": { - "string": "version 1" - }, - "bibles__version2": { - "string": "version 2" } } \ No newline at end of file diff --git a/public/lang/zh.json b/public/lang/zh.json index f34daf990..62189b2f8 100644 --- a/public/lang/zh.json +++ b/public/lang/zh.json @@ -47,21 +47,12 @@ "bibleVersionTypeLockup__type": { "string": "圣经版本" }, - "bibleVersion__booksLabel": { - "string": "66本书" - }, "bibleVersion__description": { "string": "描述" }, "bibleVersion__sponsorLabel": { "string": "赞助者" }, - "bibleVersions__heading": { - "string": "圣经" - }, - "bibleVersions__intro": { - "string": "学习纯正教义的最佳方式是聆听“上帝的道”。我们的音频圣经让您能够聆听最伟大之教师的重要教导。" - }, "blogDetailPage__moreBlogPosts": { "comment": "Blog post detail more blog posts", "string": "更多博客文章" @@ -1651,9 +1642,6 @@ "bibleBook__typeLabel": { "string": "KJV Bible" }, - "bibleVersion__websiteLabel": { - "string": "Website" - }, "bible__title": { "string": "圣经" }, @@ -2747,11 +2735,5 @@ }, "bibles__history": { "string": "历史" - }, - "bibles__version1": { - "string": "version 1" - }, - "bibles__version2": { - "string": "version 2" } } \ No newline at end of file diff --git a/src/components/molecules/card/bibleBook.tsx b/src/components/molecules/card/bibleBook.tsx index 9387472f1..c0298c65c 100644 --- a/src/components/molecules/card/bibleBook.tsx +++ b/src/components/molecules/card/bibleBook.tsx @@ -5,9 +5,9 @@ import { FormattedMessage } from 'react-intl'; import Heading2 from '~components/atoms/heading2'; import Heading6 from '~components/atoms/heading6'; import Link from '~components/atoms/linkWithoutPrefetch'; -import { IBibleBook } from '~lib/api/bibleBrain'; import root from '~lib/routes'; import useLanguageRoute from '~lib/useLanguageRoute'; +import { IBibleBook } from '~src/services/fcbh/types'; import BibleVersionTypeLockup from '../bibleVersionTypeLockup'; import Card from '.'; diff --git a/src/components/molecules/card/bibleVersion.tsx b/src/components/molecules/card/bibleVersion.tsx index ecde9c72d..d3ee112da 100644 --- a/src/components/molecules/card/bibleVersion.tsx +++ b/src/components/molecules/card/bibleVersion.tsx @@ -5,10 +5,10 @@ import { FormattedMessage } from 'react-intl'; import Heading2 from '~components/atoms/heading2'; import Heading6 from '~components/atoms/heading6'; import Link from '~components/atoms/linkWithoutPrefetch'; -import { IBibleVersion } from '~lib/api/bibleBrain'; import root from '~lib/routes'; import useHover from '~lib/useHover'; import useLanguageRoute from '~lib/useLanguageRoute'; +import { IBibleVersion } from '~src/services/fcbh/types'; import BibleVersionTypeLockup from '../bibleVersionTypeLockup'; import Card from '.'; diff --git a/src/components/organisms/passageNavigation.graphql b/src/components/organisms/passageNavigation.graphql index b81fc42f5..84424ff48 100644 --- a/src/components/organisms/passageNavigation.graphql +++ b/src/components/organisms/passageNavigation.graphql @@ -1,16 +1,11 @@ -fragment passageNavigation on BibleConnection { - nodes { - title - books { +fragment passageNavigation on Sequence { + id + title + recordings(first: 150) { + nodes { id title - chapters { - title - url - } + canonicalPath } } - aggregate { - count - } } diff --git a/src/components/organisms/passageNavigation.logic.ts b/src/components/organisms/passageNavigation.logic.ts index 50a0673b6..174663d3a 100644 --- a/src/components/organisms/passageNavigation.logic.ts +++ b/src/components/organisms/passageNavigation.logic.ts @@ -1,21 +1,21 @@ -import { PassageNavigationFragment } from './__generated__/passageNavigation'; +import { IBibleVersion } from '~src/services/fcbh/types'; export function getChapters( - audiobibles: PassageNavigationFragment, + audiobibles: IBibleVersion[], selected: string | null, ) { - const books = audiobibles.nodes?.[0].books; - const chapters = books?.find((book) => book?.title === selected)?.chapters; + const books = audiobibles[0].books; + console.log({ selected, books }); + const chapters = books?.find( + (book) => book?.name.toLowerCase() === selected?.toLowerCase(), + )?.chapters; return chapters; } -export function getBookId( - title: string, - audiobibles: PassageNavigationFragment, -) { - const books = audiobibles.nodes?.[0].books; - const book = books?.find((book) => book?.title === title); +export function getBookId(title: string, audiobibles: IBibleVersion[]) { + const books = audiobibles[0].books; + const book = books?.find((book) => book?.name === title); - return book?.id; + return book?.book_id; } diff --git a/src/components/organisms/passageNavigation.tsx b/src/components/organisms/passageNavigation.tsx index 872b74359..96ca61f5f 100644 --- a/src/components/organisms/passageNavigation.tsx +++ b/src/components/organisms/passageNavigation.tsx @@ -2,65 +2,45 @@ import clsx from 'clsx'; import React, { useState } from 'react'; import Link from '~components/atoms/linkWithoutPrefetch'; -import root from '~src/lib/routes'; -import useLanguageRoute from '~src/lib/useLanguageRoute'; -import { BIBLE_BOOKS } from '../../lib/constants'; import { PassageNavigationFragment } from './__generated__/passageNavigation'; -import { getBookId, getChapters } from './passageNavigation.logic'; import styles from './passageNavigation.module.scss'; type Props = { - audiobibles: PassageNavigationFragment; + books: Array; }; -export default function PassageNavigation(props: Props): JSX.Element { - const [selectedBook, setSelectedBook] = useState( - BIBLE_BOOKS[0], +export default function PassageNavigation({ books }: Props): JSX.Element { + const [selectedBook, setSelectedBook] = useState( + null, ); - const languageRoute = useLanguageRoute(); - return (
    - {BIBLE_BOOKS.map((book) => { - const chapters = getChapters(props.audiobibles, book); + {books.map((book) => { + const chapters = book.recordings.nodes; return (
  • - {book === selectedBook ? ( + {book.id === selectedBook ? (
      - {chapters?.map(({ title }) => { - console.log('title', title); - const n = title.split(' ').pop()?.padStart(2, '0') ?? ''; + {chapters?.map((chapter) => { + const n = Number(chapter.title.split(' ').pop()); return ( -
    • - - {n} - - - {/* - example good link: /en/bibles/chapters/27015/exodus-1 - Current Linking: /en/bibles/20 - */} +
    • + {n}
    • ); })} diff --git a/src/containers/bible/book.spec.tsx b/src/containers/bible/book.spec.tsx index 15222ab83..5168a491f 100644 --- a/src/containers/bible/book.spec.tsx +++ b/src/containers/bible/book.spec.tsx @@ -7,15 +7,19 @@ import videojs from 'video.js'; import AndMiniplayer from '~components/templates/andMiniplayer'; import AndPlaybackContext from '~components/templates/andPlaybackContext'; import { BookProps } from '~containers/bible/book'; -import * as bibleBrain from '~lib/api/bibleBrain'; import { buildStaticRenderer } from '~lib/test/buildStaticRenderer'; import setPlayerMock from '~lib/test/setPlayerMock'; import Book, { getStaticPaths, getStaticProps, } from '~pages/[language]/bibles/[id]/[book]/[chapter]'; +import * as bibleBrain from '~src/services/fcbh/getBible'; +import { getBibleBookChapters } from '~src/services/fcbh/getBibleBookChapters'; +import { getBibles } from '~src/services/fcbh/getBibles'; +import { IBibleBookChapter, IBibleVersion } from '~src/services/fcbh/types'; -jest.mock('~lib/api/bibleBrain'); +jest.mock('~services/fcbh/getBibles'); +jest.mock('~services/fcbh/getBibleBookChapters'); jest.mock('video.js'); const renderPage = buildStaticRenderer((props: BookProps) => { @@ -47,8 +51,8 @@ function loadPageData() { }, }, ], - } as bibleBrain.IBibleVersion); - jest.spyOn(bibleBrain, 'getBibleBookChapters').mockResolvedValue([ + } as IBibleVersion); + jest.mocked(getBibleBookChapters).mockResolvedValue([ { id: 'GEN/1', duration: 123, @@ -56,7 +60,7 @@ function loadPageData() { title: 'the_chapter_title', url: 'https://example.com', }, - ] as bibleBrain.IBibleBookChapter[]); + ] as IBibleBookChapter[]); } describe('Bible book detail page', () => { @@ -88,7 +92,7 @@ describe('Bible book detail page', () => { }); it('generates paths', async () => { - jest.spyOn(bibleBrain, 'getBibles').mockResolvedValue([ + jest.mocked(getBibles).mockResolvedValue([ { id: 'the_version_id', abbreviation: 'KJV', @@ -103,7 +107,7 @@ describe('Bible book detail page', () => { chapters: [1], }, ], - } as bibleBrain.IBibleVersion, + } as IBibleVersion, ]); const { paths } = await getStaticPaths(); diff --git a/src/containers/bible/book.tsx b/src/containers/bible/book.tsx index 24f733da4..62c188775 100644 --- a/src/containers/bible/book.tsx +++ b/src/containers/bible/book.tsx @@ -19,17 +19,17 @@ import SequenceNav from '~components/molecules/sequenceNav'; import Tease from '~components/molecules/tease'; import TeaseRecording from '~components/molecules/teaseRecording'; import { PlaybackContext } from '~components/templates/andPlaybackContext'; -import { - IBibleBook, - IBibleBookChapter, - IBibleVersion, -} from '~lib/api/bibleBrain'; import { BaseColors } from '~lib/constants'; import root from '~lib/routes'; import useLanguageRoute from '~lib/useLanguageRoute'; import IconBack from '~public/img/icons/icon-back-light.svg'; import IconBlog from '~public/img/icons/icon-blog-light-small.svg'; import { RecordingContentType } from '~src/__generated__/graphql'; +import { + IBibleBook, + IBibleBookChapter, + IBibleVersion, +} from '~src/services/fcbh/types'; import { Must } from '~src/types/types'; import styles from './book.module.scss'; diff --git a/src/containers/bible/index.graphql b/src/containers/bible/index.graphql index 47d92eaad..e49df25b3 100644 --- a/src/containers/bible/index.graphql +++ b/src/containers/bible/index.graphql @@ -1,5 +1,18 @@ -query getAudiobibleIndexData { - audiobibles { - ...passageNavigation +query getAudiobibleIndexData($language: Language!) { + collections( + language: $language + contentType: BIBLE_VERSION + first: 10 + orderBy: [{ field: TITLE, direction: ASC }] + ) { + nodes { + id + title + sequences(first: 66, orderBy: [{ field: ID, direction: ASC }]) { + nodes { + ...passageNavigation + } + } + } } } diff --git a/src/containers/bible/index.tsx b/src/containers/bible/index.tsx index 6270a2e9f..a068ccd46 100644 --- a/src/containers/bible/index.tsx +++ b/src/containers/bible/index.tsx @@ -5,18 +5,24 @@ import { FormattedMessage } from 'react-intl'; import { BaseColors } from '~lib/constants'; import IconDisclosure from '~public/img/icons/icon-disclosure-light-small.svg'; import IconSearch from '~public/img/icons/icon-search.svg'; +import withFailStates from '~src/components/HOCs/withFailStates'; import BibleVersionTypeLockup from '~src/components/molecules/bibleVersionTypeLockup'; import Button from '~src/components/molecules/button'; import Dropdown from '~src/components/molecules/dropdown'; import IconButton from '~src/components/molecules/iconButton'; import Tease from '~src/components/molecules/tease'; import PassageNavigation from '~src/components/organisms/passageNavigation'; +import { getBibleAcronym } from '~src/lib/getBibleAcronym'; import { GetAudiobibleIndexDataQuery } from './__generated__'; import styles from './index.module.scss'; -export type BibleIndexProps = GetAudiobibleIndexDataQuery; -export default function Bible(props: BibleIndexProps): JSX.Element { +// export type BibleIndexProps = GetAudiobibleIndexDataQuery; +export type BibleIndexProps = { + data: NonNullable; +}; +function Bible({ data }: BibleIndexProps): JSX.Element { + console.log({ data }); return (
      @@ -38,32 +44,16 @@ export default function Bible(props: BibleIndexProps): JSX.Element { > {(handleClose) => ( )} @@ -78,8 +68,12 @@ export default function Bible(props: BibleIndexProps): JSX.Element {
      - +
      ); } + +export default withFailStates(Bible, { + useShould404: ({ data }) => !data.length, +}); diff --git a/src/containers/bible/version.graphql b/src/containers/bible/version.graphql deleted file mode 100644 index 8f5c4c8bb..000000000 --- a/src/containers/bible/version.graphql +++ /dev/null @@ -1,19 +0,0 @@ -query getAudiobibleVersionData($id: ID!) { - collection(id: $id) { - id - title - description - contentType - canonicalPath(useFuturePath: true) - sponsor { - canonicalPath(useFuturePath: true) - title - website - } - sequences(first: 66, orderBy: [{ field: ID, direction: ASC }]) { - nodes { - ...cardSequence - } - } - } -} diff --git a/src/containers/bible/version.module.scss b/src/containers/bible/version.module.scss deleted file mode 100644 index bc22160dc..000000000 --- a/src/containers/bible/version.module.scss +++ /dev/null @@ -1,14 +0,0 @@ -@import '../../styles/common'; - -.container { - padding: $tease-padding; - background: $ts-bibleVersionH; -} - -.title { - color: $ts-white; -} - -.booksLabel { - color: $ts-lightTone; -} diff --git a/src/containers/bible/version.spec.tsx b/src/containers/bible/version.spec.tsx deleted file mode 100644 index 97882fd5c..000000000 --- a/src/containers/bible/version.spec.tsx +++ /dev/null @@ -1,104 +0,0 @@ -import { screen } from '@testing-library/react'; -import React from 'react'; - -import * as bibleBrain from '~lib/api/bibleBrain'; -import { buildLoader } from '~lib/test/buildLoader'; -import renderWithProviders from '~lib/test/renderWithProviders'; -import Version, { - getStaticPaths, - getStaticProps, -} from '~pages/[language]/bibles/[id]/[[...slugs]]'; - -import { GetAudiobibleVersionsDataDocument } from './__generated__/versions'; - -jest.mock('~lib/api/bibleBrain'); - -async function renderPage() { - const { props } = (await getStaticProps({ - params: { id: 'ENGKJV2' }, - })) as any; - return renderWithProviders(, undefined); -} - -const loadData = buildLoader(GetAudiobibleVersionsDataDocument, { - collections: { - nodes: [], - }, -}); - -function loadPageData() { - jest.spyOn(bibleBrain, 'getBible').mockResolvedValue({ - id: 'the_version_id', - abbreviation: 'KJV', - title: 'the_version_title', - sponsor: { - title: 'FCBH', - website: '', - }, - books: [ - { - book_id: 'ENGESVC/Gen', - name: 'Genesis', - chapters: [50], - bible: { - abbreviation: 'ESV', - }, - }, - ], - } as bibleBrain.IBibleVersion); -} - -describe('version detail page', () => { - it('renders', async () => { - loadPageData(); - - await renderPage(); - }); - - it('lists books', async () => { - loadPageData(); - - const { getByText } = await renderPage(); - - expect(getByText('Genesis')).toBeInTheDocument(); - }); - - it('generates paths', async () => { - loadData(); - - jest.spyOn(bibleBrain, 'getBibles').mockResolvedValue([ - { - id: 'the_version_id', - abbreviation: 'KJV', - title: 'the_version_title', - sponsor: { - title: 'FCBH', - website: '', - }, - books: [], - } as bibleBrain.IBibleVersion, - ]); - - const { paths } = await getStaticPaths(); - - expect(paths).toContain('/en/bibles/the_version_id'); - }); - - it('links books', async () => { - loadPageData(); - - await renderPage(); - - const link = screen.getByRole('link', { name: /Genesis/ }) as any; - - expect(link.href).toContain('/en/bibles/ENGESVC/Gen'); - }); - - it('renders 404', async () => { - jest.spyOn(bibleBrain, 'getBible').mockResolvedValue(null); - - const { getByText } = await renderPage(); - - expect(getByText('Sorry!')).toBeInTheDocument(); - }); -}); diff --git a/src/containers/bible/version.tsx b/src/containers/bible/version.tsx deleted file mode 100644 index fe1e80095..000000000 --- a/src/containers/bible/version.tsx +++ /dev/null @@ -1,130 +0,0 @@ -import React from 'react'; -import { FormattedMessage } from 'react-intl'; - -import Heading1 from '~components/atoms/heading1'; -import Heading6 from '~components/atoms/heading6'; -import HorizontalRule from '~components/atoms/horizontalRule'; -import Link from '~components/atoms/linkWithoutPrefetch'; -import withFailStates from '~components/HOCs/withFailStates'; -import BibleVersionTypeLockup from '~components/molecules/bibleVersionTypeLockup'; -import CardBibleBook from '~components/molecules/card/bibleBook'; -import CardSequence from '~components/molecules/card/sequence'; -import CardGroup from '~components/molecules/cardGroup'; -import ContentWidthLimiter from '~components/molecules/contentWidthLimiter'; -import DefinitionList, { - IDefinitionListTerm, -} from '~components/molecules/definitionList'; -import Tease from '~components/molecules/tease'; -import { IBibleVersion } from '~lib/api/bibleBrain'; -import { BaseColors } from '~lib/constants'; -import { Must } from '~src/types/types'; - -import { GetAudiobibleVersionDataQuery } from './__generated__/version'; -import styles from './version.module.scss'; - -export interface VersionProps { - version: IBibleVersion | GetAudiobibleVersionDataQuery['collection']; -} - -function Version({ version }: Must): JSX.Element { - const { title, description, sponsor } = version; - - const details: IDefinitionListTerm[] = []; - if (description) { - details.push({ - term: ( - - ), - definition:

      {description}

      , - }); - } - if (sponsor && 'canonicalPath' in sponsor && sponsor.canonicalPath) { - details.push({ - term: ( - - ), - definition: ( - - {sponsor.title} - - ), - }); - if (sponsor.website) { - details.push({ - term: ( - - ), - definition: ( - - {sponsor.website} - - ), - }); - } - } else if (sponsor?.website) { - details.push({ - term: ( - - ), - definition: ( -

      - - {sponsor.title} - -

      - ), - }); - } - - return ( - - - - {title} - - - - - - - - {'books' in version - ? version.books.map((book) => ( - - )) - : version.sequences.nodes?.map((s) => ( - - ))} - - - ); -} - -export default withFailStates(Version, { - useShould404: ({ version }) => !version, -}); diff --git a/src/containers/bible/versions.graphql b/src/containers/bible/versions.graphql deleted file mode 100644 index 4ca9dc448..000000000 --- a/src/containers/bible/versions.graphql +++ /dev/null @@ -1,20 +0,0 @@ -query getAudiobibleVersionsData($language: Language!) { - collections( - language: $language - contentType: BIBLE_VERSION - first: 10 - orderBy: [{ field: TITLE, direction: ASC }] - ) { - nodes { - ...cardCollection - sequences(first: 2, orderBy: [{ field: ID, direction: ASC }]) { - nodes { - ...cardSequence - } - } - } - aggregate { - count - } - } -} diff --git a/src/containers/bible/versions.module.scss b/src/containers/bible/versions.module.scss deleted file mode 100644 index 801af6098..000000000 --- a/src/containers/bible/versions.module.scss +++ /dev/null @@ -1,7 +0,0 @@ -.tease { - border-radius: 0; -} - -.kicker { - margin: 0 0 16px; -} diff --git a/src/containers/bible/versions.spec.tsx b/src/containers/bible/versions.spec.tsx deleted file mode 100644 index c30ecd071..000000000 --- a/src/containers/bible/versions.spec.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import React from 'react'; - -import * as bibleBrain from '~lib/api/bibleBrain'; -import { buildLoader } from '~lib/test/buildLoader'; -import renderWithProviders from '~lib/test/renderWithProviders'; -import Versions, { - getStaticPaths, - getStaticProps, -} from '~pages/[language]/bibles'; - -import { GetAudiobibleVersionsDataDocument } from './__generated__/versions'; - -jest.mock('~lib/api/bibleBrain'); - -async function renderPage() { - const { props } = (await getStaticProps({})) as any; - return renderWithProviders(, undefined); -} - -const loadData = buildLoader(GetAudiobibleVersionsDataDocument, { - collections: { - nodes: [], - }, -}); - -function loadPageData() { - loadData(); - jest.spyOn(bibleBrain, 'getBibles').mockResolvedValue([ - { - id: 'the_version_id', - abbreviation: 'KJV', - title: 'the_version_title', - sponsor: { - title: 'FCBH', - website: '', - }, - books: [], - } as bibleBrain.IBibleVersion, - ]); -} - -describe('versions list', () => { - it('renders', async () => { - loadPageData(); - - await renderPage(); - }); - - it('renders versions', async () => { - loadPageData(); - - const { getByText } = await renderPage(); - - expect(getByText('the_version_title')).toBeInTheDocument(); - }); - - it('provides language paths', async () => { - const { paths } = await getStaticPaths(); - - expect(paths).toContain('/en/bibles'); - }); - - it('links entries', async () => { - loadPageData(); - - const { getByText } = await renderPage(); - - const link = getByText('the_version_title') - .parentElement as HTMLLinkElement; - - expect(link.href).toContain('/en/bibles/the_version_id'); - }); - - it('renders 404', async () => { - jest.spyOn(bibleBrain, 'getBibles').mockResolvedValue([]); - - const { notFound } = (await getStaticProps({})) as any; - - expect(notFound).toBe(true); - }); -}); diff --git a/src/containers/bible/versions.tsx b/src/containers/bible/versions.tsx deleted file mode 100644 index 23fe931d6..000000000 --- a/src/containers/bible/versions.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import { FormattedMessage } from 'react-intl'; - -import Heading1 from '~components/atoms/heading1'; -import withFailStates from '~components/HOCs/withFailStates'; -import CardBibleVersion from '~components/molecules/card/bibleVersion'; -import CardCollection from '~components/molecules/card/collection'; -import CardMasonry from '~components/molecules/cardMasonry'; -import ContentWidthLimiter from '~components/molecules/contentWidthLimiter'; -import Tease from '~components/molecules/tease'; -import { IBibleVersion } from '~lib/api/bibleBrain'; - -import { GetAudiobibleVersionsDataQuery } from './__generated__/versions'; -import styles from './versions.module.scss'; - -export interface VersionsProps { - versions: Array< - | IBibleVersion - | NonNullable[0] - >; -} - -function Versions({ versions }: VersionsProps): JSX.Element { - return ( - - - - - -
      - -
      -
      - - - 'canonicalPath' in data ? ( - - ) : ( - - ) - } - /> -
      - ); -} - -export default withFailStates(Versions, { - useShould404: ({ versions }) => !versions.length, -}); diff --git a/src/lib/getBibleAcronym.ts b/src/lib/getBibleAcronym.ts new file mode 100644 index 000000000..7883f4e9e --- /dev/null +++ b/src/lib/getBibleAcronym.ts @@ -0,0 +1,18 @@ +export const getBibleAcronym = (title: string) => { + if (!title.includes('(')) { + return title + .split(' ') + .map((word) => word[0]) + .join(''); + } + const match = title.match(/(.*?)\s*\(.*?\)/); // Match text up to parenthesis + const acronym = match + ? match[1] + .split(' ') + .map((word) => word[0]) + .join('') + : ''; + const parenthesisMatch = title.match(/\((.*?)\)/); + const parenthesisContent = parenthesisMatch ? parenthesisMatch[1] : ''; // Get content inside parenthesis + return acronym + (parenthesisContent ? ` (${parenthesisContent})` : ''); // Combine acronym with content +}; diff --git a/src/pages/[language]/bibles/[id]/[[...slugs]].ts b/src/pages/[language]/bibles/[id]/[[...slugs]].ts deleted file mode 100644 index 2277b0683..000000000 --- a/src/pages/[language]/bibles/[id]/[[...slugs]].ts +++ /dev/null @@ -1,95 +0,0 @@ -import { - GetStaticPathsResult, - GetStaticPropsContext, - GetStaticPropsResult, -} from 'next'; - -import { IBaseProps } from '~containers/base'; -import { getAudiobibleVersionData } from '~containers/bible/__generated__/version'; -import { getAudiobibleVersionsData } from '~containers/bible/__generated__/versions'; -import Version, { VersionProps } from '~containers/bible/version'; -import { getBible, getBibles } from '~lib/api/bibleBrain'; -import { LANGUAGES, REVALIDATE, REVALIDATE_FAILURE } from '~lib/constants'; -import root from '~lib/routes'; -import { CollectionContentType, Language } from '~src/__generated__/graphql'; - -export default Version; - -export async function getStaticProps({ - params, -}: GetStaticPropsContext<{ id: string }>): Promise< - GetStaticPropsResult -> { - let props: VersionProps & IBaseProps; - if (params?.id.includes('K')) { - const version = await getBible(params?.id || '').catch((e) => { - console.log(e); - return null; - }); - if (!version) { - return { - notFound: true, - revalidate: REVALIDATE_FAILURE, - }; - } - props = { - version: { - ...version, - books: version.books.map((b) => ({ - ...b, - id: b.book_id, - title: b.name, - collection: null, - recordings: { - nodes: [], - aggregate: { - count: b.chapters.length, - }, - }, - })), - }, - title: version.title, - }; - } else { - const version = await getAudiobibleVersionData({ id: params?.id || '' }); - if ( - !version.collection || - version.collection.contentType !== CollectionContentType.BibleVersion - ) { - return { - notFound: true, - revalidate: REVALIDATE_FAILURE, - }; - } - props = { - version: version.collection, - title: version.collection?.title, - }; - } - - return { - props, - revalidate: REVALIDATE, - }; -} - -export async function getStaticPaths(): Promise { - const response = (await getBibles()) || []; - const paths = []; - paths.push( - ...response.map(({ id }) => - root.lang(LANGUAGES.ENGLISH.base_urls[0]).bibles.versionId(id).get(), - ), - ); - const apiBibles = await getAudiobibleVersionsData({ - language: Language.English, - }); - paths.push( - ...(apiBibles.collections.nodes || []).map((c) => c.canonicalPath), - ); - - return { - paths, - fallback: true, - }; -} diff --git a/src/pages/[language]/bibles/[id]/[book]/[chapter].tsx b/src/pages/[language]/bibles/[id]/[book]/[chapter].tsx index 8577a7bad..da6edbd9a 100644 --- a/src/pages/[language]/bibles/[id]/[book]/[chapter].tsx +++ b/src/pages/[language]/bibles/[id]/[book]/[chapter].tsx @@ -6,9 +6,11 @@ import { import { IBaseProps } from '~containers/base'; import Book, { BookProps } from '~containers/bible/book'; -import { getBible, getBibleBookChapters, getBibles } from '~lib/api/bibleBrain'; import { LANGUAGES, REVALIDATE, REVALIDATE_FAILURE } from '~lib/constants'; import root from '~lib/routes'; +import { getBible } from '~src/services/fcbh/getBible'; +import { getBibleBookChapters } from '~src/services/fcbh/getBibleBookChapters'; +import { getBibles } from '~src/services/fcbh/getBibles'; export default Book; diff --git a/src/pages/[language]/bibles/index.tsx b/src/pages/[language]/bibles/index.tsx index 8416fb5ce..31277f1ef 100644 --- a/src/pages/[language]/bibles/index.tsx +++ b/src/pages/[language]/bibles/index.tsx @@ -6,33 +6,51 @@ import { import { IBaseProps } from '~containers/base'; import Bible, { BibleIndexProps } from '~containers/bible'; -import { LANGUAGES, REVALIDATE } from '~lib/constants'; +import { LANGUAGES, REVALIDATE, REVALIDATE_FAILURE } from '~lib/constants'; import getIntl from '~lib/getIntl'; import { getLanguageIdByRoute } from '~lib/getLanguageIdByRoute'; import root from '~lib/routes'; import { getAudiobibleIndexData } from '~src/containers/bible/__generated__'; +import { getBibles } from '~src/services/fcbh/getBibles'; +import { IBibleVersion } from '~src/services/fcbh/types'; export default Bible; +type ApiBible = BibleIndexProps['data'][0]; + +function transform(bible: IBibleVersion): ApiBible { + return { + ...bible, + sequences: { + nodes: [], + }, + }; +} + export async function getStaticProps({ params, }: GetStaticPropsContext<{ language: string }>): Promise< GetStaticPropsResult > { - // const response = await getBibles().catch((e) => { - // console.log(e); - // return null; - // }); - // const apiBibles = await getAudiobibleVersionsData({ - // language: getLanguageIdByRoute(params?.language), - // }).catch(() => ({ collections: { nodes: [] } })); - - // if (!apiBibles?.collections.nodes) { - // return { - // notFound: true, - // revalidate: REVALIDATE_FAILURE, - // }; - // } + const response = await getBibles().catch((e) => { + console.log(e); + return null; + }); + + const apiData = await getAudiobibleIndexData({ + language: getLanguageIdByRoute(params?.language), + }).catch(() => ({ collections: { nodes: [] } })); + + const apiBibles = apiData?.collections.nodes || []; + + if (!apiBibles) { + return { + notFound: true, + revalidate: REVALIDATE_FAILURE, + }; + } + + const fcbhBibles = response?.map(transform) || []; const intl = await getIntl(getLanguageIdByRoute(params?.language)); return { @@ -40,14 +58,15 @@ export async function getStaticProps({ // versions: [...(response || []), ...apiBibles.collections.nodes].sort( // (a, b) => a.title.localeCompare(b.title), // ), - ...(await getAudiobibleIndexData({})), + data: [...fcbhBibles, ...apiBibles].sort((a, b) => + a.title.localeCompare(b.title), + ), title: intl.formatMessage({ id: 'bible__title', defaultMessage: 'Bible', }), }, - // revalidate: response ? REVALIDATE : REVALIDATE_FAILURE, - revalidate: REVALIDATE, + revalidate: response ? REVALIDATE : REVALIDATE_FAILURE, }; } diff --git a/src/services/fcbh/getBible.ts b/src/services/fcbh/getBible.ts new file mode 100644 index 000000000..9e97abd56 --- /dev/null +++ b/src/services/fcbh/getBible.ts @@ -0,0 +1,8 @@ +import { getBibles } from './getBibles'; +import { IBibleVersion } from './types'; + +export async function getBible( + bibleId: string, +): Promise { + return getBibles().then((bibles) => bibles?.find(({ id }) => id === bibleId)); +} diff --git a/src/lib/api/bibleBrain.spec.ts b/src/services/fcbh/getBibleBookChapters.spec.ts similarity index 66% rename from src/lib/api/bibleBrain.spec.ts rename to src/services/fcbh/getBibleBookChapters.spec.ts index 49a1fdaf0..2701627bc 100644 --- a/src/lib/api/bibleBrain.spec.ts +++ b/src/services/fcbh/getBibleBookChapters.spec.ts @@ -1,13 +1,13 @@ -import { buildLoader } from '../test/buildLoader'; -import { GetBibleBookContentDocument } from './__generated__/bibleContent'; -import { getBibleBookChapters } from './bibleBrain'; -import getResponse from './bibleBrain.getResponse'; +import { GetBibleBookContentDocument } from '../../lib/api/__generated__/bibleContent'; +import { buildLoader } from '../../lib/test/buildLoader'; +import { getBibleBookChapters } from './getBibleBookChapters'; +import getResponse from './getResponse'; -jest.mock('./bibleBrain.getResponse'); +jest.mock('./getResponse'); const loadData = buildLoader(GetBibleBookContentDocument, {}); -describe('bibleBrain', () => { +describe('getBibleBookChapters', () => { beforeEach(() => { jest.mocked(getResponse).mockResolvedValue({ data: [ diff --git a/src/lib/api/bibleBrain.ts b/src/services/fcbh/getBibleBookChapters.ts similarity index 54% rename from src/lib/api/bibleBrain.ts rename to src/services/fcbh/getBibleBookChapters.ts index 2cbf7113e..356288c08 100644 --- a/src/lib/api/bibleBrain.ts +++ b/src/services/fcbh/getBibleBookChapters.ts @@ -1,90 +1,7 @@ -import { getBibleBookContent } from './__generated__/bibleContent'; -import getResponse from './bibleBrain.getResponse'; +import { getBibleBookContent } from '~src/lib/api/__generated__/bibleContent'; -export interface IBibleVersion { - id: string; - title: string; - abbreviation: string; - description?: string; - books: IBibleBook[]; - sponsor: { - title: string; - website: string; - }; -} -export interface IBible { - abbr: string; - name: string; - vname: string; - language: string; - iso: string; - date: number | null; - books: IBibleBook[]; -} -interface IBBFileset { - book_id: string; - book_name: string; - chapter_start: number; - path: string; - duration: number; -} - -interface IBBBook { - book_id: string; - name: string; - name_short: string; - chapters: number[]; - book_seq: string; - testament: string; -} - -export interface IBibleBook extends IBBBook { - bible: { - abbreviation: string; - }; -} - -export interface IBibleBookChapter { - id: string; - number: number; - title: string; - url: string; - duration: number; - text: string; -} - -export async function getBibles(): Promise { - const response = await getResponse<{ data: IBible }>('/bibles/ENGKJV?'); - if (!response) { - return null; - } - - return [ - { - id: 'ENGKJV2', - title: 'King James Version (Dramatized)', - abbreviation: 'KJV', - }, - ].map((v) => ({ - ...response.data, - books: (response.data?.books || []).map((b) => ({ - ...b, - book_id: `${v.id}/${b.book_id}`, - bible: { abbreviation: v.abbreviation }, - })), - sponsor: { - title: 'Faith Comes By Hearing', - website: 'http://www.faithcomesbyhearing.com/', - }, - ...v, - })); -} - -export async function getBible( - bibleId: string, -): Promise { - return getBibles().then((bibles) => bibles?.find(({ id }) => id === bibleId)); -} +import getResponse from './getResponse'; +import { IBBFileset, IBibleBookChapter } from './types'; const bookIdMap: { [k: string]: string } = { GEN: 'Gen', @@ -160,9 +77,7 @@ export async function getBibleBookChapters( testament: string, bookId: string, ): Promise { - const filesetId = `${bibleId.substring(0, bibleId.length - 1)}${ - testament === 'OT' ? 'O' : 'N' - }${bibleId.substring(bibleId.length - 1)}DA`; + const filesetId = `${bibleId.substring(0, bibleId.length - 1)}${testament === 'OT' ? 'O' : 'N'}${bibleId.substring(bibleId.length - 1)}DA`; const response = await getResponse<{ data: IBBFileset[] }>( `/bibles/filesets/${filesetId}?`, ); diff --git a/src/services/fcbh/getBibles.ts b/src/services/fcbh/getBibles.ts new file mode 100644 index 000000000..7e907f7b3 --- /dev/null +++ b/src/services/fcbh/getBibles.ts @@ -0,0 +1,29 @@ +import getResponse from './getResponse'; +import { IBible, IBibleVersion } from './types'; + +export async function getBibles(): Promise { + const response = await getResponse<{ data: IBible }>('/bibles/ENGKJV?'); + if (!response) { + return null; + } + + return [ + { + id: 'ENGKJV2', + title: 'King James Version (Dramatized)', + abbreviation: 'KJV', + }, + ].map((v) => ({ + ...response.data, + books: (response.data?.books || []).map((b) => ({ + ...b, + book_id: `${v.id}/${b.book_id}`, + bible: { abbreviation: v.abbreviation }, + })), + sponsor: { + title: 'Faith Comes By Hearing', + website: 'http://www.faithcomesbyhearing.com/', + }, + ...v, + })); +} diff --git a/src/lib/api/bibleBrain.getResponse.ts b/src/services/fcbh/getResponse.ts similarity index 100% rename from src/lib/api/bibleBrain.getResponse.ts rename to src/services/fcbh/getResponse.ts diff --git a/src/services/fcbh/types.ts b/src/services/fcbh/types.ts new file mode 100644 index 000000000..4ab56e8d8 --- /dev/null +++ b/src/services/fcbh/types.ts @@ -0,0 +1,51 @@ +export interface IBibleVersion { + id: string; + title: string; + abbreviation: string; + description?: string; + books: IBibleBook[]; + sponsor: { + title: string; + website: string; + }; +} +export interface IBible { + abbr: string; + name: string; + vname: string; + language: string; + iso: string; + date: number | null; + books: IBibleBook[]; +} +export interface IBBFileset { + book_id: string; + book_name: string; + chapter_start: number; + path: string; + duration: number; +} + +interface IBBBook { + book_id: string; + name: string; + name_short: string; + chapters: number[]; + book_seq: string; + testament: string; +} + +export interface IBibleBook extends IBBBook { + bible: { + abbreviation: string; + }; +} + +export interface IBibleBookChapter { + id: string; + number: number; + title: string; + url: string; + duration: number; + text: string; +} diff --git a/tsconfig.json b/tsconfig.json index 1a01c5d67..b7efd64a3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,7 +28,8 @@ "~components/*": ["src/components/*"], "~containers/*": ["src/containers/*"], "~pages/*": ["src/pages/*"], - "~public/*": ["public/*"] + "~public/*": ["public/*"], + "~services/*": ["src/services/*"] }, "incremental": true },