From b227fc9c2ef361f8aa5ee2f24aa1ade6bc972a73 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 20 Aug 2023 14:32:40 +0200 Subject: area progress --- resources/js/db.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'resources/js/db.js') diff --git a/resources/js/db.js b/resources/js/db.js index e084818..aaf5423 100644 --- a/resources/js/db.js +++ b/resources/js/db.js @@ -69,6 +69,8 @@ const DB = { items: {}, translations: {}, + + areas: {}, }; async function initializeDB () { @@ -152,3 +154,19 @@ async function fetchTranslation (locale) { return DB.translations[locale]; } + +/** + * @param {string} slug + * + * @returns {Promise} + */ +async function fetchArea (slug) { + if (! DB.areas[slug]) { + DB.areas[slug] = await fetch(`/db/_generated/areas/${slug}.json`).then((response) => response.json()); + } + + const area = new Area(slug); + + + return area; +} -- cgit v1.2.3