- There was a problem loading your date range
+ There was a problem loading your date range
);
}
+ const formattedStartDate = d.format(startDate, 'MMM yyyy');
+ const formattedEndDate = d.format(endDate, 'MMM yyyy');
+ let typeOrFormattedEndDate: string;
+
+ if (type && ['budget', 'average'].includes(type)) {
+ typeOrFormattedEndDate = type === 'budget' ? 'budgeted' : type;
+ } else {
+ typeOrFormattedEndDate = formattedEndDate;
+ }
+
let content: string | ReactElement;
if (['budget', 'average'].includes(type || '')) {
content = (
- Compare {d.format(startDate, 'MMM yyyy')} to{' '}
- {type === 'budget' ? 'budgeted' : 'average'}
-
- );
- } else if (startDate.getFullYear() !== endDate.getFullYear()) {
- content = (
-
- {type && 'Compare '}
- {d.format(startDate, 'MMM yyyy')}
- {type ? ' to ' : ' - '}
- {['budget', 'average'].includes(type || '')
- ? type
- : d.format(endDate, 'MMM yyyy')}
+
+ Compare {{ formattedStartDate }} to {{ typeOrFormattedEndDate }}
+
);
- } else if (startDate.getMonth() !== endDate.getMonth()) {
+ } else if (
+ startDate.getFullYear() !== endDate.getFullYear() ||
+ startDate.getMonth() !== endDate.getMonth()
+ ) {
content = (
- {type && 'Compare '}
- {d.format(startDate, 'MMM yyyy')}
- {type ? ' to ' : ' - '}
- {['budget', 'average'].includes(type || '')
- ? type
- : d.format(endDate, 'MMM yyyy')}
+ {type ? (
+
+ Compare {{ formattedStartDate }} to {{ typeOrFormattedEndDate }}
+
+ ) : (
+
+ {{ formattedStartDate }} - {{ formattedEndDate }}
+
+ )}
);
} else {
diff --git a/packages/desktop-client/src/components/reports/Header.tsx b/packages/desktop-client/src/components/reports/Header.tsx
index ba820128284..06a73d19982 100644
--- a/packages/desktop-client/src/components/reports/Header.tsx
+++ b/packages/desktop-client/src/components/reports/Header.tsx
@@ -1,4 +1,5 @@
import { type ComponentProps, type ReactNode } from 'react';
+import { useTranslation } from 'react-i18next';
import * as monthUtils from 'loot-core/src/shared/months';
import {
@@ -6,7 +7,6 @@ import {
type TimeFrame,
} from 'loot-core/types/models';
-import { useFeatureFlag } from '../../hooks/useFeatureFlag';
import { Button } from '../common/Button2';
import { Select } from '../common/Select';
import { SpaceBetween } from '../common/SpaceBetween';
@@ -60,7 +60,7 @@ export function Header({
onConditionsOpChange,
children,
}: HeaderProps) {
- const isDashboardsFeatureEnabled = useFeatureFlag('dashboards');
+ const { t } = useTranslation();
const { isNarrowWidth } = useResponsive();
return (
@@ -78,7 +78,7 @@ export function Header({
}}
>
- {isDashboardsFeatureEnabled && mode && (
+ {mode && (
)}
@@ -111,7 +111,7 @@ export function Header({
defaultLabel={monthUtils.format(start, 'MMMM, yyyy')}
options={allMonths.map(({ name, pretty }) => [name, pretty])}
/>
- to
+ {t('to')}