diff --git a/src/components/ResourceBar.astro b/src/components/ResourceBar.astro index 64421b9..6da3895 100644 --- a/src/components/ResourceBar.astro +++ b/src/components/ResourceBar.astro @@ -1,15 +1,14 @@ --- import { ObjectId } from 'mongodb'; -import { getUserResources } from '../lib/utils/resourceManager'; +import { calculateCurrentAvailableResources, getUserResources } from '../lib/utils/resourceManager'; import { getHighestWeightedLanguage, getLocales } from '../lib/lang/langDriver'; import resourceTypes from '../lib/data/resources.json'; -import format from '../lib/utils/format'; const resourceLang = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'resources'); const resBarLang = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'resourcebar'); -const resources = await getUserResources(new ObjectId(Astro.cookies.get('userid')?.value ?? '')); +const resources = await calculateCurrentAvailableResources(new ObjectId(Astro.cookies.get('userid')?.value ?? '')); const resourceArray = []; for(const key in resources) { @@ -33,7 +32,7 @@ for(const key in resources) {
{resourceLang[`Label_${res.name}`]}
-
{Math.floor(res.amount).toString()}
+
[fetching]
{resBarLang['Label_avaliable']} - {Math.floor(res.amount).toString()}
diff --git a/src/lib/utils/resourceManager.ts b/src/lib/utils/resourceManager.ts index a685e85..3ac8a05 100644 --- a/src/lib/utils/resourceManager.ts +++ b/src/lib/utils/resourceManager.ts @@ -82,7 +82,7 @@ export const updateUserResources = async (id: ObjectId, resources: Array> => { +export const calculateCurrentAvailableResources = async (id: ObjectId): Promise> => { const user = await getUserById(id); if(user === null) return [];