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
d5d6f305
Commit
d5d6f305
authored
Oct 02, 2023
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search user in admin
parent
19c283bf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
3 deletions
+39
-3
AdminNavbar.js
src/components/AdminNavbar.js
+4
-2
member.js
src/pages/admin/member.js
+35
-1
No files found.
src/components/AdminNavbar.js
View file @
d5d6f305
...
@@ -73,8 +73,10 @@ function AdminNavbar(props) {
...
@@ -73,8 +73,10 @@ function AdminNavbar(props) {
const
[
mobileOpen
,
setMobileOpen
]
=
React
.
useState
(
false
);
const
[
mobileOpen
,
setMobileOpen
]
=
React
.
useState
(
false
);
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
router
.
push
({
pathname
:
router
.
pathname
,
query
:
{
q
:
search
}})
if
(
search
.
length
)
},
[
search
])
router
.
push
({
pathname
:
router
.
pathname
,
query
:
{
q
:
search
}
});
else
router
.
push
({
pathname
:
router
.
pathname
});
},
[
search
]);
const
handleDrawerToggle
=
()
=>
{
const
handleDrawerToggle
=
()
=>
{
setMobileOpen
(
!
mobileOpen
);
setMobileOpen
(
!
mobileOpen
);
...
...
src/pages/admin/member.js
View file @
d5d6f305
...
@@ -4,8 +4,14 @@ import Head from "next/head";
...
@@ -4,8 +4,14 @@ import Head from "next/head";
import
axios
from
"axios"
;
import
axios
from
"axios"
;
import
{
import
{
Alert
,
Alert
,
Box
,
Button
,
Button
,
FormControl
,
FormLabel
,
InputLabel
,
MenuItem
,
Paper
,
Paper
,
Select
,
Snackbar
,
Snackbar
,
Switch
,
Switch
,
Table
,
Table
,
...
@@ -15,12 +21,27 @@ import {
...
@@ -15,12 +21,27 @@ import {
TableRow
,
TableRow
,
}
from
"@mui/material"
;
}
from
"@mui/material"
;
import
DeleteMember
from
"@/components/member/DeleteMember"
;
import
DeleteMember
from
"@/components/member/DeleteMember"
;
import
{
useRouter
}
from
"next/router"
;
export
default
function
Member
()
{
export
default
function
Member
()
{
const
user
=
useContext
(
UserContext
);
const
user
=
useContext
(
UserContext
);
const
router
=
useRouter
();
const
[
userAll
,
setUserAll
]
=
useState
([]);
const
[
userAll
,
setUserAll
]
=
useState
([]);
const
[
message
,
setMessage
]
=
useState
({
error
:
false
,
message
:
""
});
const
[
message
,
setMessage
]
=
useState
({
error
:
false
,
message
:
""
});
const
[
deleteState
,
setDeleteState
]
=
useState
({
open
:
false
,
id
:
-
1
});
const
[
deleteState
,
setDeleteState
]
=
useState
({
open
:
false
,
id
:
-
1
});
const
[
filterAdmin
,
setFilterAdmin
]
=
useState
(
-
1
);
console
.
log
(
userAll
);
const
userAllFilter
=
!!
router
.
query
?.
q
?
userAll
.
filter
(
(
usr
)
=>
(
filterAdmin
===
-
1
||
usr
.
rank
===
!
filterAdmin
)
&&
(
String
(
usr
.
name
).
includes
(
router
.
query
.
q
)
||
String
(
usr
.
username
).
includes
(
router
.
query
.
q
)
||
String
(
usr
.
phone
).
includes
(
router
.
query
.
q
)
||
String
(
usr
.
id
).
includes
(
router
.
query
.
q
))
)
:
userAll
.
filter
((
usr
)
=>
filterAdmin
===
-
1
||
usr
.
rank
===
!
filterAdmin
);
async
function
changeRank
(
id
,
rank
)
{
async
function
changeRank
(
id
,
rank
)
{
try
{
try
{
...
@@ -68,6 +89,19 @@ export default function Member() {
...
@@ -68,6 +89,19 @@ export default function Member() {
{
message
.
message
}
{
message
.
message
}
<
/Alert
>
<
/Alert
>
<
/Snackbar
>
<
/Snackbar
>
<
Box
sx
=
{{
m
:
1
,
textAlign
:
"right"
}}
>
<
FormControl
>
<
Select
variant
=
"standard"
value
=
{
filterAdmin
}
onChange
=
{(
e
)
=>
setFilterAdmin
(
Number
(
e
.
target
.
value
))}
>
<
MenuItem
value
=
{
-
1
}
>
ทั้งหมด
<
/MenuItem
>
<
MenuItem
value
=
{
0
}
>
admin
<
/MenuItem
>
<
MenuItem
value
=
{
1
}
>
ผู้ใช้
<
/MenuItem
>
<
/Select
>
<
/FormControl
>
<
/Box
>
<
Paper
sx
=
{{
p
:
2
}}
>
<
Paper
sx
=
{{
p
:
2
}}
>
<
Table
>
<
Table
>
<
TableHead
>
<
TableHead
>
...
@@ -89,7 +123,7 @@ export default function Member() {
...
@@ -89,7 +123,7 @@ export default function Member() {
<
/TableRow
>
<
/TableRow
>
<
/TableHead
>
<
/TableHead
>
<
TableBody
>
<
TableBody
>
{
userAll
.
map
((
user
,
idx
)
=>
(
{
userAll
Filter
.
map
((
user
,
idx
)
=>
(
<
TableRow
key
=
{
idx
}
>
<
TableRow
key
=
{
idx
}
>
<
TableCell
>
{
user
.
id
}
<
/TableCell
>
<
TableCell
>
{
user
.
id
}
<
/TableCell
>
<
TableCell
>
<
TableCell
>
...
...
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