2nd Commit

This commit is contained in:
Aritra Banik 2024-02-03 21:00:30 +05:30
parent a27f498e2b
commit 9b7208edc8
4 changed files with 22 additions and 2 deletions

BIN
src/a3

Binary file not shown.

View File

@ -3,7 +3,7 @@ import
segfaults,
os,
nimja/parser,
./a3pkg/models,
./a3pkg/[models, mics],
./a3c/[products, users, cart]
"/" -> [get, post]:
@ -11,6 +11,7 @@ import
var
email: string
password: string
products: seq[Products]
try:
email = ctx.cookies["email"]
@ -22,6 +23,7 @@ import
if email == "":
echo "No cookie found."
else:
products = micsGetProducts(email, password)
echo "Cookie found."
compileTemplateFile(getScriptDir() / "a3a" / "index.nimja")

View File

@ -34,7 +34,9 @@
<li>
<a href="/cart" class="site-cart">
<span class="icon icon-shopping_cart"></span>
<span class="count">2</span>
{% if products.len > 0 %}
<span class="count">{{products.len}}</span>
{% endif %}
</a>
</li>
<li class="d-inline-block d-md-none ml-md-0"><a href="#" class="site-menu-toggle js-menu-toggle"><span class="icon-menu"></span></a></li>

View File

@ -1,3 +1,19 @@
import
./models,
../a3c/[cart, products, users]
proc micsGetProducts*(email, password: string): seq[Products]=
var
db1 = newDatabase1()
db2 = newDatabase2()
db3 = newDatabase3()
userId = db2.getUserId(email, password)
cart = db3.getUserCart(userId)
products: seq[Products]
for c, d in cart:
var product = db1.getProductById(d.productId)
products.add(product)
return products