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

View File

@ -34,7 +34,9 @@
<li> <li>
<a href="/cart" class="site-cart"> <a href="/cart" class="site-cart">
<span class="icon icon-shopping_cart"></span> <span class="icon icon-shopping_cart"></span>
<span class="count">2</span> {% if products.len > 0 %}
<span class="count">{{products.len}}</span>
{% endif %}
</a> </a>
</li> </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> <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 import
./models, ./models,
../a3c/[cart, products, users] ../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