Add basic resource bar
This commit is contained in:
parent
cfc7fef6c4
commit
0d4a187bed
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
import { getHighestWeightedLanguage, getLocales } from '../lib/lang/langDriver';
|
||||||
|
interface Props {
|
||||||
|
loggedIn: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lang = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'resourcebar');
|
||||||
|
|
||||||
|
// const { loggedIn } = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<div id="resourcebar">
|
||||||
|
<div>
|
||||||
|
<!-- <div style="width: 64px; height: 64px; background-color: red; margin: 10px; border-radius: 10px;"></div> -->
|
||||||
|
<div>coal</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
/* #resourcebar {
|
||||||
|
color: pink;
|
||||||
|
background-color: blueviolet;
|
||||||
|
border-radius: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#resourcebar ul {
|
||||||
|
list-style: none;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
padding-left: 15px;
|
||||||
|
} */
|
||||||
|
</style>
|
|
@ -4,6 +4,6 @@
|
||||||
},
|
},
|
||||||
"Link": {
|
"Link": {
|
||||||
"logout": "Log out",
|
"logout": "Log out",
|
||||||
"build": "Build {}"
|
"build": "[build]"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"Label": {
|
||||||
|
"avaliable": "Avaliable: {}",
|
||||||
|
"production": "Production: {}/h",
|
||||||
|
"capacity": "Storage capacity: {}"
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ import Layout from '../../layouts/Layout.astro';
|
||||||
import NavBar from '../../components/NavBar.astro';
|
import NavBar from '../../components/NavBar.astro';
|
||||||
import { getUserResources, updateUserResources } from '../../lib/db/users';
|
import { getUserResources, updateUserResources } from '../../lib/db/users';
|
||||||
import { getHighestWeightedLanguage, getLocales } from '../../lib/lang/langDriver';
|
import { getHighestWeightedLanguage, getLocales } from '../../lib/lang/langDriver';
|
||||||
|
import ResourceBar from '../../components/ResourceBar.astro';
|
||||||
|
|
||||||
const loggedToken = Astro.cookies.get('sessionToken')?.value ?? null;
|
const loggedToken = Astro.cookies.get('sessionToken')?.value ?? null;
|
||||||
const username = Astro.cookies.get('username')?.value ?? "";
|
const username = Astro.cookies.get('username')?.value ?? "";
|
||||||
|
@ -11,17 +12,12 @@ if(loggedToken === null || username === "") return Astro.redirect('/');
|
||||||
|
|
||||||
const resources = await getUserResources(username);
|
const resources = await getUserResources(username);
|
||||||
|
|
||||||
await updateUserResources(username, {
|
|
||||||
coal: resources.coal * 2,
|
|
||||||
iron: resources.iron * 3,
|
|
||||||
gold: resources.gold * 4,
|
|
||||||
});
|
|
||||||
|
|
||||||
const langResources = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'resources');
|
const langResources = await getLocales(getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), 'resources');
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title="chujów sto">
|
<Layout title="chujów sto">
|
||||||
<NavBar loggedIn="true" active="overview" />
|
<NavBar loggedIn="true" active="overview" />
|
||||||
|
<ResourceBar loggedIn="true" />
|
||||||
<ul>
|
<ul>
|
||||||
<li>{langResources['Label_coal']}: <span id="coal">{resources.coal * 2}</span></li>
|
<li>{langResources['Label_coal']}: <span id="coal">{resources.coal * 2}</span></li>
|
||||||
<li>{langResources['Label_iron']}: <span id="iron">{resources.iron * 3}</span></li>
|
<li>{langResources['Label_iron']}: <span id="iron">{resources.iron * 3}</span></li>
|
||||||
|
|
Loading…
Reference in New Issue