mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-19 04:49:37 +02:00
is visited
This commit is contained in:
parent
9d42dbac98
commit
727daf0cfd
10 changed files with 284 additions and 281 deletions
|
@ -253,28 +253,6 @@ export let ADVENTURE_TYPES = [
|
|||
{ type: 'other', label: 'Other' }
|
||||
];
|
||||
|
||||
/**
|
||||
* Checks if an adventure has been visited.
|
||||
*
|
||||
* This function determines if the `adventure.visits` array contains at least one visit
|
||||
* with a `start_date` that is before the current date.
|
||||
*
|
||||
* @param adventure - The adventure object to check.
|
||||
* @returns `true` if the adventure has been visited, otherwise `false`.
|
||||
*/
|
||||
export function isAdventureVisited(adventure: Adventure) {
|
||||
const currentTime = Date.now();
|
||||
|
||||
// Check if any visit's start_date is before the current time.
|
||||
return (
|
||||
adventure.visits &&
|
||||
adventure.visits.some((visit) => {
|
||||
const visitStartTime = new Date(visit.start_date).getTime();
|
||||
return visit.start_date && visitStartTime <= currentTime;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function getRandomBackground() {
|
||||
const randomIndex = Math.floor(Math.random() * randomBackgrounds.backgrounds.length);
|
||||
return randomBackgrounds.backgrounds[randomIndex] as Background;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue