mirror of
https://github.com/FranP-code/Hangman-game-with-React.git
synced 2025-10-13 00:42:32 +00:00
Pannel control styles done
This commit is contained in:
51
src/components/Admin/Control Panel/ControlPanel.jsx
Normal file
51
src/components/Admin/Control Panel/ControlPanel.jsx
Normal file
@@ -0,0 +1,51 @@
|
||||
import React from "react";
|
||||
import { getAuth, onAuthStateChanged } from "firebase/auth";
|
||||
import AdminFunctionButton from "./AdminFunctionButton";
|
||||
import {withRouter} from 'react-router'
|
||||
import Actions from "./Actions/Actions";
|
||||
import AdminHeader from "../Header/AdminHeader";
|
||||
|
||||
const ControlPanel = (props) => {
|
||||
|
||||
const [userLogged, setUserLogged] = React.useState(false)
|
||||
const [actualAction, setActualAction] = React.useState('')
|
||||
|
||||
const auth = getAuth()
|
||||
|
||||
onAuthStateChanged(auth, (user) => {
|
||||
|
||||
if (!user) {
|
||||
|
||||
props.history.push('/identify')
|
||||
|
||||
} else {
|
||||
setUserLogged(true)
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<>
|
||||
<AdminHeader />
|
||||
<div className="control-panel">
|
||||
{
|
||||
userLogged ?
|
||||
<>
|
||||
<AdminFunctionButton action={'Add Word(s)'} setActualAction={setActualAction}/>
|
||||
<AdminFunctionButton action={'Add Category'} setActualAction={setActualAction}/>
|
||||
<AdminFunctionButton action ={'Delete Category'} setActualAction={setActualAction}/>
|
||||
<AdminFunctionButton action ={'Delete Word'} setActualAction={setActualAction}/>
|
||||
<AdminFunctionButton action ={'Edit Word'} setActualAction={setActualAction}/>
|
||||
</>
|
||||
: null
|
||||
}
|
||||
{
|
||||
actualAction ?
|
||||
<Actions actualAction={actualAction}/>
|
||||
: null
|
||||
}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default withRouter(ControlPanel)
|
||||
Reference in New Issue
Block a user