Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20 10 2021 stock #19

Open
wants to merge 3 commits into
base: 20-10-2021-filters
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions app/server/components/ProductsCardComponent.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import Product from "../interfaces/Product";

export default function ProductsCardComponent(
{
image,
id,
price,
title
}: Product
): string {
return /* html */ `
export default function ProductsCardComponent({
image,
id,
price,
title,
stock,
}: Product): string {
return /* html */ `
<div class="product-card">
<div class="product-image">
<div style="position:relative;">
Expand All @@ -24,7 +23,12 @@ export default function ProductsCardComponent(
<h5><a href="/product/${id}">${title}</a></h5>
<h6>$${price}</h6>
</div>
<a class="shopButton shopButton-products" data-id="${id}">Comprar</a>
${
stock === 0
? `<a class="stockButton shopButton-products">Out of Stock</a>`
: `<a class="shopButton shopButton-products" data-id="${id}">Comprar</a>`
}

</div>
`;
}
}
1 change: 1 addition & 0 deletions app/server/controllers/product.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = function productGet(req: any, res: any) {
body: "",
price: "",
productSpecs: "",
stock: 0
}
: ProductSpecsComponent(product.caracts);

Expand Down
10 changes: 10 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ footer {
padding: 5px 10px;
}

.stockButton {
display: block;
width: 200px;
padding: 10px;
background-color: black;
text-align: center;
color: white;
cursor: initial;
}


/* @media (min-width: 576px) {
}
Expand Down
6 changes: 5 additions & 1 deletion views/product.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
<div class="container-productSpecs">
<%- productSpecs %>
</div>
<a class="shopButton" data-id="<%= id %>">Comprar</a>
<% if(stock !== 0){ %>
<a class="shopButton" data-id="<%= id %>">Comprar</a>
<% } else{ %>
<a class="stockButton shopButton">Out of Stock</a>
<% } %>
</div>
</div>

Expand Down