fix
This commit is contained in:
parent
a8dd640f39
commit
fc460bf343
@ -10,23 +10,23 @@ import TablePagination from '@mui/material/TablePagination';
|
||||
import TableRow from '@mui/material/TableRow';
|
||||
import TableSortLabel from '@mui/material/TableSortLabel';
|
||||
import { visuallyHidden } from '@mui/utils';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
import Image from 'next/image'
|
||||
import Image from 'next/image';
|
||||
|
||||
import Snackbar from '@mui/material/Snackbar';
|
||||
import MuiAlert, { AlertProps } from '@mui/material/Alert';
|
||||
import Snackbar from '@mui/material/Snackbar';
|
||||
|
||||
import Modal from '@mui/material/Modal';
|
||||
|
||||
import FormData from 'form-data'
|
||||
import { InputUploadView } from '../inputUploadImg/inputUploadView'
|
||||
import { FormControl, InputLabel, MenuItem, Select, TextField, Typography } from '@mui/material'
|
||||
import { FormControl, InputLabel, MenuItem, Select, TextField, Typography } from '@mui/material';
|
||||
import FormData from 'form-data';
|
||||
import { InputUploadView } from '../inputUploadImg/inputUploadView';
|
||||
|
||||
import { TableView, StyledStatus } from './TableView';
|
||||
import { api } from '../../services/api';
|
||||
import FaqButton1 from '../buttons/faqButton/FaqButton1';
|
||||
import FaqButton2 from '../buttons/faqButton/FaqButton2';
|
||||
import { StyledStatus, TableView } from './TableView';
|
||||
|
||||
const style = {
|
||||
position: 'absolute' as const,
|
||||
@ -107,19 +107,19 @@ const headCells: readonly HeadCell[] = [
|
||||
},
|
||||
{
|
||||
id: 'name',
|
||||
numeric: true,
|
||||
numeric: false,
|
||||
disablePadding: false,
|
||||
label: 'name',
|
||||
},
|
||||
{
|
||||
id: 'unity',
|
||||
numeric: true,
|
||||
numeric: false,
|
||||
disablePadding: false,
|
||||
label: 'unity',
|
||||
},
|
||||
{
|
||||
id: 'status',
|
||||
numeric: true,
|
||||
numeric: false,
|
||||
disablePadding: false,
|
||||
label: 'status',
|
||||
},
|
||||
@ -187,9 +187,9 @@ interface ClientsTableInterface {
|
||||
onChange: any
|
||||
}
|
||||
|
||||
export default function ClientTable({clients, onChange}: ClientsTableInterface) {
|
||||
export default function ClientTable({ clients, onChange }: ClientsTableInterface) {
|
||||
const [order, setOrder] = useState<Order>('asc');
|
||||
const [orderBy, setOrderBy] = useState<keyof Data | string>('status');
|
||||
const [orderBy, setOrderBy] = useState<keyof Data | string>('asc');
|
||||
const [selected, setSelected] = useState<readonly string[]>([]);
|
||||
const [page, setPage] = useState<number>(0);
|
||||
const [dense, setDense] = useState<boolean>(false);
|
||||
@ -202,13 +202,12 @@ export default function ClientTable({clients, onChange}: ClientsTableInterface)
|
||||
const handleOpen = () => setOpen(true);
|
||||
const handleClose = () => setOpen(false);
|
||||
|
||||
const [cod_client, setCod_client] = useState()
|
||||
const [units, setUnits] = useState([])
|
||||
|
||||
function getClientUnits(client_id: number) {
|
||||
api.post('/units', {
|
||||
"filters": [
|
||||
{"type" : "=", "field": "dados_cadastrais.cod_smart_cliente", "value": client_id}
|
||||
{ "type": "=", "field": "dados_cadastrais.cod_smart_cliente", "value": client_id }
|
||||
],
|
||||
"fields": ["unidade"],
|
||||
"distinct": true
|
||||
@ -283,64 +282,64 @@ export default function ClientTable({clients, onChange}: ClientsTableInterface)
|
||||
const emptyRows =
|
||||
page > 0 ? Math.max(0, (1 + page) * rowsPerPage - clients.length) : 0;
|
||||
|
||||
const formData = new FormData()
|
||||
const formData = new FormData()
|
||||
|
||||
const [clientEdit, setClientEdit] = useState<any>({
|
||||
name: String,
|
||||
email: String,
|
||||
password: String,
|
||||
password_confirmation: String,
|
||||
client_id: Number
|
||||
})
|
||||
const [logo, setLogo] = useState(false)
|
||||
const [imageURLS, setImageURLs] = useState([])
|
||||
const [images, setImages] = useState([] as any)
|
||||
const [nivelAcess, setnivelAcess] = useState<any>(2);
|
||||
const [openEditUserModal, setOpenEditUserModal] = useState<any>(2);
|
||||
const [clientEdit, setClientEdit] = useState<any>({
|
||||
name: String,
|
||||
email: String,
|
||||
password: String,
|
||||
password_confirmation: String,
|
||||
client_id: Number
|
||||
})
|
||||
const [logo, setLogo] = useState(false)
|
||||
const [imageURLS, setImageURLs] = useState([])
|
||||
const [images, setImages] = useState([] as any)
|
||||
const [nivelAcess, setnivelAcess] = useState<any>(2);
|
||||
const [openEditUserModal, setOpenEditUserModal] = useState<any>(false);
|
||||
|
||||
const [selectedClient, setSelectedClient] = useState<any>(2);
|
||||
const [selectedClient, setSelectedClient] = useState<any>(2);
|
||||
|
||||
useEffect(() => {
|
||||
if (images.length < 1) return
|
||||
const newImageUrls: any = []
|
||||
images.forEach((image: any) =>
|
||||
newImageUrls.push(URL.createObjectURL(image))
|
||||
)
|
||||
setImageURLs(newImageUrls)
|
||||
}, [images])
|
||||
useEffect(() => {
|
||||
if (images.length < 1) return
|
||||
const newImageUrls: any = []
|
||||
images.forEach((image: any) =>
|
||||
newImageUrls.push(URL.createObjectURL(image))
|
||||
)
|
||||
setImageURLs(newImageUrls)
|
||||
}, [images])
|
||||
|
||||
function onImageChange(e: any) {
|
||||
setImages([...e.target.files])
|
||||
setLogo(e.target.files[0])
|
||||
}
|
||||
function onImageChange(e: any) {
|
||||
setImages([...e.target.files])
|
||||
setLogo(e.target.files[0])
|
||||
}
|
||||
|
||||
const [openSnackSuccess, setOpenSnackSuccess] = useState<boolean>(false)
|
||||
const [openSnackSuccess, setOpenSnackSuccess] = useState<boolean>(false)
|
||||
|
||||
function handleUpdateClient({
|
||||
name,
|
||||
email,
|
||||
password,
|
||||
password_confirmation,
|
||||
client_id
|
||||
}, id) {
|
||||
formData.append('name', name)
|
||||
formData.append('email', email)
|
||||
formData.append('password', password)
|
||||
formData.append('password_confirmation', password_confirmation)
|
||||
formData.append('client_id', client_id)
|
||||
formData.append('profile_picture', logo)
|
||||
formData.append('role', nivelAcess)
|
||||
function handleUpdateClient({
|
||||
name,
|
||||
email,
|
||||
password,
|
||||
password_confirmation,
|
||||
client_id
|
||||
}, id) {
|
||||
formData.append('name', name)
|
||||
formData.append('email', email)
|
||||
formData.append('password', password)
|
||||
formData.append('password_confirmation', password_confirmation)
|
||||
formData.append('client_id', client_id)
|
||||
formData.append('profile_picture', logo)
|
||||
formData.append('role', nivelAcess)
|
||||
|
||||
api.put(`/user/${id}`, formData)
|
||||
.then((res) => {
|
||||
setOpenSnackSuccess(true)
|
||||
setOpenModalInativar(false)
|
||||
window.location.reload()
|
||||
})
|
||||
.catch((res) => {
|
||||
setOpenSnackError(true)
|
||||
})
|
||||
}
|
||||
api.put(`/user/${id}`, formData)
|
||||
.then((res) => {
|
||||
setOpenSnackSuccess(true)
|
||||
setOpenModalInativar(false)
|
||||
window.location.reload()
|
||||
})
|
||||
.catch((res) => {
|
||||
setOpenSnackError(true)
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<TableView>
|
||||
@ -398,17 +397,17 @@ export default function ClientTable({clients, onChange}: ClientsTableInterface)
|
||||
>
|
||||
Client - {row.client_id}
|
||||
</TableCell>
|
||||
<TableCell align="left" style={{cursor: 'pointer'}} onClick={() => {
|
||||
<TableCell align="left" style={{ cursor: 'pointer' }} onClick={() => {
|
||||
setOpenEditUserModal(true)
|
||||
setSelectedClient(row)
|
||||
setClientEdit(row)
|
||||
}}>{row.name}</TableCell>
|
||||
<TableCell align="left" style={{cursor: 'pointer'}} onClick={() => {
|
||||
<TableCell align="left" style={{ cursor: 'pointer' }} onClick={() => {
|
||||
setOpen(true)
|
||||
getClientUnits(row.client_id)
|
||||
setSelectedClient(row)
|
||||
}}>clique aqui para ver as unidades</TableCell>
|
||||
<TableCell align="left"><StyledStatus status={row.deleted_at? 'inativo' : 'ativo'}> {row.deleted_at? 'inativo' : 'ativo'}</StyledStatus></TableCell>
|
||||
<TableCell align="left"><StyledStatus status={row.deleted_at ? 'inativo' : 'ativo'}> {row.deleted_at ? 'inativo' : 'ativo'}</StyledStatus></TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
@ -435,140 +434,140 @@ export default function ClientTable({clients, onChange}: ClientsTableInterface)
|
||||
/>
|
||||
</Paper>
|
||||
<Modal
|
||||
open={openEditUserModal}
|
||||
onClose={() => setOpenEditUserModal(false)}
|
||||
aria-labelledby="modal-modal-title"
|
||||
aria-describedby="modal-modal-description"
|
||||
open={openEditUserModal}
|
||||
onClose={() => setOpenEditUserModal(false)}
|
||||
aria-labelledby="modal-modal-title"
|
||||
aria-describedby="modal-modal-description"
|
||||
>
|
||||
<Box sx={style}>
|
||||
<h1>Editar Cliente - {selectedClient.name}</h1>
|
||||
<Typography
|
||||
sx={{ color: 'gray', fontSize: 12 }}
|
||||
variant="h5"
|
||||
gutterBottom
|
||||
component="div"
|
||||
>
|
||||
Adicionar Cliente Smart Energia
|
||||
</Typography>
|
||||
<br />
|
||||
<TextField
|
||||
id="outlined-basic"
|
||||
label="Nome"
|
||||
sx={{ width: 350, ml: 5 }}
|
||||
onChange={(value) => {
|
||||
setClientEdit({
|
||||
...clientEdit,
|
||||
name: value.target.value
|
||||
})
|
||||
}}
|
||||
variant="outlined"
|
||||
/>
|
||||
<TextField
|
||||
id="outlined-basic"
|
||||
label="E-mail/Usuário"
|
||||
value={clientEdit.email}
|
||||
sx={{ width: 350, ml: 8 }}
|
||||
onChange={(value) => {
|
||||
setClientEdit({
|
||||
...clientEdit,
|
||||
email: value.target.value.toLowerCase()
|
||||
})
|
||||
}}
|
||||
variant="outlined"
|
||||
/>
|
||||
<TextField
|
||||
id="outlined-basic"
|
||||
label="Senha"
|
||||
sx={{ width: 350, ml: 5, mt: 2 }}
|
||||
onChange={(value) => {
|
||||
setClientEdit({
|
||||
...clientEdit,
|
||||
password: value.target.value
|
||||
})
|
||||
}}
|
||||
variant="outlined"
|
||||
/>
|
||||
<TextField
|
||||
id="outlined-basic"
|
||||
label="Confirma Senha"
|
||||
sx={{ width: 350, ml: 8, mt: 2 }}
|
||||
onChange={(value) => {
|
||||
setClientEdit({
|
||||
...clientEdit,
|
||||
password_confirmation: value.target.value
|
||||
})
|
||||
}}
|
||||
variant="outlined"
|
||||
/>
|
||||
<TextField
|
||||
id="outlined-basic"
|
||||
label="Codigo do Cliente Smart Energia"
|
||||
sx={{ width: 350, ml: 5, mt: 2 }}
|
||||
onChange={(value) => {
|
||||
setClientEdit({
|
||||
...clientEdit,
|
||||
client_id: value.target.value
|
||||
})
|
||||
}}
|
||||
variant="outlined"
|
||||
/>
|
||||
<InputUploadView>
|
||||
<div className="imgContainer">
|
||||
<article>
|
||||
{imageURLS.map((imageSrc, index) => {
|
||||
return <Image
|
||||
src={imageSrc}
|
||||
key={index}
|
||||
width={30}
|
||||
height={30}
|
||||
className="image"
|
||||
/>
|
||||
})}
|
||||
</article>
|
||||
</div>
|
||||
<div className="update">
|
||||
<form action="">
|
||||
<div>
|
||||
<label htmlFor="arquivo">
|
||||
{' '}
|
||||
<p className="TitleButton"> Enviar foto de Perfil </p>{' '}
|
||||
</label>
|
||||
<input
|
||||
type="file"
|
||||
name="arquivo"
|
||||
id="arquivo"
|
||||
onChange={onImageChange}
|
||||
/>
|
||||
<Box sx={style}>
|
||||
<h1>Editar Cliente - {selectedClient.name}</h1>
|
||||
<Typography
|
||||
sx={{ color: 'gray', fontSize: 12 }}
|
||||
variant="h5"
|
||||
gutterBottom
|
||||
component="div"
|
||||
>
|
||||
Adicionar Cliente Smart Energia
|
||||
</Typography>
|
||||
<br />
|
||||
<TextField
|
||||
id="outlined-basic"
|
||||
label="Nome"
|
||||
sx={{ width: 350, ml: 5 }}
|
||||
onChange={(value) => {
|
||||
setClientEdit({
|
||||
...clientEdit,
|
||||
name: value.target.value
|
||||
})
|
||||
}}
|
||||
variant="outlined"
|
||||
/>
|
||||
<TextField
|
||||
id="outlined-basic"
|
||||
label="E-mail/Usuário"
|
||||
value={clientEdit.email}
|
||||
sx={{ width: 350, ml: 8 }}
|
||||
onChange={(value) => {
|
||||
setClientEdit({
|
||||
...clientEdit,
|
||||
email: value.target.value.toLowerCase()
|
||||
})
|
||||
}}
|
||||
variant="outlined"
|
||||
/>
|
||||
<TextField
|
||||
id="outlined-basic"
|
||||
label="Senha"
|
||||
sx={{ width: 350, ml: 5, mt: 2 }}
|
||||
onChange={(value) => {
|
||||
setClientEdit({
|
||||
...clientEdit,
|
||||
password: value.target.value
|
||||
})
|
||||
}}
|
||||
variant="outlined"
|
||||
/>
|
||||
<TextField
|
||||
id="outlined-basic"
|
||||
label="Confirma Senha"
|
||||
sx={{ width: 350, ml: 8, mt: 2 }}
|
||||
onChange={(value) => {
|
||||
setClientEdit({
|
||||
...clientEdit,
|
||||
password_confirmation: value.target.value
|
||||
})
|
||||
}}
|
||||
variant="outlined"
|
||||
/>
|
||||
<TextField
|
||||
id="outlined-basic"
|
||||
label="Codigo do Cliente Smart Energia"
|
||||
sx={{ width: 350, ml: 5, mt: 2 }}
|
||||
onChange={(value) => {
|
||||
setClientEdit({
|
||||
...clientEdit,
|
||||
client_id: value.target.value
|
||||
})
|
||||
}}
|
||||
variant="outlined"
|
||||
/>
|
||||
<InputUploadView>
|
||||
<div className="imgContainer">
|
||||
<article>
|
||||
{imageURLS.map((imageSrc, index) => {
|
||||
return <Image
|
||||
src={imageSrc}
|
||||
key={index}
|
||||
width={30}
|
||||
height={30}
|
||||
className="image"
|
||||
/>
|
||||
})}
|
||||
</article>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</InputUploadView>
|
||||
<div className="update">
|
||||
<form action="">
|
||||
<div>
|
||||
<label htmlFor="arquivo">
|
||||
{' '}
|
||||
<p className="TitleButton"> Enviar foto de Perfil </p>{' '}
|
||||
</label>
|
||||
<input
|
||||
type="file"
|
||||
name="arquivo"
|
||||
id="arquivo"
|
||||
onChange={onImageChange}
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</InputUploadView>
|
||||
|
||||
<div className='select'>
|
||||
<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={2}>Cliente</MenuItem>
|
||||
<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={2}>Cliente</MenuItem>
|
||||
|
||||
</Select>
|
||||
</FormControl>
|
||||
</div>
|
||||
</Select>
|
||||
</FormControl>
|
||||
</div>
|
||||
|
||||
<FaqButton1 title="Cancelar" onClick={() => setOpenEditUserModal(false)} />
|
||||
<FaqButton2
|
||||
title="Salvar"
|
||||
onClick={() => handleUpdateClient(clientEdit, selectedClient.id)}
|
||||
/>
|
||||
</Box>
|
||||
<FaqButton1 title="Cancelar" onClick={() => setOpenEditUserModal(false)} />
|
||||
<FaqButton2
|
||||
title="Salvar"
|
||||
onClick={() => handleUpdateClient(clientEdit, selectedClient.id)}
|
||||
/>
|
||||
</Box>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
@ -576,15 +575,15 @@ export default function ClientTable({clients, onChange}: ClientsTableInterface)
|
||||
onClose={handleClose}
|
||||
aria-labelledby="modal-modal-title"
|
||||
aria-describedby="modal-modal-description"
|
||||
>
|
||||
>
|
||||
<Box sx={style}>
|
||||
{
|
||||
units.map((units, index) => {
|
||||
return <>
|
||||
<li style={{
|
||||
listStyle: 'none'
|
||||
}} key={index}>{units.unidade}</li>
|
||||
<hr />
|
||||
listStyle: 'none'
|
||||
}} key={index}>{units.unidade}</li>
|
||||
<hr />
|
||||
</>
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
import MuiAlert, { AlertProps } from '@mui/material/Alert'
|
||||
import Box from '@mui/material/Box'
|
||||
import Modal from '@mui/material/Modal'
|
||||
import Snackbar from '@mui/material/Snackbar'
|
||||
import TextField from '@mui/material/TextField'
|
||||
import Typography from '@mui/material/Typography'
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import Image from 'next/image'
|
||||
import Snackbar from '@mui/material/Snackbar'
|
||||
import MuiAlert, { AlertProps } from '@mui/material/Alert'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import ClientsTable from '../../../components/administrativeTables/ClientsTable'
|
||||
import BasicButton from '../../../components/buttons/basicButton/BasicButton'
|
||||
import FaqButton1 from '../../../components/buttons/faqButton/FaqButton1'
|
||||
import FaqButton2 from '../../../components/buttons/faqButton/FaqButton2'
|
||||
import Header from '../../../components/header/Header'
|
||||
|
||||
import { ClientsView } from '../../../styles/layouts/clients/ClientsView'
|
||||
import PageTitle from '../../../components/pageTitle/PageTitle'
|
||||
import ConfirmModal from '../../../components/modal/ConfirmModal'
|
||||
import { ConfirmModalView } from '../../../styles/layouts/modals/confirmModalView'
|
||||
import { api } from '../../../services/api'
|
||||
import { parseCookies } from 'nookies'
|
||||
import { GetServerSideProps } from 'next'
|
||||
import { parseCookies } from 'nookies'
|
||||
import ConfirmModal from '../../../components/modal/ConfirmModal'
|
||||
import PageTitle from '../../../components/pageTitle/PageTitle'
|
||||
import { api } from '../../../services/api'
|
||||
import getAPIClient from '../../../services/ssrApi'
|
||||
import { ClientsView } from '../../../styles/layouts/clients/ClientsView'
|
||||
import { ConfirmModalView } from '../../../styles/layouts/modals/confirmModalView'
|
||||
|
||||
import { FormControl, InputLabel, MenuItem, Select } from '@mui/material'
|
||||
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,
|
||||
@ -70,6 +70,7 @@ export default function clients({ clients, userName }) {
|
||||
const [nivelAcess, setnivelAcess] = useState<any>(2);
|
||||
const [openSnackSuccess, setOpenSnackSuccess] = useState<boolean>(false)
|
||||
const [openSnackError, setOpenSnackError] = useState<boolean>(false)
|
||||
const [openSnackWarning, setOpenSnackWarning] = useState<boolean>(false)
|
||||
const [openSnackSuccessDelete, setOpenSnackSuccessDelete] =
|
||||
useState<boolean>(false)
|
||||
const [openSnackErrorDelete, setOpenSnackErrorDelete] =
|
||||
@ -114,6 +115,9 @@ export default function clients({ clients, userName }) {
|
||||
formData.append('profile_picture', logo)
|
||||
formData.append('role', nivelAcess)
|
||||
|
||||
if (!name.length || !email.length || !password.length || !password_confirmation.length || !client_id.length || !logo || !nivelAcess.length)
|
||||
setOpenSnackWarning(true)
|
||||
|
||||
api.post('/user', formData)
|
||||
.then((res) => {
|
||||
setOpenSnackSuccess(true)
|
||||
@ -152,12 +156,6 @@ export default function clients({ clients, userName }) {
|
||||
setLogo(e.target.files[0])
|
||||
}
|
||||
|
||||
console.table(clients.map(client => {
|
||||
if (Number.parseInt(client.client_id) === 59641651) return client
|
||||
return
|
||||
}))
|
||||
console.table(clients[417])
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', width: '100%' }}>
|
||||
<Snackbar
|
||||
@ -186,6 +184,19 @@ export default function clients({ clients, userName }) {
|
||||
Cliente não cadastrado!
|
||||
</Alert>
|
||||
</Snackbar>
|
||||
<Snackbar
|
||||
open={openSnackWarning}
|
||||
autoHideDuration={4000}
|
||||
onClose={handleCloseSnack}
|
||||
>
|
||||
<Alert
|
||||
onClose={handleCloseSnack}
|
||||
severity="warning"
|
||||
sx={{ width: '100%' }}
|
||||
>
|
||||
Preencha todos os campos!
|
||||
</Alert>
|
||||
</Snackbar>
|
||||
|
||||
<Snackbar
|
||||
open={openSnackSuccessDelete}
|
||||
@ -348,22 +359,22 @@ export default function clients({ clients, userName }) {
|
||||
|
||||
<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={2}>Cliente</MenuItem>
|
||||
<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={2}>Cliente</MenuItem>
|
||||
|
||||
</Select>
|
||||
</FormControl>
|
||||
</div>
|
||||
</Select>
|
||||
</FormControl>
|
||||
</div>
|
||||
|
||||
<FaqButton1 title="Cancelar" onClick={() => setOpen(false)} />
|
||||
<FaqButton2
|
||||
|
||||
@ -39,10 +39,12 @@ const style = {
|
||||
boxShadow: 24,
|
||||
p: 4,
|
||||
|
||||
borderRadius: 3
|
||||
borderRadius: 3,
|
||||
|
||||
overflow: 'scroll'
|
||||
};
|
||||
|
||||
export default function Dashboard({grossAnualGraph, grossAnualYears, grossMensalGraph, grossMensalYears, acumulatedGraph, mapsInfo, userName, costIndicator} : any) {
|
||||
export default function Dashboard({ grossAnualGraph, grossAnualYears, grossMensalGraph, grossMensalYears, acumulatedGraph, mapsInfo, userName, costIndicator }: any) {
|
||||
const months = [
|
||||
'Jan',
|
||||
'Fev',
|
||||
@ -70,18 +72,18 @@ export default function Dashboard({grossAnualGraph, grossAnualYears, grossMensal
|
||||
useEffect(() => {
|
||||
let lastDataMensal = '0'
|
||||
let lastDataAnual = '0'
|
||||
let index=0
|
||||
let index = 0
|
||||
|
||||
while (index < grossMensalGraph.length) {
|
||||
if (!grossMensalGraph[index].dad_estimado && grossMensalGraph[index].economia_acumulada!==null)
|
||||
lastDataMensal=grossMensalGraph[index].economia_acumulada
|
||||
if (!grossMensalGraph[index].dad_estimado && grossMensalGraph[index].economia_acumulada !== null)
|
||||
lastDataMensal = grossMensalGraph[index].economia_acumulada
|
||||
index++
|
||||
}
|
||||
setLastDataBrutaMensal(`${parseFloat(lastDataMensal).toFixed(3)}`)
|
||||
index=0
|
||||
index = 0
|
||||
while (index < grossAnualGraph.length) {
|
||||
if (!grossAnualGraph[index].dad_estimado)
|
||||
lastDataAnual=grossAnualGraph[index].economia_acumulada
|
||||
lastDataAnual = grossAnualGraph[index].economia_acumulada
|
||||
index++
|
||||
}
|
||||
setLastDataBrutaAnual(`${parseFloat(lastDataAnual).toFixed(3)}`)
|
||||
@ -110,75 +112,113 @@ export default function Dashboard({grossAnualGraph, grossAnualYears, grossMensal
|
||||
</Link>
|
||||
|
||||
{
|
||||
typeof window === 'undefined' || typeof window === undefined? null :
|
||||
<>
|
||||
<section className='dashboard'>
|
||||
<GraphCard title='Economia Anual' subtitle='Economia Bruta Estimada e Acumulada Anual - Valores em R$ x mil'>
|
||||
<AccumulatedEconomyTitle value={lastDataBrutaAnualS}/>
|
||||
<GrossAnualChart title='' subtitle=''
|
||||
dataset='Consolidada'
|
||||
dataProps={grossAnualGraph}
|
||||
label={grossAnualYears} barLabel bruta miniature/>
|
||||
</GraphCard>
|
||||
typeof window === 'undefined' || typeof window === undefined ? null :
|
||||
<>
|
||||
<section className='dashboard'>
|
||||
<GraphCard title='Economia Anual' subtitle='Economia Bruta Estimada e Acumulada Anual - Valores em R$ x mil'>
|
||||
<AccumulatedEconomyTitle value={lastDataBrutaAnualS} />
|
||||
<GrossAnualChart title='' subtitle=''
|
||||
dataset='Consolidada'
|
||||
dataProps={grossAnualGraph}
|
||||
label={grossAnualYears} barLabel bruta miniature />
|
||||
</GraphCard>
|
||||
|
||||
<GraphCard title='Economia Mensal' subtitle='Economia Bruta Estimada e Acumulada Mensal - Valores em R$ x mil'>
|
||||
<AccumulatedEconomyTitle value={lastDataBrutaMensalS}/>
|
||||
<GrossMensalChart title='' subtitle=''
|
||||
data1={grossMensalGraph}
|
||||
data2={grossMensalGraph}
|
||||
label={months}
|
||||
miniature
|
||||
/>
|
||||
</GraphCard>
|
||||
<GraphCard title='Economia Mensal' subtitle='Economia Bruta Estimada e Acumulada Mensal - Valores em R$ x mil'>
|
||||
<AccumulatedEconomyTitle value={lastDataBrutaMensalS} />
|
||||
<GrossMensalChart title='' subtitle=''
|
||||
data1={grossMensalGraph}
|
||||
data2={grossMensalGraph}
|
||||
label={months}
|
||||
miniature
|
||||
/>
|
||||
</GraphCard>
|
||||
|
||||
<GraphCard title='Custo Mensal Cativo x Livre' subtitle='Comparativo de Custo Estimado - Valores em R$ x mil'>
|
||||
<CativoXLivreChart chartData={acumulatedGraph}
|
||||
dataset1="Economia (R$)" dataset2='Est. Cativo' dataset3='Est. Livre'
|
||||
label={['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez']} title='' subtitle='' barLabel hashurado miniature/>
|
||||
</GraphCard>
|
||||
<GraphCard title='Custo Mensal Cativo x Livre' subtitle='Comparativo de Custo Estimado - Valores em R$ x mil'>
|
||||
<CativoXLivreChart chartData={acumulatedGraph}
|
||||
dataset1="Economia (R$)" dataset2='Est. Cativo' dataset3='Est. Livre'
|
||||
label={['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez']} title='' subtitle='' barLabel hashurado miniature />
|
||||
</GraphCard>
|
||||
|
||||
<GraphCard title='Indicador de Custo' subtitle='Indicador de Custo - Valores em R$/MWh'>
|
||||
<CostIndicatorChart title='' subtitle=''
|
||||
data1={costIndicator?.filter((value, index) => value?.mes.slice(0, 4).includes('2021')).map(value => value?.custo_unit && !!parseInt(value?.custo_unit)? value.custo_unit : null)}
|
||||
data2={costIndicator?.filter((value, index) => value?.mes.slice(0, 4).includes('2022')).map(value => value?.custo_unit && !!parseInt(value?.custo_unit)? value.custo_unit : null)}
|
||||
label={months}
|
||||
miniature
|
||||
/>
|
||||
</GraphCard>
|
||||
</section>
|
||||
<Modal
|
||||
open={terms=='false'}
|
||||
aria-labelledby="modal-modal-title"
|
||||
aria-describedby="modal-modal-description"
|
||||
>
|
||||
<Box sx={style}>
|
||||
<Typography id="modal-modal-title" variant="h6" component="h2">
|
||||
Termos de uso
|
||||
</Typography>
|
||||
<Typography id="modal-modal-description" sx={{ mt: 2 }}>
|
||||
<p>
|
||||
Bem-vindo a Plataforma Web – SMART ENERGIA!
|
||||
</p>
|
||||
<p>
|
||||
Visualize os principais indicadores, dados de economia, resumo de operações, PLD, notícias além de acompanhar o consumo de energia em intervalos mínimos de 5 minutos.
|
||||
</p>
|
||||
<p>
|
||||
Conforme nosso contrato de serviços vigente, todas as informações entregues são estritamente privadas, sendo seu sigilo protegido por lei, não podendo ser compartilhadas com terceiros.
|
||||
</p>
|
||||
<p>
|
||||
A divulgação não autorizada das informações adquiridas nesta plataforma (ou seu uso), de forma integral ou parcial, é proibida, não sendo permitido o compartilhamento dos acessos e senhas ou qualquer informação que tiver acesso junto a esta plataforma, sendo que o acesso a esta plataforma é restrito e individual.
|
||||
</p>
|
||||
<p>
|
||||
Ressaltamos que os resultados informados são meramente indicativos.
|
||||
</p>
|
||||
<BasicButton title="Aceito os termos" onClick={() => {
|
||||
setCookie(undefined, 'terms', 'true')
|
||||
setOpen(false)
|
||||
}} />
|
||||
</Typography>
|
||||
</Box>
|
||||
</Modal>
|
||||
</>
|
||||
<GraphCard title='Indicador de Custo' subtitle='Indicador de Custo - Valores em R$/MWh'>
|
||||
<CostIndicatorChart title='' subtitle=''
|
||||
data1={costIndicator?.filter((value, index) => value?.mes.slice(0, 4).includes('2021')).map(value => value?.custo_unit && !!parseInt(value?.custo_unit) ? value.custo_unit : null)}
|
||||
data2={costIndicator?.filter((value, index) => value?.mes.slice(0, 4).includes('2022')).map(value => value?.custo_unit && !!parseInt(value?.custo_unit) ? value.custo_unit : null)}
|
||||
label={months}
|
||||
miniature
|
||||
/>
|
||||
</GraphCard>
|
||||
</section>
|
||||
<Modal
|
||||
open={terms == 'false'}
|
||||
aria-labelledby="modal-modal-title"
|
||||
aria-describedby="modal-modal-description"
|
||||
>
|
||||
<Box sx={style}>
|
||||
<Typography id="modal-modal-title" variant="h6" component="h2">
|
||||
Termos de uso
|
||||
</Typography>
|
||||
<Typography id="modal-modal-description" sx={{ mt: 2 }}>
|
||||
<p>
|
||||
Bem-vindo ao Smart Energy View, a Plataforma Web da SMART ENERGIA!
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Agora você terá a Gestão da sua Energia na palma da sua mão!!!!
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Visualize os principais indicadores, dados de economia, resumo de operações, PLD, notícias além de acompanhar o consumo de energia em intervalos mínimos de 5 minutos.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Estamos na última fase de testes da plataforma e em breve também iremos disponibilizar os aplicativos para seu celular, nos sistemas operacionais IOS e Android.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Encontrando qualquer dificuldade, eventuais inconsistências ou dúvidas, nos contate!
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Lembrando que conforme nosso contrato de serviços vigente, todas as informações entregues são estritamente privadas, sendo seu sigilo protegido por lei, não podendo ser compartilhadas com terceiros sendo destinadas a seu uso exclusivo.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A divulgação não autorizada das informações adquiridas nesta plataforma (ou seu uso), de forma integral ou parcial, é proibida, não sendo permitido o compartilhamento dos acessos e senhas ou qualquer informação que tiver acesso junto a esta plataforma, sendo que o acesso a esta plataforma é restrito e individual.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
Destacamos que os resultados informados são meramente indicativos, não vinculantes a resultados e que as premissas disponibilizadas na plataforma são as mesmas utilizadas nos Energys Reports e estudos encaminhados.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<strong>Aproveite essa nova ferramenta de acompanhar sua Gestão de Energia!</strong>
|
||||
</p>
|
||||
{/* <p>
|
||||
Bem-vindo a Plataforma Web – SMART ENERGIA!
|
||||
</p>
|
||||
<p>
|
||||
Visualize os principais indicadores, dados de economia, resumo de operações, PLD, notícias além de acompanhar o consumo de energia em intervalos mínimos de 5 minutos.
|
||||
</p>
|
||||
<p>
|
||||
Conforme nosso contrato de serviços vigente, todas as informações entregues são estritamente privadas, sendo seu sigilo protegido por lei, não podendo ser compartilhadas com terceiros.
|
||||
</p>
|
||||
<p>
|
||||
A divulgação não autorizada das informações adquiridas nesta plataforma (ou seu uso), de forma integral ou parcial, é proibida, não sendo permitido o compartilhamento dos acessos e senhas ou qualquer informação que tiver acesso junto a esta plataforma, sendo que o acesso a esta plataforma é restrito e individual.
|
||||
</p>
|
||||
<p>
|
||||
Ressaltamos que os resultados informados são meramente indicativos.
|
||||
</p> */}
|
||||
<BasicButton title="Aceito os termos" onClick={() => {
|
||||
setCookie(undefined, 'terms', 'true')
|
||||
setOpen(false)
|
||||
}} />
|
||||
</Typography>
|
||||
</Box>
|
||||
</Modal>
|
||||
</>
|
||||
}
|
||||
</DashboardView>
|
||||
)
|
||||
@ -198,8 +238,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
await apiClient.post('/economy/grossAnnual').then(res => {
|
||||
grossAnualGraph = res.data.data
|
||||
})
|
||||
.then(console.log)
|
||||
.catch(console.log)
|
||||
.then(console.log)
|
||||
.catch(console.log)
|
||||
|
||||
await apiClient.post('/economy/grossMonthly').then(res => {
|
||||
grossMensalGraph = res.data.data
|
||||
|
||||
@ -41,7 +41,7 @@ const Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert(
|
||||
})
|
||||
|
||||
export default function Telemetria({ userName, clients }: any) {
|
||||
const [unity, setUnity] = useState(clients[0].codigo_scde);
|
||||
const [unity, setUnity] = useState(clients[0]?.codigo_scde);
|
||||
const [startDate, setStartDate] = useState(new Date());
|
||||
const [endDate, setEndDate] = useState(new Date());
|
||||
const [month, setMonth] = useState(new Date().getMonth() + 1);
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import axios, { AxiosRequestConfig } from "axios";
|
||||
import * as cookie from 'cookie';
|
||||
import axios from "axios";
|
||||
import * as express from 'express';
|
||||
import * as next from 'next';
|
||||
import { parseCookies } from "nookies";
|
||||
@ -13,7 +12,8 @@ export default function getAPIClient(ctx?: Pick<next.NextPageContext, 'req'> | {
|
||||
const { '@smartAuth-token': token } = parseCookies(ctx)
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: "https://api.energiasmart.com.br/api",
|
||||
// baseURL: "https://api.energiasmart.com.br/api",
|
||||
baseURL: "https://api.energiasmart.klupp.com.br/api",
|
||||
});
|
||||
|
||||
api.interceptors.request.use(config => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user