24th Commit

This commit is contained in:
Aritra Banik 2024-02-09 02:54:36 +05:30
parent c4354da63e
commit 741b61e17f
10 changed files with 47 additions and 30 deletions

Binary file not shown.

BIN
src/a3

Binary file not shown.

View File

@ -26,7 +26,6 @@ import
echo "No cookie found."
else:
products = micsGetProducts(email, password)
echo "Cookie found."
compileTemplateFile(getScriptDir() / "a3a" / "index.nimja")
@ -336,13 +335,11 @@ import
loginError = ""
emailError = ""
passwordError = ""
echo user
if user == true:
ctx &= initCookie("email", email)
ctx &= initCookie("password", password)
echo ctx.cookies
ctx.redirect("/")

View File

@ -30,7 +30,12 @@
<li>
<a href="/cart" class="site-cart">
<span class="icon icon-shopping_cart"></span>
<span class="count">2</span>
{# <span class="count">2</span> #}
{% if email != "" %}
{% if products.len > 0 %}
<span class="count">{{products.len}}</span>
{% endif %}
{% 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>
@ -102,12 +107,12 @@
</div>
</div>
<div class="form-group row">
{# <div class="form-group row">
<div class="col-md-12">
<label for="c_companyname" class="text-black">Company Name </label>
<input type="text" class="form-control" id="c_companyname" name="c_companyname">
</div>
</div>
</div> #}
<div class="form-group row">
<div class="col-md-12">
@ -189,12 +194,12 @@
</div>
</div>
<div class="form-group row">
{# <div class="form-group row">
<div class="col-md-12">
<label for="c_diff_companyname" class="text-black">Company Name </label>
<input type="text" class="form-control" id="c_diff_companyname" name="c_diff_companyname">
</div>
</div>
</div> #}
<div class="form-group row">
<div class="col-md-12">

Binary file not shown.

View File

@ -1,13 +1,14 @@
import
./[products, users, cart, orders]
./orders,
../a3pkg/mics
var
db1 = newDatabase1()
db2 = newDatabase2()
db3 = newDatabase3()
db4 = newDatabase4()
db = newDatabase()
# db2 = newDatabase2()
# db3 = newDatabase3()
# db4 = newDatabase4()
db1.drop()
db2.drop()
db3.drop()
db4.drop()
db.drop()
# db2.drop()
# db3.drop()
# db4.drop()

Binary file not shown.

View File

@ -1,16 +1,17 @@
import
./[products, users, cart, orders]
./[products, users, cart, orders],
../a3pkg/mics
var
db1 = newDatabase1()
db2 = newDatabase2()
db3 = newDatabase3()
db4 = newDatabase4()
db = newDatabase()
# db2 = newDatabase2()
# db3 = newDatabase3()
# db4 = newDatabase4()
db1.setupProducts()
db.setupProducts()
# db1.availableProducts()
db2.setupUsers()
db3.setupCart()
db4.setupOrders()
db.setupUsers()
db.setupCart()
db.setupOrders()
db1.setupProductsIndex()
db.setupProductsIndex()

View File

@ -10,6 +10,11 @@ proc setupOrders*(db: DbConn) =
CREATE TABLE IF NOT EXISTS orders (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE ON UPDATE CASCADE,
country VARCHAR(255) NOT NULL,
address VARCHAR(255) NOT NULL,
state VARCHAR(255) NOT NULL,
postal_code VARCHAR(255) NOT NULL,
phone_number VARCHAR(255) NOT NULL,
product_id INTEGER NOT NULL REFERENCES products(id) ON DELETE CASCADE ON UPDATE CASCADE,
quantity INTEGER NOT NULL,
created_at TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL,
@ -19,10 +24,13 @@ proc setupOrders*(db: DbConn) =
);
""")
# proc createPost*(db: DbConn, order:Orders): int64 =
# var newID = db.insertID(sql"INSERT INTO orders (user_id, product_id, quantity, order_status, order_date) VALUES (?, ?, ?, ?, ?);",
# order.userId, order.productId, order.quantity, order.orderStatus, order.orderDate)
# return newID
proc createPost*(db: DbConn, order:Orders): int64 =
var newID = db.insertID(sql"INSERT INTO orders (user_id, product_id, quantity, order_status, order_date) VALUES (?, ?, ?, ?, ?);",
order.userId, order.productId, order.quantity, order.orderStatus, order.orderDate)
return newID
result = db.insertID(sql"INSERT INTO orders (user_id, country, address, state, postal_code, phone_number, product_id, quantity, order_status, order_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", order.userId, order.country, order.address, order.state, order.postalCode, order.phoneNumber, order.productId, order.quantity, order.orderStatus, order.orderDate)
proc drop*(db: DbConn) =
db.exec(sql"DROP TABLE IF EXISTS orders")

View File

@ -38,6 +38,11 @@ type
## Orders is the orders model
id*: int
userId*: int
country*: string
address*: string
state*: string
postalCode*: string
phoneNumber*: string
productId*: int
quantity*: int
createdAt*: DateTime