Skip to content

Commit

Permalink
Add shared LocaleAndTranslations type
Browse files Browse the repository at this point in the history
  • Loading branch information
elmeister committed Aug 27, 2023
1 parent 1cd2fb3 commit eef090a
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ import useMyStyles from "hooks/useMyStyles";
import { getTranslate } from "shared/translate";
import classNames from "utils/classNames";

interface Props {
type Props = {
chapterData: GitaChapterData;
versesData: Pick<
GitaVerse,
"id" | "verse_number" | "gita_translations" | "chapter_number"
>[];
locale: Locale;
translations: Record<string, string>;
}
} & LocaleAndTranslations;

export default function ChapterPage({
chapterData: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import classNames from "utils/classNames";

type Props = {
verseData: GitaVerse;
translations: Record<string, string>;
locale: Locale;
};
} & LocaleAndTranslations;

export default function VersePage({ verseData, translations, locale }: Props) {
return (
Expand Down
5 changes: 1 addition & 4 deletions src/app/search/search-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ interface SearchQueryVerse {
export default function SearchPage({
translations,
locale,
}: {
locale: Locale;
translations: Record<string, string>;
}) {
}: LocaleAndTranslations) {
const searchParams = useSearchParams();
const query = searchParams?.get("query");
const [data, setData] = useState<SearchQueryVerse[]>();
Expand Down
12 changes: 3 additions & 9 deletions src/app/verse-of-the-day/VerseOfTheDay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@ import Verse from "components/Verse";
import useMyStyles from "hooks/useMyStyles";
import classNames from "utils/classNames";

interface VerseOfTheDayProps {
type Props = {
dailyVerse: GitaVerse;
translations: Record<string, string>;
locale: Locale;
}
} & LocaleAndTranslations;

const VerseOfTheDay = ({
dailyVerse,
translations,
locale,
}: VerseOfTheDayProps) => {
const VerseOfTheDay = ({ dailyVerse, translations, locale }: Props) => {
const styles = useMyStyles();

return (
Expand Down
7 changes: 1 addition & 6 deletions src/components/AboutBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import { getTranslate } from "shared/translate";

import AboutGitaBanner from "../../public/quotes-bg.png";

type Props = {
locale: Locale;
translations: Record<string, string>;
};

export default function AboutBanner(props: Props) {
export default function AboutBanner(props: LocaleAndTranslations) {
const { locale, translations } = props;
const translate = getTranslate(translations, locale);

Expand Down
7 changes: 1 addition & 6 deletions src/components/Home/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import Image from "next/image";
import LinkWithLocale from "components/LinkWithLocale";
import { getTranslate } from "shared/translate";

type Props = {
locale: Locale;
translations: Record<string, string>;
};

const Banner = (props: Props) => {
const Banner = (props: LocaleAndTranslations) => {
const { translations, locale } = props;

const translate = getTranslate(translations, locale);
Expand Down
6 changes: 2 additions & 4 deletions src/components/Home/Newsletter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ import Modal from "./Modal";

type SubscribeMessage = { isSuccess: boolean; message: string };

interface Props {
type Props = {
notification: {
name: string;
message: string;
status: string;
};
locale: Locale;
translations: Record<string, string>;
}
} & LocaleAndTranslations;

const Newsletter = ({ notification, locale, translations }: Props) => {
const [modalVisible, setModalVisible] = useState<boolean>(false);
Expand Down
7 changes: 1 addition & 6 deletions src/components/Home/VerseOfDay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import { getTranslate } from "shared/translate";
import { getDailyVerse } from "../../lib/getDailyVerse";
import { Skeleton } from "../Skeleton";

type Props = {
locale: Locale;
translations: Record<string, string>;
};

const VerseOfDay = async (props: Props) => {
const VerseOfDay = async (props: LocaleAndTranslations) => {
const { translations, locale } = props;

const dailyVerse = await getDailyVerse(locale);
Expand Down
6 changes: 2 additions & 4 deletions src/components/Verse/Commentary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import classNames from "../../utils/classNames";
import splitIntoParagraphs from "../../utils/splitIntoParagraphs";
import { Skeleton } from "../Skeleton";

interface Props {
type Props = {
commentaryData: GitaLanguage[] | undefined;
translations: Record<string, string>;
locale: Locale;
}
} & LocaleAndTranslations;

export default function Commentary({
commentaryData,
Expand Down
6 changes: 2 additions & 4 deletions src/components/Verse/Translation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import useMyStyles from "hooks/useMyStyles";
import { getTranslate } from "shared/translate";
import classNames from "utils/classNames";

interface Props {
type Props = {
translationData: GitaLanguage[] | undefined;
translations: Record<string, string>;
locale: Locale;
}
} & LocaleAndTranslations;

export default function Translation({
translationData,
Expand Down
8 changes: 3 additions & 5 deletions src/components/Verse/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ import { SvgFloralDivider } from "../svgs";
import Commentary from "./Commentary";
import Translation from "./Translation";

interface VerseProps {
type Props = {
verse: GitaVerse;
translations: Record<string, string>;
locale: Locale;
}
} & LocaleAndTranslations;

const Verse = ({
verse: {
Expand All @@ -34,7 +32,7 @@ const Verse = ({
},
translations,
locale,
}: VerseProps) => {
}: Props) => {
const styles = useMyStyles();

const { advancedSettings, updateAdvancedSettings } = useAdvancedSettings();
Expand Down
7 changes: 1 addition & 6 deletions src/layouts/ChapterLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ import { getTranslate } from "shared/translate";
import Footer from "../components/Footers/Footer";
import ChapterHeader from "../components/Headers/ChapterHeader";

type Props = {
locale: Locale;
translations: Record<string, string>;
};

const ChapterLayout = ({
children,
translations,
locale,
}: React.PropsWithChildren<Props>) => {
}: React.PropsWithChildren<LocaleAndTranslations>) => {
const translate = getTranslate(translations, locale);

return (
Expand Down
7 changes: 1 addition & 6 deletions src/layouts/HomeLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ import { getTranslate } from "shared/translate";
import Footer from "../components/Footers/Footer";
import IndexHeader from "../components/Headers/IndexHeader";

type Props = {
locale: Locale;
translations: Record<string, string>;
};

const HomeLayout = ({
children,
locale,
translations,
}: React.PropsWithChildren<Props>) => {
}: React.PropsWithChildren<LocaleAndTranslations>) => {
const translate = getTranslate(translations, locale);

return (
Expand Down
7 changes: 1 addition & 6 deletions src/layouts/PagesLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ import { getTranslate } from "shared/translate";

import Footer from "../components/Footers/Footer";

type Props = {
locale: Locale;
translations: Record<string, string>;
};

const PagesLayout = ({
children,
locale,
translations,
}: React.PropsWithChildren<Props>) => {
}: React.PropsWithChildren<LocaleAndTranslations>) => {
const translate = getTranslate(translations, locale);

return (
Expand Down
11 changes: 7 additions & 4 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ interface TChapter {
verses_count: number;
}

interface ChaptersProps {
type ChaptersProps = {
chapters: TChapter[];
locale: Locale;
translations: Record<string, string>;
}
} & LocaleAndTranslations;

interface NewsletterFormData {
name: string;
Expand Down Expand Up @@ -93,3 +91,8 @@ interface SvgProps {
}

type Translate = (literal: string, options?: {}) => string;

type LocaleAndTranslations = {
locale: Locale;
translations: Record<string, string>;
};

0 comments on commit eef090a

Please sign in to comment.