mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-19 04:49:37 +02:00
checklists ui
This commit is contained in:
parent
d5f93c5d9d
commit
18ef919a11
6 changed files with 405 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
|||
import inspirationalQuotes from './json/quotes.json';
|
||||
import type { Adventure, Collection, Note, Transportation } from './types';
|
||||
import type { Adventure, Checklist, Collection, Note, Transportation } from './types';
|
||||
|
||||
export function getRandomQuote() {
|
||||
const quotes = inspirationalQuotes.quotes;
|
||||
|
@ -152,3 +152,29 @@ export function groupNotesByDate(
|
|||
|
||||
return groupedNotes;
|
||||
}
|
||||
|
||||
export function groupChecklistsByDate(
|
||||
checklists: Checklist[],
|
||||
startDate: Date,
|
||||
numberOfDays: number
|
||||
): Record<string, Checklist[]> {
|
||||
const groupedChecklists: Record<string, Checklist[]> = {};
|
||||
|
||||
for (let i = 0; i < numberOfDays; i++) {
|
||||
const currentDate = new Date(startDate);
|
||||
currentDate.setDate(startDate.getDate() + i);
|
||||
const dateString = currentDate.toISOString().split('T')[0];
|
||||
groupedChecklists[dateString] = [];
|
||||
}
|
||||
|
||||
checklists.forEach((checklist) => {
|
||||
if (checklist.date) {
|
||||
const noteDate = new Date(checklist.date).toISOString().split('T')[0];
|
||||
if (groupedChecklists[noteDate]) {
|
||||
groupedChecklists[noteDate].push(checklist);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return groupedChecklists;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue