Skip to content

Commit

Permalink
Localize All Tasks tab
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Nov 14, 2024
1 parent 249d00b commit 00c4ac0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { useUserPreference } from 'src/hooks/useUserPreference';
import theme from 'src/theme';
import {
TaskFilterTabsTypes,
taskFiltersTabs,
getTaskFiltersTabs,
} from 'src/utils/tasks/taskFilterTabs';
import {
TaskFiltersQuery,
Expand Down Expand Up @@ -122,6 +122,8 @@ const TasksPage: React.FC = () => {

//#region Filters

const taskFiltersTabs = useMemo(() => getTaskFiltersTabs(t), [t]);

const [taskType, setTaskType] = useState<TaskFilterTabsTypes>(
taskFiltersTabs[0].name,
);
Expand Down Expand Up @@ -311,15 +313,15 @@ const TasksPage: React.FC = () => {
)})`,
}}
>
{taskFiltersTabs.map((i) => (
{taskFiltersTabs.map((tab) => (
<Button
variant={
taskType === i.name ? 'contained' : 'outlined'
taskType === tab.name ? 'contained' : 'outlined'
}
onClick={() => setTaskTypeFilter(i.name)}
key={`btn-${i.name}`}
onClick={() => setTaskTypeFilter(tab.name)}
key={`btn-${tab.name}`}
>
{i.translated ? t(i.uiName) : i.uiName}
{tab.uiName}
</Button>
))}
</TaskCurrentHistoryButtonGroup>
Expand Down
23 changes: 9 additions & 14 deletions src/utils/tasks/taskFilterTabs.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { TFunction } from 'react-i18next';

export type TaskFilterTabsTypes =
| 'All'
| 'Overdue'
Expand All @@ -9,63 +11,56 @@ export type TaskFilterTabsTypes =
interface TaskFilterTabsObject {
name: TaskFilterTabsTypes;
uiName: string;
translated: boolean;
activeFiltersOptions: {
completed: boolean | null;
dateRange: string | null;
};
}

export const taskFiltersTabs: TaskFilterTabsObject[] = [
export const getTaskFiltersTabs = (t: TFunction): TaskFilterTabsObject[] => [
{
name: 'All',
uiName: 'All Tasks',
translated: false,
uiName: t('All Tasks'),
activeFiltersOptions: {
completed: null,
dateRange: null,
},
},
{
name: 'Overdue',
uiName: 'Overdue',
translated: true,
uiName: t('Overdue'),
activeFiltersOptions: {
completed: false,
dateRange: 'overdue',
},
},
{
name: 'Completed',
uiName: 'Completed',
translated: true,
uiName: t('Completed'),
activeFiltersOptions: {
completed: true,
dateRange: null,
},
},
{
name: 'Today',
uiName: 'Today',
translated: true,
uiName: t('Today'),
activeFiltersOptions: {
completed: false,
dateRange: 'today',
},
},
{
name: 'Upcoming',
uiName: 'Upcoming',
translated: true,
uiName: t('Upcoming'),
activeFiltersOptions: {
completed: false,
dateRange: 'upcoming',
},
},
{
name: 'NoDueDate',
uiName: 'No Due Date',
translated: true,
uiName: t('No Due Date'),
activeFiltersOptions: {
completed: false,
dateRange: 'no_date',
Expand Down

0 comments on commit 00c4ac0

Please sign in to comment.