Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(task): Display Tasks for curent calendar week and not for seven … #54

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dashboard/HotContacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const HotContacts = () => {
component={Link}
to="/contacts/create"
>
<ControlPointIcon fontSize="inherit" />
<ControlPointIcon fontSize="inherit" color="primary" />
</IconButton>
</Tooltip>
</Box>
Expand Down
28 changes: 19 additions & 9 deletions src/dashboard/TasksList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@ import * as React from 'react';
import { Card, Box, Stack, Typography } from '@mui/material';
import AssignmentTurnedInIcon from '@mui/icons-material/AssignmentTurnedIn';
import { AddTask } from '../tasks/AddTask';
import { startOfToday, endOfToday, addDays } from 'date-fns';
import {
startOfToday,
endOfToday,
endOfTomorrow,
endOfWeek,
getDay,
} from 'date-fns';
import { TasksListFilter } from './TasksListFilter';
import { TasksListEmpty } from './TasksListEmpty';

const today = new Date();
const todayDayOfWeek = getDay(today);
const isBeforeFriday = todayDayOfWeek < 5; // Friday is represented by 5
const startOfTodayDateISO = startOfToday().toISOString();
const endOfTodayDateISO = endOfToday().toISOString();
const startOfWeekDateISO = addDays(today, 1).toISOString();
const endOfWeekDateISO = addDays(today, 7).toISOString();
const endOfTomorrowDateISO = endOfTomorrow().toISOString();
const endOfWeekDateISO = endOfWeek(today, { weekStartsOn: 0 }).toISOString();

const taskFilters = {
overdue: { 'done_date@is': null, 'due_date@lt': startOfTodayDateISO },
Expand All @@ -22,11 +30,11 @@ const taskFilters = {
tomorrow: {
'done_date@is': null,
'due_date@gt': endOfTodayDateISO,
'due_date@lt': startOfWeekDateISO,
'due_date@lt': endOfTomorrowDateISO,
},
thisWeek: {
'done_date@is': null,
'due_date@gte': startOfWeekDateISO,
'due_date@gte': endOfTomorrowDateISO,
'due_date@lte': endOfWeekDateISO,
},
later: { 'done_date@is': null, 'due_date@gt': endOfWeekDateISO },
Expand Down Expand Up @@ -59,10 +67,12 @@ export const TasksList = () => {
title="Tomorrow"
filter={taskFilters.tomorrow}
/>
<TasksListFilter
title="This week"
filter={taskFilters.thisWeek}
/>
{isBeforeFriday && (
<TasksListFilter
title="This week"
filter={taskFilters.thisWeek}
/>
)}
<TasksListFilter title="Later" filter={taskFilters.later} />
</Stack>
</Card>
Expand Down
1 change: 1 addition & 0 deletions src/providers/fakerest/dataGenerator/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const generateTasks = (db: Db) => {
new Date(Date.now() + 100 * 24 * 60 * 60 * 1000)
).toISOString(),
done_date: undefined,
sales_id: 0,
};
});
};
2 changes: 1 addition & 1 deletion src/providers/fakerest/dataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { authProvider, USER_STORAGE_KEY } from './authProvider';
import generateData from './dataGenerator';
import { withSupabaseFilterAdapter } from './internal/supabaseAdapter';

const baseDataProvider = fakeRestDataProvider(generateData(), false, 300);
const baseDataProvider = fakeRestDataProvider(generateData(), true, 300);

const TASK_MARKED_AS_DONE = 'TASK_MARKED_AS_DONE';
const TASK_MARKED_AS_UNDONE = 'TASK_MARKED_AS_UNDONE';
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/AddTask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const AddTask = ({
to={'#'}
onClick={handleOpen}
>
<ControlPointIcon fontSize="inherit" />
<ControlPointIcon fontSize="inherit" color="primary" />
</IconButton>
</Tooltip>
) : (
Expand Down
Loading