Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
final-exam
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nawasan Wisitsingkhon
final-exam
Commits
2fcb9a27
Commit
2fcb9a27
authored
Oct 02, 2023
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search product
parent
85145f0b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
stock.js
src/pages/admin/stock.js
+11
-2
No files found.
src/pages/admin/stock.js
View file @
2fcb9a27
...
@@ -20,14 +20,20 @@ import { Delete } from "@mui/icons-material";
...
@@ -20,14 +20,20 @@ import { Delete } from "@mui/icons-material";
import
{
Edit
}
from
"@mui/icons-material"
;
import
{
Edit
}
from
"@mui/icons-material"
;
import
UpdateProduct
from
"@/components/product/UpdateProduct"
;
import
UpdateProduct
from
"@/components/product/UpdateProduct"
;
import
DeleteProduct
from
"@/components/product/DeleteProduct"
;
import
DeleteProduct
from
"@/components/product/DeleteProduct"
;
import
{
useRouter
}
from
"next/router"
;
export
default
function
Stock
()
{
export
default
function
Stock
()
{
const
router
=
useRouter
();
const
[
modal
,
setModal
]
=
useState
(
false
);
const
[
modal
,
setModal
]
=
useState
(
false
);
const
[
products
,
setProducts
]
=
useState
([]);
const
[
products
,
setProducts
]
=
useState
([]);
const
[
updateState
,
setUpdateState
]
=
useState
({
open
:
false
,
data
:
{}
});
const
[
updateState
,
setUpdateState
]
=
useState
({
open
:
false
,
data
:
{}
});
const
[
deleteState
,
setDeleteState
]
=
useState
({
open
:
false
,
id
:
-
1
});
const
[
deleteState
,
setDeleteState
]
=
useState
({
open
:
false
,
id
:
-
1
});
const
[
category
,
setCategory
]
=
useState
([]);
const
[
category
,
setCategory
]
=
useState
([]);
const
productsFilter
=
!!
router
.
query
?.
q
?
products
.
filter
((
prod
)
=>
String
(
prod
.
name
).
includes
(
router
.
query
.
q
))
:
products
;
useEffect
(()
=>
{
useEffect
(()
=>
{
axios
.
get
(
"/api/product"
).
then
((
res
)
=>
{
axios
.
get
(
"/api/product"
).
then
((
res
)
=>
{
setProducts
(
res
.
data
);
setProducts
(
res
.
data
);
...
@@ -51,7 +57,7 @@ export default function Stock() {
...
@@ -51,7 +57,7 @@ export default function Stock() {
เพิ่มสินค้า
เพิ่มสินค้า
<
/Button
>
<
/Button
>
<
/Box
>
<
/Box
>
{
products
.
map
((
product
,
idx
)
=>
(
{
products
Filter
.
map
((
product
,
idx
)
=>
(
<
Card
<
Card
key
=
{
idx
}
key
=
{
idx
}
sx
=
{{
sx
=
{{
...
@@ -101,7 +107,10 @@ export default function Stock() {
...
@@ -101,7 +107,10 @@ export default function Stock() {
>
>
<
Edit
/>
แก้ไข
<
Edit
/>
แก้ไข
<
/Button
>
<
/Button
>
<
Button
color
=
"error"
onClick
=
{()
=>
setDeleteState
({
open
:
true
,
id
:
product
.
id
})}
>
<
Button
color
=
"error"
onClick
=
{()
=>
setDeleteState
({
open
:
true
,
id
:
product
.
id
})}
>
<
Delete
/>
ลบ
<
Delete
/>
ลบ
<
/Button
>
<
/Button
>
<
/CardActions
>
<
/CardActions
>
...
...
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