Skip to content

Commit

Permalink
Clean up the code
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecoble committed Dec 17, 2024
1 parent dcdaa77 commit 84097fc
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/components/organisms/passageNavigation/chapterGrid.tsx
Original file line number Diff line number Diff line change
@@ -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<PassageNavigationFragment['recordings']['nodes']>[0];
type ChapterId = Chapter['id'];
Expand Down
24 changes: 12 additions & 12 deletions src/components/organisms/passageNavigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -77,8 +77,8 @@ function findVersionAndBookId(
versions: Array<Version>,
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];
}
Expand Down Expand Up @@ -116,7 +116,7 @@ export default function PassageNavigation({
setSelectedVersion(version);
setSelectedBookId(bookId);
}
}, [selectedChapterId]);
}, [selectedChapterId, chapterId, setSelectedChapterId, versions]);

const [selectedView, setSelectedView] = useLocalStorage<'grid' | 'list'>(
'passageNavLayout',
Expand Down
5 changes: 2 additions & 3 deletions src/components/organisms/recording.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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;
Expand Down
8 changes: 3 additions & 5 deletions src/containers/bible/book.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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,
Expand All @@ -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;
Expand All @@ -43,7 +41,7 @@ export interface BookProps {
chapterNumber: string | number;
}

const Book = (params: Must<BookProps & BibleIndexProps>) => {
const Book = (params: Must<BookProps>) => {
const chapter = params.chapters.find(
({ number }) => number === +params.chapterNumber,
);
Expand Down Expand Up @@ -71,7 +69,7 @@ function BookInner({
book,
chapters,
chapterNumber,
}: Must<BookProps & BibleIndexProps>): JSX.Element {
}: Must<BookProps>): JSX.Element {
const { id, description, sponsor } = version;
const languageRoute = useLanguageRoute();
const chapter = chapters.find(({ number }) => number === +chapterNumber);
Expand Down
1 change: 1 addition & 0 deletions src/containers/bible/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';

import withFailStates from '~src/components/HOCs/withFailStates';
import Tease from '~src/components/molecules/tease';
import PassageNavigation, {
Expand Down
10 changes: 3 additions & 7 deletions src/lib/getBibleStaticProps.ts
Original file line number Diff line number Diff line change
@@ -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<ApiBible['sequences']['nodes']>[0];
Expand Down
5 changes: 3 additions & 2 deletions src/pages/[language]/bibles/chapters/[id]/[[...slugs]].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,7 +30,8 @@ export async function getStaticProps({
GetStaticPropsResult<
{
recording: RecordingFragment;
} & IBaseProps
} & IBaseProps &
BibleIndexProps
>
> {
const { recording } = await getAudiobibleBookDetailData({
Expand Down
1 change: 0 additions & 1 deletion src/pages/[language]/bibles/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import root from '~lib/routes';
import {
concatBibles,
getApiBibles,
getBibleStaticProps,
getFcbhBibles,
} from '~src/lib/getBibleStaticProps';
import getIntl from '~src/lib/getIntl';
Expand Down

0 comments on commit 84097fc

Please sign in to comment.