2024-03-03 16:03:22 -05:00
import * as React from 'react' ;
import { useState , useEffect } from 'react' ;
import { useRouter } from 'next/router' ;
import { withPageAuthRequired } from '@auth0/nextjs-auth0/client'
2024-03-17 06:47:37 -04:00
import { Alert , Card , CardContent , Grid , IconButton , TextField , Typography } from '@mui/material' ;
import { ArrowBack , ArrowLeft , Block , Close } from '@mui/icons-material' ;
import Button from '@mui/material/Button' ;
import { OpenInNew } from 'mdi-material-ui' ;
import Tooltip from '@mui/material/Tooltip' ;
2024-03-03 16:03:22 -05:00
const AdminArtist = ( ) = > {
const router = useRouter ( ) ;
2024-03-17 06:47:37 -04:00
const [ artist , setArtist ] = useState ( null ) ;
2024-03-03 16:03:22 -05:00
const getData = async ( ) = > {
if ( router . query . artistId != null ) {
2024-03-17 06:47:37 -04:00
const response = await fetch ( "/api/admin/artists/" + router . query . artistId ) ;
const data = await response . json ( ) ;
setArtist ( data ) ;
2024-03-03 16:03:22 -05:00
}
}
useEffect ( ( ) = > {
getData ( )
} , [ router . query . artistId ] ) ;
2024-03-17 06:47:37 -04:00
return (
< >
< Card >
< CardContent >
< Grid container spacing = { 3 } >
< Grid item xs = { 6 } >
< Typography variant = "h5" > Artist Information < / Typography >
< / Grid >
< Grid item xs = { 6 } sx = { { textAlign : "right" } } >
< Tooltip title = "Ban this artist." >
< IconButton color = "error" >
< Block / >
< / IconButton >
< / Tooltip >
< Tooltip title = "Suspend this artist." >
< IconButton color = "warning" >
< Close / >
< / IconButton >
< / Tooltip >
< Tooltip title = "Go back a page." >
< IconButton onClick = { ( ) = > router . push ( "/dashboard/admin/artists" ) } color = "primary" >
< ArrowBack / >
< / IconButton >
< / Tooltip >
< / Grid >
< Grid item xs = { 12 } md = { 6 } >
< Grid container spacing = { 3 } >
< Grid item xs = { 12 } md = { 5 } >
< Grid container spacing = { 3 } >
< Grid item xs = { 12 } >
Display Name : { artist ? . user ? . displayName }
< / Grid >
< Grid item xs = { 12 } >
Email : { artist ? . user ? . email }
< / Grid >
< Grid item xs = { 12 } >
< Button variant = "contained" color = "primary" fullWidth > Save Changes < / Button >
< / Grid >
< / Grid >
< / Grid >
< Grid item xs = { 12 } md = { 7 } >
< TextField size = "small" label = "Admin Notes" multiline rows = { 4 } fullWidth variant = "outlined" value = { artist ? . userId } / >
< / Grid >
< Grid item xs = { 12 } >
< Alert severity = { artist ? . numberOfBans > 0 ? "error" : "success" } > { artist ? . numberOfBans > 0 ? "This user has been banned " + artist ? . numberOfBans + " times." : "This user has not been banned before." } < / Alert >
< / Grid >
< Grid item xs = { 12 } >
< Alert severity = { artist ? . numberOfSuspensions > 0 ? "error" : "success" } > { artist ? . numberOfBans > 0 ? "This user has been suspended " + artist ? . numberOfSuspensions + " times." : "This user has not been suspended before." } < / Alert >
< / Grid >
< / Grid >
< / Grid >
< Grid item xs = { 12 } md = { 6 } >
< Grid container spacing = { 3 } >
< Grid item xs = { 12 } >
< Alert severity = "success" > This artist has made $ { artist ? . amountMade } , and we have made $ { artist ? . feesCollected } in fees . < / Alert >
< / Grid >
< Grid item xs = { 12 } >
< Alert severity = { artist ? . numberOfRequests > 0 ? "success" : "warning" } > This artist has accepted { artist ? . numberOfRequests } requests . < / Alert >
< / Grid >
< Grid item xs = { 12 } >
< Alert severity = { artist ? . numberOfCompleted > 0 ? "success" : "warning" } > This artist has completed { artist ? . numberOfCompleted } requests . < / Alert >
< / Grid >
< / Grid >
< / Grid >
< / Grid >
< / CardContent >
< / Card >
< / >
2024-03-03 16:03:22 -05:00
) ;
} ;
// Protected route, checking user authentication client-side.(CSR)
2024-03-17 06:47:37 -04:00
export default withPageAuthRequired ( AdminArtist ) ;
2024-03-03 16:03:22 -05:00