mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-02 04:39:54 -05:00
shopping list delay fix and category change implemented
This commit is contained in:
23
vue3/src/utils/logic_utils.ts
Normal file
23
vue3/src/utils/logic_utils.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user