feat: complete day 13

This commit is contained in:
Ayobami
2025-07-17 21:55:47 +01:00
parent 9c84737fed
commit 7d9350c3df
10 changed files with 271 additions and 40 deletions
+22
View File
@@ -0,0 +1,22 @@
extends layout
block content
.container.mt-5
h2 Add Product
if error
.alert.alert-danger= error
form(method="POST" action="/create-product")
.form-group
label(for="title") Title
input.form-control(type="text" name="title" id="title" required)
.form-group
label(for="description") Description
textarea.form-control(name="description" id="description" required)
.form-group
label(for="price") Price (in dollars)
input.form-control(type="number" name="price" id="price" min="0" step="0.01" required)
.form-group
label(for="image") Image URL
input.form-control(type="text" name="image" id="image")
button.btn.btn-primary(type="submit") Add Product
a.btn.btn-secondary.ml-2(href="/") Cancel
+16 -1
View File
@@ -2,4 +2,19 @@ extends layout
block content
h1= title
p Welcome to #{title}
a.btn.btn-success.mb-4(href="/create-product") Create Product
if products && products.length
.row
each product in products
.col-md-4.mb-4
.card
if product.image
img.card-img-top(src=product.image, alt=product.title, style="width:100px;height:100px;object-fit:contain;")
.card-body
h5.card-title= product.title
p.card-text= product.description
p.card-text
strong $#{product.price}
a.btn.btn-primary(href=`/product/${product.id}`) View Details
else
p No products found.
+1
View File
@@ -2,6 +2,7 @@ doctype html
html
head
title= title
link(rel='stylesheet', href='https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css')
link(rel='stylesheet', href='/stylesheets/style.css')
body
block content
+15
View File
@@ -0,0 +1,15 @@
extends layout
block content
.container.mt-5
.row
.col-md-6
if product.image
img.img-fluid(src=product.image, alt=product.title style="width:100px;height:100px;object-fit:contain;")
.col-md-6
h2= product.title
p= product.description
h4.text-success $#{product.price}
form(action=`/buy/${product.id}` method="POST")
button.btn.btn-success(type="submit") Buy Now
a.btn.btn-secondary.mt-3(href="/") Back to Products
+23
View File
@@ -0,0 +1,23 @@
extends layout
block content
.container.mt-5
.alert.alert-success
h2 Thank you for your purchase!
p Your payment was successful.
if session
h4 Payment Details
table.table
tr
th Session ID
td= session.id
tr
th Payment Status
td= session.payment_status
tr
th Amount Total
td $#{(session.amount_total / 100).toFixed(2)}
tr
th Payment Method
td= session.payment_method_types && session.payment_method_types[0]
a.btn.btn-primary.mt-4(href="/") Back to Products