035
This commit is contained in:
parent
8f7a830182
commit
f75e3b841d
67
src/a3.nim
67
src/a3.nim
@ -5,7 +5,7 @@ import
|
|||||||
nimja/parser,
|
nimja/parser,
|
||||||
strutils,
|
strutils,
|
||||||
strformat,
|
strformat,
|
||||||
./a3pkg/[models, mics],
|
./a3pkg/[models, mics, htmx],
|
||||||
./a3c/[products, users, cart, orders]
|
./a3c/[products, users, cart, orders]
|
||||||
|
|
||||||
"/" -> [get, post]:
|
"/" -> [get, post]:
|
||||||
@ -280,12 +280,8 @@ import
|
|||||||
productName = ""
|
productName = ""
|
||||||
quantity = 0
|
quantity = 0
|
||||||
|
|
||||||
# if productName == "" and email == "":
|
|
||||||
# ctx.redirect("/login")
|
|
||||||
|
|
||||||
var
|
var
|
||||||
country = cookies["c_country"]
|
country = cookies["c_country"]
|
||||||
# country = ctx.queryParams["c_country"]
|
|
||||||
firstName = cookies["c_fname"]
|
firstName = cookies["c_fname"]
|
||||||
lastName = cookies["c_lname"]
|
lastName = cookies["c_lname"]
|
||||||
address = cookies["c_address"]
|
address = cookies["c_address"]
|
||||||
@ -295,7 +291,6 @@ import
|
|||||||
phone = cookies["c_phone"]
|
phone = cookies["c_phone"]
|
||||||
password1: string
|
password1: string
|
||||||
|
|
||||||
# echo ctx.queryParams["c_country"]
|
|
||||||
echo cookies
|
echo cookies
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -371,6 +366,18 @@ import
|
|||||||
|
|
||||||
compileTemplateFile(getScriptDir() / "a3a" / "checkout.nimja")
|
compileTemplateFile(getScriptDir() / "a3a" / "checkout.nimja")
|
||||||
|
|
||||||
|
"/lname" -> post:
|
||||||
|
var lname = ctx.urlForm["c_lname"]
|
||||||
|
echo lname
|
||||||
|
var val: Validity
|
||||||
|
if lname == "":
|
||||||
|
val.message = "Last Name is Required"
|
||||||
|
val.class = "text-danger"
|
||||||
|
else:
|
||||||
|
val.message = ""
|
||||||
|
val.class = "text-success"
|
||||||
|
ctx.send sendLastName(lname, val)
|
||||||
|
|
||||||
"/contact" -> get:
|
"/contact" -> get:
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -445,34 +452,34 @@ import
|
|||||||
|
|
||||||
compileTemplateFile(getScriptDir() / "a3a" / "shop-single.nimja")
|
compileTemplateFile(getScriptDir() / "a3a" / "shop-single.nimja")
|
||||||
|
|
||||||
# "/thankyou" -> get:
|
"/thankyou" -> get:
|
||||||
# var
|
var
|
||||||
# email: string
|
email: string
|
||||||
# password: string
|
password: string
|
||||||
# products: seq[Products]
|
products: seq[Products]
|
||||||
|
|
||||||
# try:
|
try:
|
||||||
# email = ctx.cookies["email"]
|
email = ctx.cookies["email"]
|
||||||
# password = ctx.cookies["password"]
|
password = ctx.cookies["password"]
|
||||||
# except:
|
except:
|
||||||
# email = ""
|
email = ""
|
||||||
# password = ""
|
password = ""
|
||||||
|
|
||||||
# if email == "":
|
if email == "":
|
||||||
# ctx.redirect("/login")
|
ctx.redirect("/login")
|
||||||
# else:
|
else:
|
||||||
# products = micsGetProducts(email, password)
|
products = micsGetProducts(email, password)
|
||||||
|
|
||||||
# ctx &= initCookie("c_country", "")
|
ctx &= initCookie("c_country", "")
|
||||||
# ctx &= initCookie("c_fname", "")
|
ctx &= initCookie("c_fname", "")
|
||||||
# ctx &= initCookie("c_lname", "")
|
ctx &= initCookie("c_lname", "")
|
||||||
# ctx &= initCookie("c_address", "")
|
ctx &= initCookie("c_address", "")
|
||||||
# ctx &= initCookie("c_state_country", "")
|
ctx &= initCookie("c_state_country", "")
|
||||||
# ctx &= initCookie("c_postal_zip", "")
|
ctx &= initCookie("c_postal_zip", "")
|
||||||
# ctx &= initCookie("c_email_address", "")
|
ctx &= initCookie("c_email_address", "")
|
||||||
# ctx &= initCookie("c_phone", "")
|
ctx &= initCookie("c_phone", "")
|
||||||
|
|
||||||
# compileTemplateFile(getScriptDir() / "a3a" / "thankyou.nimja")
|
compileTemplateFile(getScriptDir() / "a3a" / "thankyou.nimja")
|
||||||
|
|
||||||
"/login" -> get:
|
"/login" -> get:
|
||||||
var
|
var
|
||||||
|
@ -108,10 +108,16 @@
|
|||||||
<label class="text-danger">{{firstNameError}}</label>
|
<label class="text-danger">{{firstNameError}}</label>
|
||||||
<input type="text" class="form-control" id="c_fname" name="c_fname">
|
<input type="text" class="form-control" id="c_fname" name="c_fname">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div
|
||||||
|
class="col-md-6"
|
||||||
|
hx-target="this"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
>
|
||||||
<label for="c_lname" class="text-black">Last Name <span class="text-danger">*</span></label>
|
<label for="c_lname" class="text-black">Last Name <span class="text-danger">*</span></label>
|
||||||
<label class="text-danger">{{lastNameError}}</label>
|
<input type="text" class="form-control" id="c_lname"
|
||||||
<input type="text" class="form-control" id="c_lname" name="c_lname">
|
hx-post="/lname"
|
||||||
|
name="c_lname"
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
25
src/a3pkg/htmx.nim
Normal file
25
src/a3pkg/htmx.nim
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import
|
||||||
|
strformat
|
||||||
|
|
||||||
|
type
|
||||||
|
Validity* = object
|
||||||
|
message*: string
|
||||||
|
class*: string
|
||||||
|
|
||||||
|
proc sendLastName*(lastName: string, input: Validity): string =
|
||||||
|
|
||||||
|
result = fmt"""
|
||||||
|
<div
|
||||||
|
class="col-md-6"
|
||||||
|
hx-target="this"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
>
|
||||||
|
<label for="c_lname" class="text-black">Last Name <span class="text-danger">*</span></label>
|
||||||
|
<label class="{input.class}">{input.message}</label>
|
||||||
|
<input type="text" class="form-control" id="c_lname"
|
||||||
|
hx-post="lname"
|
||||||
|
name="c_lname"
|
||||||
|
value="{lastName}"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
"""
|
Loading…
Reference in New Issue
Block a user