mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2024-12-28 18:36:25 +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
|
follow_symlink = false
|
||||||
full_bin = ""
|
full_bin = ""
|
||||||
include_dir = ["front", "api", "cmd"]
|
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 = []
|
include_file = []
|
||||||
kill_delay = "0s"
|
kill_delay = "0s"
|
||||||
log = "build-errors.log"
|
log = "build-errors.log"
|
||||||
|
|
|
@ -4,14 +4,7 @@ import { type CartItem, type Item } from "./types";
|
||||||
import { getItemByUUID, postVerifyCart } from "./test-api";
|
import { getItemByUUID, postVerifyCart } from "./test-api";
|
||||||
|
|
||||||
function getLocal(): Record<string, CartItem> {
|
function getLocal(): Record<string, CartItem> {
|
||||||
let localData: Record<string, CartItem> = {};
|
let localData: Record<string, CartItem> = JSON.parse(localStorage.getItem("basket")) || {};
|
||||||
|
|
||||||
try {
|
|
||||||
localData = JSON.parse(localStorage.getItem("basket"));
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Could parse basket JSON:", error);
|
|
||||||
return localData;
|
|
||||||
}
|
|
||||||
|
|
||||||
postVerifyCart(localData)
|
postVerifyCart(localData)
|
||||||
.then((data: Record<string, CartItem>) => {
|
.then((data: Record<string, CartItem>) => {
|
||||||
|
@ -19,6 +12,7 @@ function getLocal(): Record<string, CartItem> {
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Could not load basket:", error);
|
console.error("Could not load basket:", error);
|
||||||
|
return <Record<string, CartItem>>{};
|
||||||
});
|
});
|
||||||
|
|
||||||
return localData;
|
return localData;
|
||||||
|
|
Loading…
Reference in a new issue