Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ecommerce-maven
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ascend
ecommerce-maven
Commits
2bb2ee0b
Commit
2bb2ee0b
authored
May 09, 2021
by
Shaphen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[AFP-47 Shaphen Pangburn]: Abstract Product item to its own component
parent
5b4f2f7d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
30 deletions
+45
-30
product-item.jsx
ecom-web/src/components/product-market/product-item.jsx
+43
-0
product-market.jsx
ecom-web/src/components/product-market/product-market.jsx
+2
-30
No files found.
ecom-web/src/components/product-market/product-item.jsx
0 → 100644
View file @
2bb2ee0b
import
React
,
{
Component
}
from
'react'
export
default
class
ProductItem
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{}
}
calculateDiscount
(
price
,
discount
)
{
return
(
price
*
(
1.00
-
discount
/
100
)).
toFixed
(
2
);
}
render
()
{
return
(
<
div
className=
"product-item"
>
<
div
id=
"more-details-img-box"
>
<
img
id=
"prod-img"
src=
{
this
.
props
.
item
.
productImageUrl
?
this
.
props
.
item
.
productImageUrl
:
"-no photo-"
}
/>
<
p
id=
"more-details-text"
>
More Details
</
p
>
</
div
>
<
p
id=
"prod-name"
>
{
this
.
props
.
item
.
productName
}
</
p
>
<
div
id=
"prod-price"
>
{
this
.
props
.
item
.
promo
?
<
div
id=
"promo-show"
>
<
p
id=
"promo-show-text-original"
>
$
{
this
.
props
.
item
.
price
}
</
p
>
<
p
id=
"promo-show-text"
>
$
{
this
.
calculateDiscount
(
this
.
props
.
item
.
price
,
this
.
props
.
item
.
promo
)
}
</
p
>
</
div
>
:
"$"
+
this
.
props
.
item
.
price
}
</
div
>
{
this
.
props
.
item
.
promo
?
<
p
id=
"prod-promotion"
>
{
"Save "
+
this
.
props
.
item
.
promo
+
"% on this item!"
}
</
p
>
:
""
}
<
div
className=
"add-cart-and-quantity"
>
<
input
id=
"order-quantity"
type=
"number"
placeholder=
"Qty"
/>
<
span
id=
"add-to-cart-button"
>
Add to Cart
</
span
>
</
div
>
</
div
>
)
}
}
ecom-web/src/components/product-market/product-market.jsx
View file @
2bb2ee0b
import
ProductItem
from
'./product-item'
import
'../../resources/stylesheets/product-market.css'
;
import
'../../resources/stylesheets/product-market.css'
;
import
'../../resources/stylesheets/reset.css'
;
import
'../../resources/stylesheets/reset.css'
;
...
@@ -14,10 +15,6 @@ export default class ProductMarket extends Component {
...
@@ -14,10 +15,6 @@ export default class ProductMarket extends Component {
this
.
props
.
getPromotions
();
this
.
props
.
getPromotions
();
}
}
calculateDiscount
(
price
,
discount
)
{
return
(
price
*
(
1.00
-
discount
/
100
)).
toFixed
(
2
);
}
render
()
{
render
()
{
let
products
=
this
.
props
.
products
;
let
products
=
this
.
props
.
products
;
let
promotions
=
this
.
props
.
promotions
;
let
promotions
=
this
.
props
.
promotions
;
...
@@ -38,32 +35,7 @@ export default class ProductMarket extends Component {
...
@@ -38,32 +35,7 @@ export default class ProductMarket extends Component {
return
(
return
(
<
div
className=
"product-item-container"
key=
{
prod
.
sku
}
>
<
div
className=
"product-item-container"
key=
{
prod
.
sku
}
>
{
prod
.
productName
?
{
prod
.
productName
?
<
div
className=
"product-item"
>
<
ProductItem
item=
{
prod
}
/>
<
div
id=
"more-details-img-box"
>
<
img
id=
"prod-img"
src=
{
prod
.
productImageUrl
?
prod
.
productImageUrl
:
"-no photo-"
}
/>
<
p
id=
"more-details-text"
>
More Details
</
p
>
</
div
>
<
p
id=
"prod-name"
>
{
prod
.
productName
}
</
p
>
<
p
id=
"prod-price"
>
{
prod
.
promo
?
<
div
id=
"promo-show"
>
<
p
id=
"promo-show-text-original"
>
$
{
prod
.
price
}
</
p
>
<
p
id=
"promo-show-text"
>
$
{
this
.
calculateDiscount
(
prod
.
price
,
prod
.
promo
)
}
</
p
>
</
div
>
:
"$"
+
prod
.
price
}
</
p
>
{
prod
.
promo
?
<
p
id=
"prod-promotion"
>
{
"Save "
+
prod
.
promo
+
"% on your order!"
}
</
p
>
:
""
}
<
div
className=
"add-cart-and-quantity"
>
<
input
id=
"order-quantity"
type=
"number"
placeholder=
"Qty"
/>
<
span
id=
"add-to-cart-button"
>
Add to Cart
</
span
>
</
div
>
</
div
>
:
:
<
div
className=
"product-item"
>
<
div
className=
"product-item"
>
<
p
id=
"prod-not-available"
>
This Product is No Longer Available
</
p
>
<
p
id=
"prod-not-available"
>
This Product is No Longer Available
</
p
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment