Skip to content

Commit

Permalink
feat(daterangepicker): update last N day presets (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrobertson authored Jun 14, 2023
1 parent 119d555 commit 697e8b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-lizards-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@project44-manifest/react': minor
---

add last N days presets
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export const defineds = {
endOfToday: calendarDate,
startOfYesterday: addDays(calendarDate, -1),
endOfYesterday: addDays(calendarDate, -1),
startOfWeek: startOfWeek(calendarDate, 'en-US'),
sevenDaysAgo: addDays(calendarDate, -7),
thirtyDaysAgo: addDays(calendarDate, -30),
endOfWeek: endOfWeek(calendarDate, 'en-US'),
startOfLastWeek: startOfWeek(addDays(calendarDate, -7), 'en-US'),
endOfLastWeek: endOfWeek(addDays(calendarDate, -7), 'en-US'),
Expand Down Expand Up @@ -72,19 +73,19 @@ export const getDefaultRanges = (): DefinedRange[] => [
},
},
{
key: 'thisWeek',
label: 'This Week',
key: 'last7Days',
label: 'Last 7 days',
value: {
start: defineds.startOfWeek,
end: defineds.endOfWeek,
start: defineds.sevenDaysAgo,
end: defineds.endOfToday,
},
},
{
key: 'lastWeek',
label: 'Last Week',
key: 'last30Days',
label: 'Last 30 days',
value: {
start: defineds.startOfLastWeek,
end: defineds.endOfLastWeek,
start: defineds.thirtyDaysAgo,
end: defineds.endOfToday,
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions packages/react/tests/CalendarRange.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ describe('@project44-manifest/react - CalendarRange', () => {
expect(results).toBeDefined();
expect(results).toContainHTML('Today');
expect(results).toContainHTML('Yesterday');
expect(results).toContainHTML('This Week');
expect(results).toContainHTML('Last Week');
expect(results).toContainHTML('Last 7 days');
expect(results).toContainHTML('Last 30 days');
expect(results).toContainHTML('This Month');
expect(results).toContainHTML('Last Month');
});
Expand Down

0 comments on commit 697e8b9

Please sign in to comment.