🐛(frontend) use hook useTranslation

Sentry highlitghted a few errors about the
function "t" not being defined. Better to get
it from the hook useTranslation.
This commit is contained in:
Anthony LC
2024-11-27 11:35:49 +01:00
committed by Anthony LC
parent 79e899c301
commit 6dd1697915
5 changed files with 10 additions and 5 deletions

View File

@@ -10,8 +10,8 @@ import {
VariantType, VariantType,
useToastProvider, useToastProvider,
} from '@openfun/cunningham-react'; } from '@openfun/cunningham-react';
import { t } from 'i18next';
import { useEffect, useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Box, Text } from '@/components'; import { Box, Text } from '@/components';
import { useEditorStore } from '@/features/docs/doc-editor'; import { useEditorStore } from '@/features/docs/doc-editor';
@@ -27,6 +27,7 @@ interface ModalPDFProps {
} }
export const ModalPDF = ({ onClose, doc }: ModalPDFProps) => { export const ModalPDF = ({ onClose, doc }: ModalPDFProps) => {
const { t } = useTranslation();
const { data: templates } = useTemplates({ const { data: templates } = useTemplates({
ordering: TemplatesOrdering.BY_CREATED_ON_DESC, ordering: TemplatesOrdering.BY_CREATED_ON_DESC,
}); });

View File

@@ -6,8 +6,8 @@ import {
VariantType, VariantType,
useToastProvider, useToastProvider,
} from '@openfun/cunningham-react'; } from '@openfun/cunningham-react';
import { t } from 'i18next';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { useTranslation } from 'react-i18next';
import { Box, Text, TextErrors } from '@/components'; import { Box, Text, TextErrors } from '@/components';
import { useCunninghamTheme } from '@/cunningham/'; import { useCunninghamTheme } from '@/cunningham/';
@@ -22,6 +22,7 @@ interface ModalRemoveDocProps {
} }
export const ModalRemoveDoc = ({ onClose, doc }: ModalRemoveDocProps) => { export const ModalRemoveDoc = ({ onClose, doc }: ModalRemoveDocProps) => {
const { t } = useTranslation();
const { colorsTokens } = useCunninghamTheme(); const { colorsTokens } = useCunninghamTheme();
const { toast } = useToastProvider(); const { toast } = useToastProvider();
const { push } = useRouter(); const { push } = useRouter();

View File

@@ -3,7 +3,7 @@ import {
VariantType, VariantType,
useToastProvider, useToastProvider,
} from '@openfun/cunningham-react'; } from '@openfun/cunningham-react';
import { t } from 'i18next'; import { useTranslation } from 'react-i18next';
import { createGlobalStyle } from 'styled-components'; import { createGlobalStyle } from 'styled-components';
import { Box, Card, IconBG, SideModal, Text } from '@/components'; import { Box, Card, IconBG, SideModal, Text } from '@/components';
@@ -44,6 +44,7 @@ interface ModalShareProps {
} }
export const ModalShare = ({ onClose, doc }: ModalShareProps) => { export const ModalShare = ({ onClose, doc }: ModalShareProps) => {
const { t } = useTranslation();
const { isMobile, isSmallMobile } = useResponsiveStore(); const { isMobile, isSmallMobile } = useResponsiveStore();
const width = isSmallMobile ? '100vw' : isMobile ? '90vw' : '70vw'; const width = isSmallMobile ? '100vw' : isMobile ? '90vw' : '70vw';
const { toast } = useToastProvider(); const { toast } = useToastProvider();

View File

@@ -6,8 +6,8 @@ import {
VariantType, VariantType,
useToastProvider, useToastProvider,
} from '@openfun/cunningham-react'; } from '@openfun/cunningham-react';
import { t } from 'i18next';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { useTranslation } from 'react-i18next';
import * as Y from 'yjs'; import * as Y from 'yjs';
import { Box, Text } from '@/components'; import { Box, Text } from '@/components';
@@ -30,6 +30,7 @@ export const ModalVersion = ({
docId, docId,
versionId, versionId,
}: ModalVersionProps) => { }: ModalVersionProps) => {
const { t } = useTranslation();
const { toast } = useToastProvider(); const { toast } = useToastProvider();
const { push } = useRouter(); const { push } = useRouter();
const { providers } = useDocStore(); const { providers } = useDocStore();

View File

@@ -1,6 +1,6 @@
import { Button } from '@openfun/cunningham-react'; import { Button } from '@openfun/cunningham-react';
import { t } from 'i18next';
import React, { PropsWithChildren, useState } from 'react'; import React, { PropsWithChildren, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Box, DropButton, IconOptions, StyledLink, Text } from '@/components'; import { Box, DropButton, IconOptions, StyledLink, Text } from '@/components';
import { useCunninghamTheme } from '@/cunningham'; import { useCunninghamTheme } from '@/cunningham';
@@ -25,6 +25,7 @@ export const VersionItem = ({
link, link,
isActive, isActive,
}: VersionItemProps) => { }: VersionItemProps) => {
const { t } = useTranslation();
const { colorsTokens } = useCunninghamTheme(); const { colorsTokens } = useCunninghamTheme();
const [isDropOpen, setIsDropOpen] = useState(false); const [isDropOpen, setIsDropOpen] = useState(false);
const [isModalVersionOpen, setIsModalVersionOpen] = useState(false); const [isModalVersionOpen, setIsModalVersionOpen] = useState(false);