Skip to content

Commit

Permalink
change entity for entityName
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMarcMilletScality committed Mar 1, 2024
1 parent 89f9d9b commit 451e5d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
18 changes: 11 additions & 7 deletions src/lib/components/tablev2/TableUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type TableMessagesType = 'error' | 'loading' | 'noResult';

export const translatedMessages = (
type: TableMessagesType,
entity:
entityName:
| {
en: { singular: string; plural: string };
fr: { singular: string; plural: string };
Expand All @@ -74,25 +74,29 @@ export const translatedMessages = (
if (type === 'error') {
if (locale === 'fr') {
return `Erreur lors du chargement des ${
entity ? entity.fr.plural : 'données'
entityName ? entityName.fr.plural : 'données'
}, veuillez rafraîchir la page.`;
}
return `An error occured while loading ${
entity ? ` the ${entity.en.plural}` : 'data'
entityName ? ` the ${entityName.en.plural}` : 'data'
}, please refresh the
page.`;
}
if (type === 'loading') {
if (locale === 'fr') {
return `Chargement des ${entity ? entity[locale].plural : 'données'}...`;
return `Chargement des ${
entityName ? entityName[locale].plural : 'données'
}...`;
}
return `Loading ${entity ? entity.en.plural : 'data'}...`;
return `Loading ${entityName ? entityName.en.plural : 'data'}...`;
}
if (type === 'noResult') {
if (locale === 'fr') {
return `Aucun ${entity ? entity[locale].singular : 'résultat'} trouvé`;
return `Aucun ${
entityName ? entityName[locale].singular : 'résultat'
} trouvé`;
}
return `No ${entity ? entity.en.plural : 'results'} found`;
return `No ${entityName ? entityName.en.plural : 'results'} found`;
}

return '';
Expand Down
8 changes: 4 additions & 4 deletions src/lib/components/tablev2/Tablev2.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export type TableProps<
onBottomOffset?: number;
allFilters?: { id: string; value: string }[];
status?: 'idle' | 'loading' | 'error' | 'success';
entity?: {
entityName?: {
en: { singular: string; plural: string };
fr: { singular: string; plural: string };
};
Expand Down Expand Up @@ -101,7 +101,7 @@ type TableContextType<
isAllRowsSelected?: boolean;
toggleAllRowsSelected: (value?: boolean) => void;
status?: 'idle' | 'loading' | 'error' | 'success';
entity?: {
entityName?: {
en: { singular: string; plural: string };
fr: { singular: string; plural: string };
};
Expand Down Expand Up @@ -179,7 +179,7 @@ function Table<
initiallySelectedRowsIds,
updateTableData,
status,
entity,
entityName,
}: TableProps<DATA_ROW>) {
sortTypes = {
health: (row1, row2) => {
Expand Down Expand Up @@ -309,7 +309,7 @@ function Table<
isAllRowsSelected,
toggleAllRowsSelected,
status,
entity,
entityName,
};
return (
<TableContext.Provider
Expand Down

0 comments on commit 451e5d3

Please sign in to comment.