From d247f3f9a32a010c560096167e05ad81c1df2f34 Mon Sep 17 00:00:00 2001 From: Caleb Cox Date: Mon, 29 Apr 2024 16:15:30 -0500 Subject: [PATCH] Import i18n from src/lib/i18n Importing i18n directly from 'i18next' will result in an i18n instance that is not configured and doesn't load translation files. i18n.t will return undefined in tests. --- pages/login.page.tsx | 2 +- .../ContactDetailsTab/Other/ContactDetailsOther.tsx | 2 +- .../ContactDetailsTab/People/Items/PersonModal/uploadAvatar.ts | 2 +- .../Organization/Modals/OrganizationImportDataSyncModal.tsx | 3 +-- src/components/Tool/Appeal/AddAppealForm.tsx | 2 +- .../Tool/Appeal/AppealDetails/AppealDetailsAsked.tsx | 2 +- .../Tool/Appeal/AppealDetails/AppealDetailsCommitted.tsx | 2 +- .../Tool/Appeal/AppealDetails/AppealDetailsExcluded.tsx | 2 +- .../Tool/Appeal/AppealDetails/AppealDetailsGiven.tsx | 2 +- .../Tool/Appeal/AppealDetails/AppealDetailsReceived.tsx | 2 +- .../Tool/FixCommitmentInfo/InputOptions/Frequencies.ts | 2 +- src/components/Tool/NoData.tsx | 2 +- src/hooks/useGetTimezones.ts | 2 +- src/utils/contacts/contactPartnershipStatus.ts | 2 +- 14 files changed, 14 insertions(+), 15 deletions(-) diff --git a/pages/login.page.tsx b/pages/login.page.tsx index bd2dbc5f6..292731eca 100644 --- a/pages/login.page.tsx +++ b/pages/login.page.tsx @@ -3,13 +3,13 @@ import Head from 'next/head'; import React, { ReactElement, useEffect } from 'react'; import SubjectIcon from '@mui/icons-material/Subject'; import { Button } from '@mui/material'; -import i18n from 'i18next'; import { getSession, signIn } from 'next-auth/react'; import BaseLayout from 'src/components/Layouts/Basic'; import Loading from 'src/components/Loading'; import Welcome from 'src/components/Welcome'; import useGetAppSettings from 'src/hooks/useGetAppSettings'; import { extractCookie } from 'src/lib/extractCookie'; +import i18n from 'src/lib/i18n'; export interface LoginProps { signInButtonText: string; diff --git a/src/components/Contacts/ContactDetails/ContactDetailsTab/Other/ContactDetailsOther.tsx b/src/components/Contacts/ContactDetails/ContactDetailsTab/Other/ContactDetailsOther.tsx index 2b56e4b15..1019f20eb 100644 --- a/src/components/Contacts/ContactDetails/ContactDetailsTab/Other/ContactDetailsOther.tsx +++ b/src/components/Contacts/ContactDetails/ContactDetailsTab/Other/ContactDetailsOther.tsx @@ -1,9 +1,9 @@ import React from 'react'; import { Box, IconButton, Typography } from '@mui/material'; import { styled } from '@mui/material/styles'; -import i18n from 'i18next'; import { useTranslation } from 'react-i18next'; import { PreferredContactMethodEnum } from 'src/graphql/types.generated'; +import i18n from 'src/lib/i18n'; import { EditIcon } from '../StyledComponents'; import { ContactOtherFragment } from './ContactOther.generated'; diff --git a/src/components/Contacts/ContactDetails/ContactDetailsTab/People/Items/PersonModal/uploadAvatar.ts b/src/components/Contacts/ContactDetails/ContactDetailsTab/People/Items/PersonModal/uploadAvatar.ts index 9494c2fc8..d88f350d0 100644 --- a/src/components/Contacts/ContactDetails/ContactDetailsTab/People/Items/PersonModal/uploadAvatar.ts +++ b/src/components/Contacts/ContactDetails/ContactDetailsTab/People/Items/PersonModal/uploadAvatar.ts @@ -1,4 +1,4 @@ -import { TFunction } from 'i18next'; +import { TFunction } from 'react-i18next'; export const validateAvatar = ({ file, diff --git a/src/components/Settings/integrations/Organization/Modals/OrganizationImportDataSyncModal.tsx b/src/components/Settings/integrations/Organization/Modals/OrganizationImportDataSyncModal.tsx index 6d4ce7552..44ae78148 100644 --- a/src/components/Settings/integrations/Organization/Modals/OrganizationImportDataSyncModal.tsx +++ b/src/components/Settings/integrations/Organization/Modals/OrganizationImportDataSyncModal.tsx @@ -8,9 +8,8 @@ import { Typography, } from '@mui/material'; import { styled } from '@mui/material/styles'; -import { TFunction } from 'i18next'; import { useSnackbar } from 'notistack'; -import { useTranslation } from 'react-i18next'; +import { TFunction, useTranslation } from 'react-i18next'; import { CancelButton, SubmitButton, diff --git a/src/components/Tool/Appeal/AddAppealForm.tsx b/src/components/Tool/Appeal/AddAppealForm.tsx index 2affe52ed..c815d6983 100644 --- a/src/components/Tool/Appeal/AddAppealForm.tsx +++ b/src/components/Tool/Appeal/AddAppealForm.tsx @@ -16,13 +16,13 @@ import { } from '@mui/material'; import { styled } from '@mui/material/styles'; import { Field, Form, Formik } from 'formik'; -import i18n from 'i18next'; import { useSnackbar } from 'notistack'; import { useTranslation } from 'react-i18next'; import { makeStyles } from 'tss-react/mui'; import * as yup from 'yup'; import { useContactFiltersQuery } from 'pages/accountLists/[accountListId]/contacts/Contacts.generated'; import { MultiselectFilter } from 'src/graphql/types.generated'; +import i18n from 'src/lib/i18n'; import { useAccountListId } from '../../../hooks/useAccountListId'; import theme from '../../../theme'; import AnimatedCard from '../../AnimatedCard'; diff --git a/src/components/Tool/Appeal/AppealDetails/AppealDetailsAsked.tsx b/src/components/Tool/Appeal/AppealDetails/AppealDetailsAsked.tsx index fe86c4e3b..28d770155 100644 --- a/src/components/Tool/Appeal/AppealDetails/AppealDetailsAsked.tsx +++ b/src/components/Tool/Appeal/AppealDetails/AppealDetailsAsked.tsx @@ -3,9 +3,9 @@ import { mdiDelete, mdiSquareEditOutline } from '@mdi/js'; import Icon from '@mdi/react'; import { Box, IconButton } from '@mui/material'; import { DataGrid, GridSelectionModel } from '@mui/x-data-grid'; -import i18n from 'i18next'; import { makeStyles } from 'tss-react/mui'; import { TestAppeal } from 'pages/accountLists/[accountListId]/tools/appeals/testAppeal'; +import i18n from 'src/lib/i18n'; import theme from '../../../../theme'; import { useAppealContext } from '../AppealContextProvider/AppealContextProvider'; import AppealDetailsNoData from './AppealDetailsNoData'; diff --git a/src/components/Tool/Appeal/AppealDetails/AppealDetailsCommitted.tsx b/src/components/Tool/Appeal/AppealDetails/AppealDetailsCommitted.tsx index bd9912e77..43f151984 100644 --- a/src/components/Tool/Appeal/AppealDetails/AppealDetailsCommitted.tsx +++ b/src/components/Tool/Appeal/AppealDetails/AppealDetailsCommitted.tsx @@ -3,9 +3,9 @@ import { mdiDelete, mdiSquareEditOutline } from '@mdi/js'; import Icon from '@mdi/react'; import { Box, IconButton } from '@mui/material'; import { DataGrid, GridSelectionModel } from '@mui/x-data-grid'; -import i18n from 'i18next'; import { makeStyles } from 'tss-react/mui'; import { TestAppeal } from 'pages/accountLists/[accountListId]/tools/appeals/testAppeal'; +import i18n from 'src/lib/i18n'; import theme from '../../../../theme'; import { useAppealContext } from '../AppealContextProvider/AppealContextProvider'; import AppealDetailsNoData from './AppealDetailsNoData'; diff --git a/src/components/Tool/Appeal/AppealDetails/AppealDetailsExcluded.tsx b/src/components/Tool/Appeal/AppealDetails/AppealDetailsExcluded.tsx index 90d47ee01..e76104f95 100644 --- a/src/components/Tool/Appeal/AppealDetails/AppealDetailsExcluded.tsx +++ b/src/components/Tool/Appeal/AppealDetails/AppealDetailsExcluded.tsx @@ -3,9 +3,9 @@ import { mdiAccountPlus } from '@mdi/js'; import Icon from '@mdi/react'; import { Box, IconButton } from '@mui/material'; import { DataGrid } from '@mui/x-data-grid'; -import i18n from 'i18next'; import { makeStyles } from 'tss-react/mui'; import { TestAppeal } from 'pages/accountLists/[accountListId]/tools/appeals/testAppeal'; +import i18n from 'src/lib/i18n'; import theme from '../../../../theme'; import AppealDetailsNoData from './AppealDetailsNoData'; diff --git a/src/components/Tool/Appeal/AppealDetails/AppealDetailsGiven.tsx b/src/components/Tool/Appeal/AppealDetails/AppealDetailsGiven.tsx index d8b05112e..15207cb5e 100644 --- a/src/components/Tool/Appeal/AppealDetails/AppealDetailsGiven.tsx +++ b/src/components/Tool/Appeal/AppealDetails/AppealDetailsGiven.tsx @@ -3,9 +3,9 @@ import { mdiDelete, mdiSquareEditOutline } from '@mdi/js'; import Icon from '@mdi/react'; import { Box, IconButton } from '@mui/material'; import { DataGrid, GridSelectionModel } from '@mui/x-data-grid'; -import i18n from 'i18next'; import { makeStyles } from 'tss-react/mui'; import { TestAppeal } from 'pages/accountLists/[accountListId]/tools/appeals/testAppeal'; +import i18n from 'src/lib/i18n'; import theme from '../../../../theme'; import { useAppealContext } from '../AppealContextProvider/AppealContextProvider'; import AppealDetailsNoData from './AppealDetailsNoData'; diff --git a/src/components/Tool/Appeal/AppealDetails/AppealDetailsReceived.tsx b/src/components/Tool/Appeal/AppealDetails/AppealDetailsReceived.tsx index c411951a1..ef375d962 100644 --- a/src/components/Tool/Appeal/AppealDetails/AppealDetailsReceived.tsx +++ b/src/components/Tool/Appeal/AppealDetails/AppealDetailsReceived.tsx @@ -3,9 +3,9 @@ import { mdiDelete, mdiSquareEditOutline } from '@mdi/js'; import Icon from '@mdi/react'; import { Box, IconButton } from '@mui/material'; import { DataGrid, GridSelectionModel } from '@mui/x-data-grid'; -import i18n from 'i18next'; import { makeStyles } from 'tss-react/mui'; import { TestAppeal } from 'pages/accountLists/[accountListId]/tools/appeals/testAppeal'; +import i18n from 'src/lib/i18n'; import theme from '../../../../theme'; import { useAppealContext } from '../AppealContextProvider/AppealContextProvider'; import AppealDetailsNoData from './AppealDetailsNoData'; diff --git a/src/components/Tool/FixCommitmentInfo/InputOptions/Frequencies.ts b/src/components/Tool/FixCommitmentInfo/InputOptions/Frequencies.ts index c6851514b..06e8cd66a 100644 --- a/src/components/Tool/FixCommitmentInfo/InputOptions/Frequencies.ts +++ b/src/components/Tool/FixCommitmentInfo/InputOptions/Frequencies.ts @@ -1,4 +1,4 @@ -import i18n from 'i18next'; +import i18n from 'src/lib/i18n'; export const frequencies: { [key: string]: string } = { WEEKLY: i18n.t('Weekly'), diff --git a/src/components/Tool/NoData.tsx b/src/components/Tool/NoData.tsx index af462fda8..b2e95f3a9 100644 --- a/src/components/Tool/NoData.tsx +++ b/src/components/Tool/NoData.tsx @@ -10,7 +10,7 @@ import { } from '@mdi/js'; import Icon from '@mdi/react'; import { Typography } from '@mui/material'; -import i18n from 'i18next'; +import i18n from 'src/lib/i18n'; import { NullStateBox } from '../Shared/Filters/NullState/NullStateBox'; interface Props { diff --git a/src/hooks/useGetTimezones.ts b/src/hooks/useGetTimezones.ts index 9881f087c..db2ae4737 100644 --- a/src/hooks/useGetTimezones.ts +++ b/src/hooks/useGetTimezones.ts @@ -1,4 +1,4 @@ -import i18n from 'i18next'; +import i18n from 'src/lib/i18n'; export const useGetTimezones = (): Array> => { const timezones = [ diff --git a/src/utils/contacts/contactPartnershipStatus.ts b/src/utils/contacts/contactPartnershipStatus.ts index c83719a97..9e9daf4b1 100644 --- a/src/utils/contacts/contactPartnershipStatus.ts +++ b/src/utils/contacts/contactPartnershipStatus.ts @@ -1,4 +1,4 @@ -import i18n from 'i18next'; +import i18n from 'src/lib/i18n'; export const contactPartnershipStatus = { NEVER_CONTACTED: i18n.t('Never Contacted'),