Skip to content

Commit

Permalink
changes suggested in discord
Browse files Browse the repository at this point in the history
  • Loading branch information
lelemm committed Nov 13, 2024
1 parent a2cebb2 commit c887f22
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function CalendarGraph({
{data.map((day, index) =>
!isSameMonth(day.date, startOfMonth(start)) ? (
<View key={`empty-${day.date.getTime()}`} />
) : (
) : day.incomeValue !== 0 || day.expenseValue !== 0 ? (
<Tooltip
key={day.date.getTime()}
content={
Expand Down Expand Up @@ -191,6 +191,14 @@ export function CalendarGraph({
onPress={() => onDayClick(day.date)}
/>
</Tooltip>
) : (
<DayButton
key={day.date.getTime()}
resizeRef={index === 15 ? buttonRef : null}
fontSize={fontSize}
day={day}
onPress={() => onDayClick(day.date)}
/>
),
)}
</View>
Expand Down
36 changes: 12 additions & 24 deletions packages/desktop-client/src/components/reports/reports/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useParams, useSearchParams } from 'react-router-dom';
import { useSpring, animated, config } from 'react-spring';

import { useDrag } from '@use-gesture/react';
import { format, isValid, parseISO } from 'date-fns';
import { format, parseISO } from 'date-fns';

import { SchedulesProvider } from 'loot-core/client/data-hooks/schedules';
import { useTransactions } from 'loot-core/client/data-hooks/transactions';
Expand Down Expand Up @@ -138,26 +138,16 @@ function CalendarInner({ widget, parameters }: CalendarInnerProps) {
});
}

if (
parameters.has('monthStart') &&
parameters.get('monthStart') &&
isValid(new Date(parameters.get('monthStart') || '')) &&
parameters.has('monthEnd') &&
parameters.get('monthEnd') &&
isValid(new Date(parameters.get('monthEnd') || '')) &&
onApplyFilter
) {
if (parameters.has('month') && parameters.get('month') && onApplyFilter) {
onApplyFilter({
conditions: [
{
field: 'date',
op: 'gte',
value: parameters.get('monthStart'),
},
{
field: 'date',
op: 'lte',
value: parameters.get('monthEnd'),
op: 'is',
value: parameters.get('month'),
options: {
month: true,
},
},
] as RuleConditionEntity[],
conditionsOp: 'and',
Expand Down Expand Up @@ -753,13 +743,11 @@ function CalendarWithHeader({
conditions: [
{
field: 'date',
op: 'gte',
value: format(calendar.start, 'yyyy-MM-dd'),
},
{
field: 'date',
op: 'lte',
value: format(calendar.end, 'yyyy-MM-dd'),
op: 'is',
value: format(calendar.start, 'yyyy-MM'),
options: {
month: true,
},
},
],
conditionsOp: 'and',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ function CalendarCardInner({
onPress={() => {
navigate(
isDashboardsFeatureEnabled
? `/reports/calendar/${widgetId}?monthStart=${format(calendar.start, 'yyyy-MM-dd')}&monthEnd=${format(calendar.end, 'yyyy-MM-dd')}`
? `/reports/calendar/${widgetId}?month=${format(calendar.start, 'yyyy-MM')}`
: '/reports/calendar',
);
}}
Expand Down

0 comments on commit c887f22

Please sign in to comment.