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 { HeaderView } from './HeaderView'
|
||||||
import { parseCookies } from 'nookies';
|
import { parseCookies } from 'nookies';
|
||||||
|
import { GetServerSideProps } from 'next';
|
||||||
|
import getAPIClient from '../../services/ssrApi';
|
||||||
|
|
||||||
function stringToColor(string: string) {
|
function stringToColor(string: string) {
|
||||||
let hash = 0;
|
let hash = 0;
|
||||||
@ -37,20 +39,21 @@ function stringAvatar(name: string) {
|
|||||||
interface headerInterface {
|
interface headerInterface {
|
||||||
name: string,
|
name: string,
|
||||||
admin?: boolean | undefined
|
admin?: boolean | undefined
|
||||||
|
logo?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Header({ name, admin }: headerInterface) {
|
export default function Header({ name, admin, logo }: headerInterface) {
|
||||||
return (
|
return (
|
||||||
<HeaderView>
|
<HeaderView>
|
||||||
<section>
|
<section>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
{/* {
|
{
|
||||||
!admin?
|
!admin?
|
||||||
<Image src='/assets/png/copel.png' width={170} height={50} />
|
<Image src={logo} width={170} height={50} />
|
||||||
:
|
:
|
||||||
null
|
null
|
||||||
} */}
|
}
|
||||||
<div className='icon' >
|
<div className='icon' >
|
||||||
<p>
|
<p>
|
||||||
olá, {name}
|
olá, {name}
|
||||||
@ -61,3 +64,34 @@ export default function Header({ name, admin }: headerInterface) {
|
|||||||
</HeaderView>
|
</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 FormData from 'form-data'
|
||||||
import { InputUploadView } from '../../../components/inputUploadImg/inputUploadView'
|
import { InputUploadView } from '../../../components/inputUploadImg/inputUploadView'
|
||||||
|
import { FormControl, InputLabel, MenuItem, Select } from '@mui/material'
|
||||||
|
|
||||||
const style = {
|
const style = {
|
||||||
position: 'absolute' as const,
|
position: 'absolute' as const,
|
||||||
@ -66,7 +67,7 @@ export default function clients({ clients, userName }) {
|
|||||||
const handleClose = () => setOpen(false)
|
const handleClose = () => setOpen(false)
|
||||||
|
|
||||||
const [openModal, setOpenModal] = useState(false)
|
const [openModal, setOpenModal] = useState(false)
|
||||||
|
const [nivelAcess, setnivelAcess] = useState<any>(0);
|
||||||
const [openSnackSuccess, setOpenSnackSuccess] = useState<boolean>(false)
|
const [openSnackSuccess, setOpenSnackSuccess] = useState<boolean>(false)
|
||||||
const [openSnackError, setOpenSnackError] = useState<boolean>(false)
|
const [openSnackError, setOpenSnackError] = useState<boolean>(false)
|
||||||
const [openSnackSuccessDelete, setOpenSnackSuccessDelete] =
|
const [openSnackSuccessDelete, setOpenSnackSuccessDelete] =
|
||||||
@ -115,7 +116,7 @@ export default function clients({ clients, userName }) {
|
|||||||
formData.append('password_confirmation', password_confirmation)
|
formData.append('password_confirmation', password_confirmation)
|
||||||
formData.append('client_id', client_id)
|
formData.append('client_id', client_id)
|
||||||
formData.append('profile_picture', logo)
|
formData.append('profile_picture', logo)
|
||||||
|
formData.append('role', 0)
|
||||||
api
|
api
|
||||||
.post('/user', formData)
|
.post('/user', formData)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -127,6 +128,7 @@ export default function clients({ clients, userName }) {
|
|||||||
setOpenSnackError(true)
|
setOpenSnackError(true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDeleteClient(id: any) {
|
async function handleDeleteClient(id: any) {
|
||||||
await id.map((client) => {
|
await id.map((client) => {
|
||||||
api
|
api
|
||||||
@ -341,8 +343,27 @@ export default function clients({ clients, userName }) {
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</InputUploadView>
|
</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)} />
|
<FaqButton1 title="Cancelar" onClick={() => setOpen(false)} />
|
||||||
<FaqButton2
|
<FaqButton2
|
||||||
title="Salvar"
|
title="Salvar"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user