shopping list delay fix and category change implemented

This commit is contained in:
vabene1111
2024-11-19 16:32:26 +01:00
parent 3aca96148d
commit 7531c83379
187 changed files with 2098 additions and 36 deletions

View File

@@ -0,0 +1,23 @@
import {ShoppingListEntry} from "@/openapi";
import {IShoppingListFood} from "@/types/Shopping";
/**
* determine if a shopping list entry is delayed
* @param entry
*/
export function isDelayed(entry: ShoppingListEntry){
// this function is needed because the openapi typescript fetch client always replaces null with undefined, so delayUntil cant be
// set back to null once it has been delayed once. This will hopefully be fixed at some point, until then un-delaying will set the date to 1997-1-1 00:00
return entry.delayUntil !== null && entry.delayUntil > Date.now()
}
/**
* determine if any entry in a given IShoppingListFood is delayed, if so return true
*/
export function isShoppingListFoodDelayed(slf: IShoppingListFood){
let hasDelayedEntry = false
slf.entries.forEach(sle => {
hasDelayedEntry = hasDelayedEntry || isDelayed(sle)
})
return hasDelayedEntry
}