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
d93bc232
Commit
d93bc232
authored
Oct 02, 2023
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alert when change rank success or failed
parent
587d26bd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
6 deletions
+31
-6
member.js
src/pages/admin/member.js
+31
-6
No files found.
src/pages/admin/member.js
View file @
d93bc232
...
...
@@ -3,8 +3,10 @@ import { UserContext } from "../_app";
import
Head
from
"next/head"
;
import
axios
from
"axios"
;
import
{
Alert
,
Button
,
Paper
,
Snackbar
,
Switch
,
Table
,
TableBody
,
...
...
@@ -17,15 +19,29 @@ import DeleteMember from "@/components/member/DeleteMember";
export
default
function
Member
()
{
const
user
=
useContext
(
UserContext
);
const
[
userAll
,
setUserAll
]
=
useState
([]);
const
[
message
,
setMessage
]
=
useState
({
error
:
false
,
message
:
""
});
const
[
deleteState
,
setDeleteState
]
=
useState
({
open
:
false
,
id
:
-
1
});
async
function
changeRank
(
id
,
rank
)
{
let
response
=
await
axios
.
put
(
"/api/admin/user/rank"
,
{
id
,
rank
},
{
headers
:
{
token
:
user
.
value
.
token
}
}
);
fetchApi
();
try
{
let
response
=
await
axios
.
put
(
"/api/admin/user/rank"
,
{
id
,
rank
},
{
headers
:
{
token
:
user
.
value
.
token
}
}
);
if
(
response
.
data
.
status
===
301
)
{
fetchApi
();
setMessage
({
message
:
"เปลี่ยนสิทธิ์สำเร็จ"
,
error
:
false
});
setTimeout
(()
=>
{
setMessage
({
message
:
""
,
error
:
false
});
},
2000
);
}
}
catch
(
err
)
{
setMessage
({
message
:
"พบข้อผิดพลาด กรุณาลองใหม่อีกครั้ง"
,
error
:
true
});
setTimeout
(()
=>
{
setMessage
({
message
:
""
,
error
:
false
});
},
3000
);
}
}
async
function
fetchApi
()
{
try
{
...
...
@@ -36,6 +52,7 @@ export default function Member() {
}
catch
(
err
)
{}
}
useEffect
(()
=>
{
// console.log();
fetchApi
();
},
[
deleteState
]);
return
(
...
...
@@ -43,6 +60,14 @@ export default function Member() {
<
Head
>
<
title
>
รายชื่อสมาชิก
|
admin
<
/title
>
<
/Head
>
<
Snackbar
anchorOrigin
=
{{
horizontal
:
"center"
,
vertical
:
"top"
}}
open
=
{
!!
message
.
message
.
length
}
>
<
Alert
color
=
{
message
.
error
?
"error"
:
"success"
}
>
{
message
.
message
}
<
/Alert
>
<
/Snackbar
>
<
Paper
sx
=
{{
p
:
2
}}
>
<
Table
>
<
TableHead
>
...
...
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