allow saving and loading carts

This commit is contained in:
dylan
2023-05-06 15:12:42 -07:00
parent 13b600eb95
commit 86d8a8b166
3 changed files with 10 additions and 3 deletions

10
cart.ts
View File

@ -1,10 +1,14 @@
import fakeCart from "./cart_unpacked.json" assert { type: "json" };
import { Sheet } from "./sheet.ts";
const cart = fakeCart as Array<Sheet>;
let cart = fakeCart as Array<Sheet>;
export const loadCart = (_name: string) => {
return;
export const saveCart = async (fname: string) => {
await Deno.writeTextFile("./carts/"+fname+".fx", JSON.stringify(getCart()));
}
export const loadCart = async (fname: string) => {
cart = JSON.parse(await Deno.readTextFile("./carts/"+fname+".fx"));
}
export const getCart = () => {