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) {
const
[
mobileOpen
,
setMobileOpen
]
=
React
.
useState
(
false
);
React
.
useEffect
(()
=>
{
router
.
push
({
pathname
:
router
.
pathname
,
query
:
{
q
:
search
}})
},
[
search
])
if
(
search
.
length
)
router
.
push
({
pathname
:
router
.
pathname
,
query
:
{
q
:
search
}
});
else
router
.
push
({
pathname
:
router
.
pathname
});
},
[
search
]);
const
handleDrawerToggle
=
()
=>
{
setMobileOpen
(
!
mobileOpen
);
...
...
src/pages/admin/member.js
View file @
d5d6f305
...
...
@@ -4,8 +4,14 @@ import Head from "next/head";
import
axios
from
"axios"
;
import
{
Alert
,
Box
,
Button
,
FormControl
,
FormLabel
,
InputLabel
,
MenuItem
,
Paper
,
Select
,
Snackbar
,
Switch
,
Table
,
...
...
@@ -15,12 +21,27 @@ import {
TableRow
,
}
from
"@mui/material"
;
import
DeleteMember
from
"@/components/member/DeleteMember"
;
import
{
useRouter
}
from
"next/router"
;
export
default
function
Member
()
{
const
user
=
useContext
(
UserContext
);
const
router
=
useRouter
();
const
[
userAll
,
setUserAll
]
=
useState
([]);
const
[
message
,
setMessage
]
=
useState
({
error
:
false
,
message
:
""
});
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
)
{
try
{
...
...
@@ -68,6 +89,19 @@ export default function Member() {
{
message
.
message
}
<
/Alert
>
<
/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
}}
>
<
Table
>
<
TableHead
>
...
...
@@ -89,7 +123,7 @@ export default function Member() {
<
/TableRow
>
<
/TableHead
>
<
TableBody
>
{
userAll
.
map
((
user
,
idx
)
=>
(
{
userAll
Filter
.
map
((
user
,
idx
)
=>
(
<
TableRow
key
=
{
idx
}
>
<
TableCell
>
{
user
.
id
}
<
/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