🚚(frontend) rename useTransRole to useTrans
We rename useTransRole to useTrans to make it more general and reusable. It will be used for all reusable doc translation.
This commit is contained in:
@@ -1 +1 @@
|
|||||||
export * from './useTransRole';
|
export * from './useTrans';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
|
|
||||||
import { Role } from '../types';
|
import { Role } from '../types';
|
||||||
|
|
||||||
export const useTransRole = () => {
|
export const useTrans = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const translatedRoles = {
|
const translatedRoles = {
|
||||||
@@ -12,9 +12,10 @@ export const useTransRole = () => {
|
|||||||
[Role.EDITOR]: t('Editor'),
|
[Role.EDITOR]: t('Editor'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const transRole = (role: Role) => {
|
return {
|
||||||
return translatedRoles[role];
|
transRole: (role: Role) => {
|
||||||
|
return translatedRoles[role];
|
||||||
|
},
|
||||||
|
untitledDocument: t('Untitled document'),
|
||||||
};
|
};
|
||||||
|
|
||||||
return transRole;
|
|
||||||
};
|
};
|
||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
currentDocRole,
|
currentDocRole,
|
||||||
isDocsOrdering,
|
isDocsOrdering,
|
||||||
useDocs,
|
useDocs,
|
||||||
useTransRole,
|
useTrans,
|
||||||
} from '@/features/docs/doc-management';
|
} from '@/features/docs/doc-management';
|
||||||
import { useDate } from '@/hook/';
|
import { useDate } from '@/hook/';
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ function formatSortModel(sortModel: SortModelItem): DocsOrdering | undefined {
|
|||||||
|
|
||||||
export const DocsGrid = () => {
|
export const DocsGrid = () => {
|
||||||
const { colorsTokens } = useCunninghamTheme();
|
const { colorsTokens } = useCunninghamTheme();
|
||||||
const transRole = useTransRole();
|
const { transRole } = useTrans();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { formatDate } = useDate();
|
const { formatDate } = useDate();
|
||||||
const pagination = usePagination({
|
const pagination = usePagination({
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Select } from '@openfun/cunningham-react';
|
import { Select } from '@openfun/cunningham-react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { Role, useTransRole } from '@/features/docs/doc-management';
|
import { Role, useTrans } from '@/features/docs/doc-management';
|
||||||
|
|
||||||
interface ChooseRoleProps {
|
interface ChooseRoleProps {
|
||||||
currentRole: Role;
|
currentRole: Role;
|
||||||
@@ -19,7 +19,7 @@ export const ChooseRole = ({
|
|||||||
label,
|
label,
|
||||||
}: ChooseRoleProps) => {
|
}: ChooseRoleProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const transRole = useTransRole();
|
const { transRole } = useTrans();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
Reference in New Issue
Block a user