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
227fb9ee
Commit
227fb9ee
authored
May 10, 2021
by
Khai Yuan Liew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[AFP-15] Start work on Delete product functionality
parent
7803e712
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
apiRequests.js
src/actions/apiRequests.js
+7
-0
Product.jsx
src/component/Product.jsx
+12
-1
No files found.
src/actions/apiRequests.js
View file @
227fb9ee
...
...
@@ -5,4 +5,11 @@ export const getAllProducts = async data => {
const
res
=
await
axios
.
get
(
`
${
Config
.
inventoryUrl
}
`
);
// console.log(res.data);
return
res
.
data
;
}
export
const
deleteProduct
=
async
(
sku
)
=>
{
await
axios
.
delete
(
`
${
Config
.
inventoryUrl
}
/
${
sku
}
`
)
.
then
(()
=>
{
return
await
axios
.
get
(
`
${
Config
.
inventoryUrl
}
`
);
});
}
\ No newline at end of file
src/component/Product.jsx
View file @
227fb9ee
import
React
,
{
useState
}
from
"react"
;
import
"./../styles/Product.css"
;
import
{
Modal
,
Button
,
Alert
}
from
"react-bootstrap"
;
import
{
deleteProduct
}
from
"../actions/apiRequests"
;
export
default
function
Product
({
product
})
{
const
[
show
,
setShow
]
=
useState
(
false
);
...
...
@@ -10,6 +11,16 @@ export default function Product({ product }) {
setShow
(
false
);
handleCloseConfirm
();
};
const
handleDelete
=
(
sku
)
=>
{
deleteProduct
(
sku
)
.
then
(
res
=>
{
const
products
=
res
.
data
;
this
.
setState
({
products
});
});
}
const
handleShow
=
()
=>
setShow
(
true
);
const
handleShowConfirm
=
()
=>
setShowConfirm
(
true
);
const
handleCloseConfirm
=
()
=>
setShowConfirm
(
false
);
...
...
@@ -66,7 +77,7 @@ export default function Product({ product }) {
Cancel
</
Button
>
<
Button
variant=
"danger"
>
Yes, delete
</
Button
>
<
Button
variant=
"danger"
onClick=
{
handleDelete
(
product
.
sku
)
}
>
Yes, delete
</
Button
>
</
Alert
>
</
Modal
.
Footer
>
</
Modal
>
...
...
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