3rd Commit

This commit is contained in:
Aritra Banik 2024-02-03 23:15:58 +05:30
parent 9b7208edc8
commit 6a1e0155b1
3 changed files with 97 additions and 3 deletions

BIN
src/a3

Binary file not shown.

View File

@ -29,6 +29,25 @@ import
compileTemplateFile(getScriptDir() / "a3a" / "index.nimja")
"/about" -> get:
var
email: string
password: string
products: seq[Products]
try:
email = ctx.cookies["email"]
password = ctx.cookies["password"]
except:
email = ""
password = ""
if email == "":
echo "No cookie found."
else:
products = micsGetProducts(email, password)
echo "Cookie found."
compileTemplateFile(getScriptDir() / "a3a" / "about.nimja")
"/cart" -> get:
@ -63,16 +82,91 @@ import
compileTemplateFile(getScriptDir() / "a3a" / "cart.nimja")
"/checkout" -> get:
var
email: string
password: string
db2 = newDatabase2()
db3 = newDatabase3()
db1 = newDatabase1()
try:
email = ctx.cookies["email"]
password = ctx.cookies["password"]
except:
email = ""
password = ""
if email == "":
ctx.redirect("/login")
else:
var
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)
compileTemplateFile(getScriptDir() / "a3a" / "checkout.nimja")
"/contact" -> get:
var
email: string
password: string
db2 = newDatabase2()
db3 = newDatabase3()
db1 = newDatabase1()
try:
email = ctx.cookies["email"]
password = ctx.cookies["password"]
except:
email = ""
password = ""
if email != "" and password != "":
var
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)
compileTemplateFile(getScriptDir() / "a3a" / "contact.nimja")
"/shop" -> get:
var
email: string
password: string
db2 = newDatabase2()
db3 = newDatabase3()
db1 = newDatabase1()
products = db1.availableProducts()
availableProducts = db1.availableProducts()
try:
email = ctx.cookies["email"]
password = ctx.cookies["password"]
except:
email = ""
password = ""
if email != "" and password != "":
var
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)
compileTemplateFile(getScriptDir() / "a3a" / "shop.nimja")

View File

@ -99,7 +99,7 @@
</div>
<div class="row mb-5">
{% for (id, product) in products.pairs() %}
{% for (id, product) in db1.availableProducts().pairs() %}
<div class="col-sm-6 col-lg-4 mb-4" data-aos="fade-up">
<div class="block-4 text-center border">
<figure class="block-4-image">
@ -234,4 +234,4 @@
</div>
</div>
{% endblock %}
{% endblock %}