mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2024-12-28 02:16:07 +00:00
Fix loading of broken basket
This commit is contained in:
parent
503f47fd71
commit
cf385e5875
|
@ -14,7 +14,7 @@ tmp_dir = "tmp"
|
|||
follow_symlink = false
|
||||
full_bin = ""
|
||||
include_dir = ["front", "api", "cmd"]
|
||||
include_ext = ["go", "tpl", "tmpl", "html", "js", "svelte", "scss"]
|
||||
include_ext = ["go", "tpl", "tmpl", "html", "js", "ts", "svelte", "scss"]
|
||||
include_file = []
|
||||
kill_delay = "0s"
|
||||
log = "build-errors.log"
|
||||
|
|
|
@ -4,14 +4,7 @@ import { type CartItem, type Item } from "./types";
|
|||
import { getItemByUUID, postVerifyCart } from "./test-api";
|
||||
|
||||
function getLocal(): Record<string, CartItem> {
|
||||
let localData: Record<string, CartItem> = {};
|
||||
|
||||
try {
|
||||
localData = JSON.parse(localStorage.getItem("basket"));
|
||||
} catch (error) {
|
||||
console.error("Could parse basket JSON:", error);
|
||||
return localData;
|
||||
}
|
||||
let localData: Record<string, CartItem> = JSON.parse(localStorage.getItem("basket")) || {};
|
||||
|
||||
postVerifyCart(localData)
|
||||
.then((data: Record<string, CartItem>) => {
|
||||
|
@ -19,6 +12,7 @@ function getLocal(): Record<string, CartItem> {
|
|||
})
|
||||
.catch((error) => {
|
||||
console.error("Could not load basket:", error);
|
||||
return <Record<string, CartItem>>{};
|
||||
});
|
||||
|
||||
return localData;
|
||||
|
|
Loading…
Reference in a new issue