077
This commit is contained in:
parent
927a5a5e96
commit
c24f4c6fe6
BIN
db5.sqlite3
BIN
db5.sqlite3
Binary file not shown.
66
src/a3.nim
66
src/a3.nim
@ -4,9 +4,9 @@ import
|
||||
os,
|
||||
nimja/parser,
|
||||
strutils,
|
||||
./a3pkg/[models, mics, htmx],
|
||||
./a3c/[products, users, cart],
|
||||
./[admin, cart, about, index, checkout, validation]
|
||||
./a3pkg/[models, mics],
|
||||
./a3c/[users],
|
||||
./[admin, cart, about, index, checkout, validation, contact, shop]
|
||||
|
||||
"/" -> [get, post]: ctx.index()
|
||||
|
||||
@ -29,64 +29,10 @@ import
|
||||
"/validation/phone" -> post: ctx.validationPhone()
|
||||
"/validation/country" -> post: ctx.validationCountry()
|
||||
|
||||
"/contact" -> get:
|
||||
"/contact" -> get: ctx.contact()
|
||||
|
||||
var
|
||||
db = newDatabase()
|
||||
|
||||
products: seq[Products]
|
||||
cookies = ctx.cookies
|
||||
|
||||
email = cookies.getOrDefault("email", "")
|
||||
password = cookies.getOrDefault("password", "")
|
||||
|
||||
if email != "" and password != "":
|
||||
var
|
||||
userId = db.getUserId(email, password)
|
||||
cart = db.getUserCart(userId)
|
||||
|
||||
for c, d in cart:
|
||||
var product = db.getProductById(d.productId)
|
||||
products.add(product)
|
||||
|
||||
compileTemplateFile(getScriptDir() / "a3a" / "contact.nimja")
|
||||
|
||||
"/shop" -> get:
|
||||
|
||||
var
|
||||
db = newDatabase()
|
||||
|
||||
availableProducts = db.availableProducts()
|
||||
products: seq[Products]
|
||||
cookies = ctx.cookies
|
||||
|
||||
email = cookies.getOrDefault("email", "")
|
||||
password = cookies.getOrDefault("password", "")
|
||||
|
||||
if email != "" and password != "":
|
||||
products = micsGetProducts(email, password)
|
||||
|
||||
compileTemplateFile(getScriptDir() / "a3a" / "shop.nimja")
|
||||
|
||||
"/shop-single" -> get:
|
||||
|
||||
var
|
||||
db = newDatabase()
|
||||
|
||||
productName = ctx.queryParams["prod"]
|
||||
|
||||
product = db.getProductByName(productName)
|
||||
|
||||
products: seq[Products]
|
||||
cookies = ctx.cookies
|
||||
|
||||
email = cookies.getOrDefault("email", "")
|
||||
password = cookies.getOrDefault("password", "")
|
||||
|
||||
if email != "" and password != "":
|
||||
products = micsGetProducts(email, password)
|
||||
|
||||
compileTemplateFile(getScriptDir() / "a3a" / "shop-single.nimja")
|
||||
"/shop" -> get: ctx.shop()
|
||||
"/shop-single" -> get: ctx.shopSingle()
|
||||
|
||||
"/login" -> get:
|
||||
var
|
||||
|
28
src/contact.nim
Normal file
28
src/contact.nim
Normal file
@ -0,0 +1,28 @@
|
||||
import
|
||||
mike,
|
||||
segfaults,
|
||||
os,
|
||||
nimja/parser,
|
||||
./a3pkg/[models, mics],
|
||||
./a3c/[products, users, cart]
|
||||
|
||||
proc contact*(ctx: Context): string=
|
||||
var
|
||||
db = newDatabase()
|
||||
|
||||
products: seq[Products]
|
||||
cookies = ctx.cookies
|
||||
|
||||
email = cookies.getOrDefault("email", "")
|
||||
password = cookies.getOrDefault("password", "")
|
||||
|
||||
if email != "" and password != "":
|
||||
var
|
||||
userId = db.getUserId(email, password)
|
||||
cart = db.getUserCart(userId)
|
||||
|
||||
for c, d in cart:
|
||||
var product = db.getProductById(d.productId)
|
||||
products.add(product)
|
||||
|
||||
compileTemplateFile(getScriptDir() / "a3a" / "contact.nimja")
|
42
src/shop.nim
Normal file
42
src/shop.nim
Normal file
@ -0,0 +1,42 @@
|
||||
import
|
||||
mike,
|
||||
segfaults,
|
||||
os,
|
||||
nimja/parser,
|
||||
./a3pkg/[models, mics],
|
||||
./a3c/[products]
|
||||
|
||||
proc shop*(ctx: Context): string=
|
||||
var
|
||||
db = newDatabase()
|
||||
|
||||
availableProducts = db.availableProducts()
|
||||
products: seq[Products]
|
||||
cookies = ctx.cookies
|
||||
|
||||
email = cookies.getOrDefault("email", "")
|
||||
password = cookies.getOrDefault("password", "")
|
||||
|
||||
if email != "" and password != "":
|
||||
products = micsGetProducts(email, password)
|
||||
|
||||
compileTemplateFile(getScriptDir() / "a3a" / "shop.nimja")
|
||||
|
||||
proc shopSingle*(ctx: Context): string=
|
||||
var
|
||||
db = newDatabase()
|
||||
|
||||
productName = ctx.queryParams["prod"]
|
||||
|
||||
product = db.getProductByName(productName)
|
||||
|
||||
products: seq[Products]
|
||||
cookies = ctx.cookies
|
||||
|
||||
email = cookies.getOrDefault("email", "")
|
||||
password = cookies.getOrDefault("password", "")
|
||||
|
||||
if email != "" and password != "":
|
||||
products = micsGetProducts(email, password)
|
||||
|
||||
compileTemplateFile(getScriptDir() / "a3a" / "shop-single.nimja")
|
Loading…
Reference in New Issue
Block a user