diff --git a/src/components/organisms/passageNavigation/chapterGrid.tsx b/src/components/organisms/passageNavigation/chapterGrid.tsx index 68b5b3a92..131848953 100644 --- a/src/components/organisms/passageNavigation/chapterGrid.tsx +++ b/src/components/organisms/passageNavigation/chapterGrid.tsx @@ -1,10 +1,10 @@ import React from 'react'; import Link from '~components/atoms/linkWithoutPrefetch'; +import { useLocalStorage } from '~src/lib/hooks/useLocalStorage'; import { PassageNavigationFragment } from './__generated__/index'; import styles from './index.module.scss'; -import { useLocalStorage } from '~src/lib/hooks/useLocalStorage'; type Chapter = NonNullable[0]; type ChapterId = Chapter['id']; diff --git a/src/components/organisms/passageNavigation/index.tsx b/src/components/organisms/passageNavigation/index.tsx index 17d1f61c4..a5fd74900 100644 --- a/src/components/organisms/passageNavigation/index.tsx +++ b/src/components/organisms/passageNavigation/index.tsx @@ -2,20 +2,20 @@ import clsx from 'clsx'; import React, { ReactNode, useEffect, useState } from 'react'; import { FormattedMessage } from 'react-intl'; -import { useLocalStorage } from '~src/lib/hooks/useLocalStorage'; - -import IconSearch from '~public/img/icons/icon-search.svg'; import IconDisclosure from '~public/img/icons/icon-disclosure.svg'; -import BookGrid from './bookGrid'; -import BookList from './bookList'; -import styles from './index.module.scss'; +import IconSearch from '~public/img/icons/icon-search.svg'; import BibleVersionTypeLockup from '~src/components/molecules/bibleVersionTypeLockup'; -import Dropdown from '~src/components/molecules/dropdown'; import Button from '~src/components/molecules/button'; -import { getBibleAcronym } from '~src/lib/getBibleAcronym'; -import { GetAudiobibleIndexDataQuery } from '~src/containers/bible/__generated__'; +import Dropdown from '~src/components/molecules/dropdown'; import IconButton from '~src/components/molecules/iconButton'; +import { GetAudiobibleIndexDataQuery } from '~src/containers/bible/__generated__'; import { BaseColors } from '~src/lib/constants'; +import { getBibleAcronym } from '~src/lib/getBibleAcronym'; +import { useLocalStorage } from '~src/lib/hooks/useLocalStorage'; + +import BookGrid from './bookGrid'; +import BookList from './bookList'; +import styles from './index.module.scss'; export type Version = NonNullable< GetAudiobibleIndexDataQuery['collections']['nodes'] @@ -77,8 +77,8 @@ function findVersionAndBookId( versions: Array, chapterId: ChapterId, ): [Version, BookId] { - for (let version of versions) { - for (let book of version.sequences.nodes || []) { + for (const version of versions) { + for (const book of version.sequences.nodes || []) { if (book.recordings.nodes?.find((r) => r.id === chapterId)) { return [version, book.id]; } @@ -116,7 +116,7 @@ export default function PassageNavigation({ setSelectedVersion(version); setSelectedBookId(bookId); } - }, [selectedChapterId]); + }, [selectedChapterId, chapterId, setSelectedChapterId, versions]); const [selectedView, setSelectedView] = useLocalStorage<'grid' | 'list'>( 'passageNavLayout', diff --git a/src/components/organisms/recording.tsx b/src/components/organisms/recording.tsx index cd7a624f9..339cbc4c7 100644 --- a/src/components/organisms/recording.tsx +++ b/src/components/organisms/recording.tsx @@ -10,7 +10,6 @@ import HorizontalRule from '~components/atoms/horizontalRule'; import LineHeading from '~components/atoms/lineHeading'; import Link from '~components/atoms/linkWithoutPrefetch'; import { TeaseRecordingFragment } from '~components/molecules/__generated__/teaseRecording'; -import BibleVersionTypeLockup from '~components/molecules/bibleVersionTypeLockup'; import Button from '~components/molecules/button'; import CopyrightInfo from '~components/molecules/copyrightInfo'; import DefinitionList, { @@ -35,14 +34,14 @@ import { RecordingContentType, SequenceContentType, } from '~src/__generated__/graphql'; +import { BibleIndexProps } from '~src/containers/bible'; import useLanguageRoute from '~src/lib/hooks/useLanguageRoute'; import { analytics } from '../../lib/analytics'; import PlaylistTypeLockup from '../molecules/playlistTypeLockup'; import { RecordingFragment } from './__generated__/recording'; -import styles from './recording.module.scss'; -import { BibleIndexProps } from '~src/containers/bible'; import PassageNavigation from './passageNavigation'; +import styles from './recording.module.scss'; interface RecordingProps { recording: RecordingFragment; diff --git a/src/containers/bible/book.tsx b/src/containers/bible/book.tsx index 8e7b2580d..853d3af96 100644 --- a/src/containers/bible/book.tsx +++ b/src/containers/bible/book.tsx @@ -8,7 +8,6 @@ import Link from '~components/atoms/linkWithoutPrefetch'; import withFailStates from '~components/HOCs/withFailStates'; import { PlayerFragment } from '~components/molecules/__generated__/player'; import { SequenceNavFragment } from '~components/molecules/__generated__/sequenceNav'; - import Button from '~components/molecules/button'; import ContentWidthLimiter from '~components/molecules/contentWidthLimiter'; import DefinitionList, { @@ -24,6 +23,7 @@ import root from '~lib/routes'; 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 BibleVersionTypeLockup from '~src/components/molecules/bibleVersionTypeLockup'; import useLanguageRoute from '~src/lib/hooks/useLanguageRoute'; import { IBibleBook, @@ -33,8 +33,6 @@ import { import { Must } from '~src/types/types'; import styles from './book.module.scss'; -import { BibleIndexProps } from '.'; -import BibleVersionTypeLockup from '~src/components/molecules/bibleVersionTypeLockup'; export interface BookProps { version: IBibleVersion; @@ -43,7 +41,7 @@ export interface BookProps { chapterNumber: string | number; } -const Book = (params: Must) => { +const Book = (params: Must) => { const chapter = params.chapters.find( ({ number }) => number === +params.chapterNumber, ); @@ -71,7 +69,7 @@ function BookInner({ book, chapters, chapterNumber, -}: Must): JSX.Element { +}: Must): JSX.Element { const { id, description, sponsor } = version; const languageRoute = useLanguageRoute(); const chapter = chapters.find(({ number }) => number === +chapterNumber); diff --git a/src/containers/bible/index.tsx b/src/containers/bible/index.tsx index 9644324a0..773c5c686 100644 --- a/src/containers/bible/index.tsx +++ b/src/containers/bible/index.tsx @@ -1,4 +1,5 @@ import React from 'react'; + import withFailStates from '~src/components/HOCs/withFailStates'; import Tease from '~src/components/molecules/tease'; import PassageNavigation, { diff --git a/src/lib/getBibleStaticProps.ts b/src/lib/getBibleStaticProps.ts index d7314a5d4..d1c7f23bd 100644 --- a/src/lib/getBibleStaticProps.ts +++ b/src/lib/getBibleStaticProps.ts @@ -1,16 +1,12 @@ import { Language } from '~src/__generated__/graphql'; import { BibleIndexProps } from '~src/containers/bible'; +import { getAudiobibleIndexData } from '~src/containers/bible/__generated__'; import { BOOK_ID_MAP } from '~src/services/fcbh/constants'; import { getBibleBookChapters } from '~src/services/fcbh/getBibleBookChapters'; +import { getBibles } from '~src/services/fcbh/getBibles'; import { IBibleBookChapter, IBibleVersion } from '~src/services/fcbh/types'; + import root from './routes'; -import { getBibles } from '~src/services/fcbh/getBibles'; -import { getAudiobibleIndexData } from '~src/containers/bible/__generated__'; -import { GetStaticPropsResult } from 'next'; -import { IBaseProps } from '~src/containers/base'; -import { REVALIDATE, REVALIDATE_FAILURE } from './constants'; -import { getLanguageIdByRoute } from './getLanguageIdByRoute'; -import getIntl from './getIntl'; type ApiBible = BibleIndexProps['data'][0]; type ApiBook = NonNullable[0]; diff --git a/src/pages/[language]/bibles/chapters/[id]/[[...slugs]].ts b/src/pages/[language]/bibles/chapters/[id]/[[...slugs]].ts index a8837f8a6..2a64e741e 100644 --- a/src/pages/[language]/bibles/chapters/[id]/[[...slugs]].ts +++ b/src/pages/[language]/bibles/chapters/[id]/[[...slugs]].ts @@ -14,12 +14,12 @@ import { import { REVALIDATE, REVALIDATE_FAILURE } from '~lib/constants'; import { getDetailStaticPaths } from '~lib/getDetailStaticPaths'; import { RecordingContentType } from '~src/__generated__/graphql'; +import { BibleIndexProps } from '~src/containers/bible'; import { concatBibles, getApiBibles, getFcbhBibles, } from '~src/lib/getBibleStaticProps'; -import getIntl from '~src/lib/getIntl'; import { getLanguageIdByRoute } from '~src/lib/getLanguageIdByRoute'; export default Recording; @@ -30,7 +30,8 @@ export async function getStaticProps({ GetStaticPropsResult< { recording: RecordingFragment; - } & IBaseProps + } & IBaseProps & + BibleIndexProps > > { const { recording } = await getAudiobibleBookDetailData({ diff --git a/src/pages/[language]/bibles/index.tsx b/src/pages/[language]/bibles/index.tsx index b4fdbcf71..caadf2a41 100644 --- a/src/pages/[language]/bibles/index.tsx +++ b/src/pages/[language]/bibles/index.tsx @@ -11,7 +11,6 @@ import root from '~lib/routes'; import { concatBibles, getApiBibles, - getBibleStaticProps, getFcbhBibles, } from '~src/lib/getBibleStaticProps'; import getIntl from '~src/lib/getIntl';