Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
inventory-promotion-react
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
inventory-promotion-react
Commits
bd397691
Commit
bd397691
authored
May 10, 2021
by
John Lam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
promotions list, add, delete buttons
parent
9068a7f1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
147 additions
and
2 deletions
+147
-2
Main.jsx
src/component/Main.jsx
+2
-1
PromotionsIndexComponent.jsx
src/component/promo_index/PromotionsIndexComponent.jsx
+87
-0
promolistStyle.css
src/component/promo_index/promolistStyle.css
+53
-0
promoStyle.css
src/component/promotionforms/promoStyle.css
+5
-1
No files found.
src/component/Main.jsx
View file @
bd397691
...
...
@@ -5,6 +5,7 @@ import ProductForm from "./ProductForm";
import
PromotionNewFormComponent
from
'./promotionforms/PromotionNewFormComponent'
import
ProductGrid
from
"./ProductGrid"
;
import
{
getAllProducts
}
from
"../actions/apiRequests.js"
import
PromotionIndexComponent
from
'./promo_index/PromotionsIndexComponent'
;
export
default
function
Main
()
{
...
...
@@ -29,7 +30,7 @@ export default function Main() {
<
AuthRoute
exact
path=
"/products"
>
<
ProductGrid
productData=
{
productData
}
/>
</
AuthRoute
>
<
AuthRoute
path=
"/promos"
>
PROMOS
</
AuthRoute
>
<
AuthRoute
path=
"/promos"
component=
{
PromotionIndexComponent
}
>
PROMOS
</
AuthRoute
>
<
AuthRoute
exact
path=
"/"
>
<
Redirect
to=
"/products"
/>
</
AuthRoute
>
...
...
src/component/promo_index/PromotionsIndexComponent.jsx
0 → 100644
View file @
bd397691
import
{
useState
,
useEffect
}
from
'react'
;
import
Config
from
'../../config'
;
import
"./promolistStyle.css"
;
import
{
NavLink
}
from
'react-router-dom'
;
export
default
function
PromotionIndexComponent
({})
{
const
[
promoData
,
setPromoData
]
=
useState
([]);
useEffect
(
async
()
=>
{
loadPromotions
();
},
[])
const
loadPromotions
=
async
()
=>
{
const
response
=
await
fetch
(
`
${
Config
.
promotionsUrl
}
`
);
const
data
=
await
response
.
json
();
setPromoData
(
data
);
console
.
log
(
data
);
console
.
log
(
promoData
);
}
const
deletePromotion
=
(
promoId
)
=>
{
console
.
log
(
promoId
)
fetch
(
`
${
Config
.
promotionsUrl
}
/
${
promoId
}
`
,
{
method
:
"DELETE"
,
})
.
then
(
res
=>
console
.
log
(
"item deleted"
))
.
catch
(
err
=>
console
.
log
(
"error"
))
}
return
(
<
div
>
<
div
className=
"promo-container"
>
<
div
className=
"promo-list-container"
>
<
div
className=
"promo-header"
>
<
h1
className=
"promo-title"
>
Promotions
</
h1
>
<
NavLink
className=
"add-navLink"
to=
'/promos/new'
><
button
className=
"btn-primary"
>
+ New Promotion
</
button
></
NavLink
>
</
div
>
<
table
className=
"promo-index-list"
>
<
thead
className=
"promo-table-title"
>
<
tr
>
<
th
>
Promotion Id
</
th
>
<
th
>
Product SKU
</
th
>
<
th
>
Discount
</
th
>
<
th
>
Minimum Quanitity
</
th
>
<
th
>
</
th
>
</
tr
>
</
thead
>
<
tbody
>
{
promoData
.
reverse
().
map
((
promo
,
key
)
=>
{
return
(
<
tr
key=
{
key
}
>
<
td
>
{
promo
.
promotionId
}
</
td
>
<
td
>
{
promo
.
productSku
}
</
td
>
<
td
>
{
promo
.
discountPercentage
*
100
}
%
</
td
>
<
td
>
{
promo
.
minimumQuantity
}
</
td
>
<
td
>
<
button
className=
"btn-danger btn-sm"
onClick=
{
()
=>
deletePromotion
(
promo
.
promotionId
)
}
>
Delete
</
button
>
</
td
>
</
tr
>
)
})
}
</
tbody
>
</
table
>
</
div
>
</
div
>
</
div
>
)
}
\ No newline at end of file
src/component/promo_index/promolistStyle.css
0 → 100644
View file @
bd397691
.promo-container
{
margin
:
30px
auto
;
padding
:
0
16px
;
}
.promo-header
{
background-color
:
#212529
;
display
:
flex
;
justify-content
:
space-between
;
padding-left
:
10px
;
padding-right
:
10px
;
}
.promo-title
{
color
:
white
;
padding
:
8px
;
}
.add-navLink
{
align-self
:
center
;
}
table
{
border-collapse
:
collapse
;
width
:
100%
;
}
td
,
th
{
text-align
:
left
;
padding
:
8px
;
}
tr
td
{
height
:
40px
;
}
tr
{
box-sizing
:
border-box
;
}
tr
:nth-child
(
even
)
{
background-color
:
#dddddd
;
}
thead
th
{
background-color
:
#dddddd
;
height
:
35px
;
}
tr
:hover
{
background-color
:
lightblue
;
}
\ No newline at end of file
src/component/promotionforms/promoStyle.css
View file @
bd397691
...
...
@@ -6,7 +6,6 @@
}
.promo-form-title
{
text-align
:
center
;
background-color
:
#212529
;
...
...
@@ -18,6 +17,11 @@
border
:
1px
solid
#212529
;
}
label
{
font-weight
:
bold
;
padding-bottom
:
7px
;
}
.promo-form
{
padding
:
50px
;
...
...
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