update Header
This commit is contained in:
parent
78552b5b85
commit
b731c80830
@ -6,6 +6,8 @@ import TextField from '@mui/material/TextField';
|
||||
|
||||
import { HeaderView } from './HeaderView'
|
||||
import { parseCookies } from 'nookies';
|
||||
import { GetServerSideProps } from 'next';
|
||||
import getAPIClient from '../../services/ssrApi';
|
||||
|
||||
function stringToColor(string: string) {
|
||||
let hash = 0;
|
||||
@ -37,20 +39,21 @@ function stringAvatar(name: string) {
|
||||
interface headerInterface {
|
||||
name: string,
|
||||
admin?: boolean | undefined
|
||||
logo?: string
|
||||
}
|
||||
|
||||
export default function Header({ name, admin }: headerInterface) {
|
||||
export default function Header({ name, admin, logo }: headerInterface) {
|
||||
return (
|
||||
<HeaderView>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
{/* {
|
||||
{
|
||||
!admin?
|
||||
<Image src='/assets/png/copel.png' width={170} height={50} />
|
||||
<Image src={logo} width={170} height={50} />
|
||||
:
|
||||
null
|
||||
} */}
|
||||
}
|
||||
<div className='icon' >
|
||||
<p>
|
||||
olá, {name}
|
||||
@ -61,3 +64,34 @@ export default function Header({ name, admin }: headerInterface) {
|
||||
</HeaderView>
|
||||
)
|
||||
}
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
const apiClient = getAPIClient(ctx)
|
||||
const { ['@smartAuth-token']: token } = parseCookies(ctx)
|
||||
const { ['user-name']: userName } = parseCookies(ctx)
|
||||
|
||||
let userData = [];
|
||||
|
||||
await apiClient.get('/user').then(res => {
|
||||
userData = res.data.data
|
||||
}).catch(res => {
|
||||
// console.log(res)
|
||||
})
|
||||
|
||||
if (!token) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: '/',
|
||||
permanent: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
userData,
|
||||
userName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ import getAPIClient from '../../../services/ssrApi'
|
||||
|
||||
import FormData from 'form-data'
|
||||
import { InputUploadView } from '../../../components/inputUploadImg/inputUploadView'
|
||||
import { FormControl, InputLabel, MenuItem, Select } from '@mui/material'
|
||||
|
||||
const style = {
|
||||
position: 'absolute' as const,
|
||||
@ -66,7 +67,7 @@ export default function clients({ clients, userName }) {
|
||||
const handleClose = () => setOpen(false)
|
||||
|
||||
const [openModal, setOpenModal] = useState(false)
|
||||
|
||||
const [nivelAcess, setnivelAcess] = useState<any>(0);
|
||||
const [openSnackSuccess, setOpenSnackSuccess] = useState<boolean>(false)
|
||||
const [openSnackError, setOpenSnackError] = useState<boolean>(false)
|
||||
const [openSnackSuccessDelete, setOpenSnackSuccessDelete] =
|
||||
@ -115,7 +116,7 @@ export default function clients({ clients, userName }) {
|
||||
formData.append('password_confirmation', password_confirmation)
|
||||
formData.append('client_id', client_id)
|
||||
formData.append('profile_picture', logo)
|
||||
|
||||
formData.append('role', 0)
|
||||
api
|
||||
.post('/user', formData)
|
||||
.then((res) => {
|
||||
@ -127,6 +128,7 @@ export default function clients({ clients, userName }) {
|
||||
setOpenSnackError(true)
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDeleteClient(id: any) {
|
||||
await id.map((client) => {
|
||||
api
|
||||
@ -341,8 +343,27 @@ export default function clients({ clients, userName }) {
|
||||
</form>
|
||||
</div>
|
||||
</InputUploadView>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
|
||||
<div className='select'>
|
||||
|
||||
<FormControl sx={{ width: 350, ml: 5, mt: 2 }}>
|
||||
<InputLabel id="demo-select-small">Nivel de acesso</InputLabel>
|
||||
<Select
|
||||
labelId="demo-select-small"
|
||||
id="demo-select-small"
|
||||
value={nivelAcess}
|
||||
label="Unidade"
|
||||
onChange={value => setnivelAcess(value.target.value)}
|
||||
fullWidth
|
||||
>
|
||||
<MenuItem value={1}>Administrador</MenuItem>
|
||||
<MenuItem value={0}>Cliente</MenuItem>
|
||||
|
||||
</Select>
|
||||
</FormControl>
|
||||
</div>
|
||||
|
||||
<FaqButton1 title="Cancelar" onClick={() => setOpen(false)} />
|
||||
<FaqButton2
|
||||
title="Salvar"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user