add create client with role
This commit is contained in:
parent
b731c80830
commit
d056493014
@ -14,15 +14,13 @@ interface GradientButtonInterface {
|
|||||||
onClick?: () => void
|
onClick?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GradientButton({ title, description, orange, purple, green, link, onClick }: GradientButtonInterface) {
|
export default function GradientButton({ title, description, orange, purple, green, onClick }: GradientButtonInterface) {
|
||||||
const router = useRouter()
|
// function handleClick() {
|
||||||
|
// onClick()
|
||||||
function handleClick() {
|
// }
|
||||||
onClick()
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GradientButtonView color={orange? 'orange' : purple? 'purple' : green? 'green' : 'orange' } onClick={() => link? router.push('/chartTelemetry') : handleClick()} >
|
<GradientButtonView color={orange? 'orange' : purple? 'purple' : green? 'green' : 'orange' } >
|
||||||
<p>{title}</p>
|
<p>{title}</p>
|
||||||
<p>{description}</p>
|
<p>{description}</p>
|
||||||
</GradientButtonView>
|
</GradientButtonView>
|
||||||
|
|||||||
@ -32,8 +32,6 @@ export const GradientButtonView = styled.button`
|
|||||||
|
|
||||||
border-style: none;
|
border-style: none;
|
||||||
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
* {
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|||||||
@ -24,12 +24,10 @@ interface SingleBarInterface{
|
|||||||
label: Array<string>,
|
label: Array<string>,
|
||||||
dataset: string,
|
dataset: string,
|
||||||
barLabel?: boolean | undefined,
|
barLabel?: boolean | undefined,
|
||||||
year?: boolean | undefined,
|
brutoAnual?: boolean | undefined,
|
||||||
month?: boolean | undefined,
|
|
||||||
dataset1?: string,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SingleBar({ title, subtitle, dataProps, label, dataset, dataset1, barLabel, year, month }: SingleBarInterface) {
|
export function SingleBar({ title, subtitle, dataProps, label, dataset, barLabel, brutoAnual }: SingleBarInterface) {
|
||||||
const currentTime = new Date();
|
const currentTime = new Date();
|
||||||
|
|
||||||
const options: object = {
|
const options: object = {
|
||||||
@ -76,6 +74,11 @@ export function SingleBar({ title, subtitle, dataProps, label, dataset, dataset1
|
|||||||
const data: any = {
|
const data: any = {
|
||||||
labels,
|
labels,
|
||||||
datasets: [
|
datasets: [
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
data: [],
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: dataset,
|
label: dataset,
|
||||||
data: dataProps.map((value, index) => {
|
data: dataProps.map((value, index) => {
|
||||||
@ -85,7 +88,14 @@ export function SingleBar({ title, subtitle, dataProps, label, dataset, dataset1
|
|||||||
return dataProps[value.dataIndex]?.dad_estimado == false ? '#255488' : '#C2d5fb'
|
return dataProps[value.dataIndex]?.dad_estimado == false ? '#255488' : '#C2d5fb'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
data: [dataProps[0]?.economia_acumulada?dataProps[0].economia_acumulada*1.1:1],
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
datalabels: {
|
||||||
|
display: false
|
||||||
|
}
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,8 @@ export default function Header({ name, admin, logo }: headerInterface) {
|
|||||||
<section>
|
<section>
|
||||||
{
|
{
|
||||||
!admin?
|
!admin?
|
||||||
<Image src={logo} width={170} height={50} />
|
// <Image src={logo} width={170} height={50} />
|
||||||
|
null
|
||||||
:
|
:
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,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 [nivelAcess, setnivelAcess] = useState<any>(2);
|
||||||
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] =
|
||||||
@ -116,9 +116,9 @@ 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)
|
formData.append('role', nivelAcess)
|
||||||
api
|
|
||||||
.post('/user', formData)
|
api.post('/user', formData)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setOpenSnackSuccess(true)
|
setOpenSnackSuccess(true)
|
||||||
setOpenModalInativar(false)
|
setOpenModalInativar(false)
|
||||||
@ -358,7 +358,7 @@ export default function clients({ clients, userName }) {
|
|||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
<MenuItem value={1}>Administrador</MenuItem>
|
<MenuItem value={1}>Administrador</MenuItem>
|
||||||
<MenuItem value={0}>Cliente</MenuItem>
|
<MenuItem value={2}>Cliente</MenuItem>
|
||||||
|
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
@ -21,9 +21,11 @@ import { parseCookies } from 'nookies'
|
|||||||
import getAPIClient from '../services/ssrApi'
|
import getAPIClient from '../services/ssrApi'
|
||||||
import { api } from '../services/api'
|
import { api } from '../services/api'
|
||||||
import FatorPotenciaChart from '../components/graph/fatorPotenciaChart'
|
import FatorPotenciaChart from '../components/graph/fatorPotenciaChart'
|
||||||
import { DemRegXDemConChart } from '../components/graph/demRegXDemConChart'
|
// import { DemRegXDemConChart } from '../components/graph/demRegXDemConChart'
|
||||||
import { DiscretizedConsumptionChart } from '../components/graph/DiscretizedConsumptionChart'
|
import { DiscretizedConsumptionChart } from '../components/graph/DiscretizedConsumptionChart'
|
||||||
import DiscretizedConsumptionChartLine from '../components/graph/DiscretizedConsumptionChartLine'
|
import DiscretizedConsumptionChartLine from '../components/graph/DiscretizedConsumptionChartLine'
|
||||||
|
import router, { useRouter } from 'next/router'
|
||||||
|
import { DemRegXDemConChart } from '../components/graph/DemRegXDemConChart'
|
||||||
|
|
||||||
const style = {
|
const style = {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -58,11 +60,16 @@ export default function chartTelemetry({userName}) {
|
|||||||
|
|
||||||
const { ['user-cod_client']: cod_client } = parseCookies()
|
const { ['user-cod_client']: cod_client } = parseCookies()
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
const {startDate, endDate} = router.query
|
||||||
|
|
||||||
async function getChartsData() {
|
async function getChartsData() {
|
||||||
|
console.log(router.query)
|
||||||
await api.post('/telemetry/powerFactor', {
|
await api.post('/telemetry/powerFactor', {
|
||||||
"filters": [
|
"filters": [
|
||||||
{"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"},
|
{"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"},
|
||||||
{"type" : "between", "field": "dia_num", "value": ["2022-01-03", "2022-01-03"]}
|
{"type" : "between", "field": "dia_num", "value": [startDate, endDate]}
|
||||||
]
|
]
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
setFatorPotenciaData(res.data.data)
|
setFatorPotenciaData(res.data.data)
|
||||||
@ -73,7 +80,7 @@ export default function chartTelemetry({userName}) {
|
|||||||
await api.post('/telemetry/demand', {
|
await api.post('/telemetry/demand', {
|
||||||
"filters": [
|
"filters": [
|
||||||
{"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"},
|
{"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"},
|
||||||
{"type" : "between", "field": "dia_num", "value": ["2022-01-03", "2022-01-03"]}
|
{"type" : "between", "field": "dia_num", "value": [startDate, endDate]}
|
||||||
]
|
]
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
setDemRegXDemCon(res.data.data)
|
setDemRegXDemCon(res.data.data)
|
||||||
@ -85,7 +92,7 @@ export default function chartTelemetry({userName}) {
|
|||||||
"type": "5_min",
|
"type": "5_min",
|
||||||
"filters": [
|
"filters": [
|
||||||
{"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"},
|
{"type" : "=", "field": "med_5min.ponto", "value": "RSZFNAENTR101P"},
|
||||||
{"type" : "between", "field": "dia_num", "value": ["2022-01-03", "2022-01-03"]}
|
{"type" : "between", "field": "dia_num", "value": [startDate, endDate]}
|
||||||
]
|
]
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
setDiscretizedConsumptionData(res.data.data)
|
setDiscretizedConsumptionData(res.data.data)
|
||||||
@ -156,7 +163,7 @@ export default function chartTelemetry({userName}) {
|
|||||||
aria-describedby="modal-modal-description"
|
aria-describedby="modal-modal-description"
|
||||||
>
|
>
|
||||||
<Box sx={style}>
|
<Box sx={style}>
|
||||||
<SingleBar title='Consumo discretizado em 1 hora' subtitle='' dataProps={ConsumoDecretizadoBar.data} label={ConsumoDecretizadoBar.label} dataset={'Consumo'} dataset1='Estimado' month/>
|
<SingleBar title='Consumo discretizado em 1 hora' subtitle='' dataProps={ConsumoDecretizadoBar.data} label={ConsumoDecretizadoBar.label} dataset={'Consumo'}/>
|
||||||
</Box>
|
</Box>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
|||||||
@ -105,12 +105,21 @@ export default function Telemetria({userName}: any) {
|
|||||||
</RenderIf>
|
</RenderIf>
|
||||||
|
|
||||||
<Buttons>
|
<Buttons>
|
||||||
<GradientButton title='GRÁFICO' description='Gerar gráficos com os dados selecionados' orange onClick={() => router.replace('/chartTelemetry', { query: {
|
<Link href={{
|
||||||
startDate,
|
pathname: '/chartTelemetry',
|
||||||
endDate,
|
query: {
|
||||||
discretization
|
startDate,
|
||||||
}})}/>
|
endDate,
|
||||||
<GradientButton title='GRÁFICO' description='Gerar gráficos com os dados selecionados' orange onClick={() => router.replace('/chartTelemetry')}/>
|
discretization
|
||||||
|
},
|
||||||
|
}} >
|
||||||
|
{/* <GradientButton title='GRÁFICO' description='Gerar gráficos com os dados selecionados' orange/> */}
|
||||||
|
<button>
|
||||||
|
<p>GRÁFICO</p>
|
||||||
|
<p>Gerar gráficos com os dados selecionados</p>
|
||||||
|
</button>
|
||||||
|
</Link>
|
||||||
|
{/* <GradientButton title='GRÁFICO' description='Gerar gráficos com os dados selecionados' orange onClick={() => router.replace('/chartTelemetry')}/> */}
|
||||||
<GradientButton title='DOWNLOADS' description='DADOS BRUTOS SELECIONADOS' purple />
|
<GradientButton title='DOWNLOADS' description='DADOS BRUTOS SELECIONADOS' purple />
|
||||||
<GradientButton title='DADOS' description='hORÁRIOS DO MÊS ATUAL' onClick={() => setShowChart(!showChart)} green />
|
<GradientButton title='DADOS' description='hORÁRIOS DO MÊS ATUAL' onClick={() => setShowChart(!showChart)} green />
|
||||||
</Buttons>
|
</Buttons>
|
||||||
|
|||||||
@ -80,6 +80,58 @@ export const Buttons = styled.div`
|
|||||||
padding-left: 100px;
|
padding-left: 100px;
|
||||||
padding-right: 100px;
|
padding-right: 100px;
|
||||||
|
|
||||||
|
button {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
flex-direction: column;
|
||||||
|
border-radius: 2px;
|
||||||
|
|
||||||
|
width: 30%;
|
||||||
|
min-width: 240px;
|
||||||
|
height: 110px;
|
||||||
|
min-height: 110px;
|
||||||
|
margin-bottom: 25px;
|
||||||
|
|
||||||
|
font-family: 'Poppins';
|
||||||
|
font-size: 10px;
|
||||||
|
|
||||||
|
color: #FFFFFF;
|
||||||
|
|
||||||
|
:first-child {
|
||||||
|
background: linear-gradient(200.86deg, #F48665 8.03%, #F48665 91.97%), #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
box-shadow: 0.5px 3px 10px rgba(119, 119, 119, 0.1);
|
||||||
|
|
||||||
|
border-style: none;
|
||||||
|
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
:first-child {
|
||||||
|
font-family: 'Poppins';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: calc(20px);
|
||||||
|
|
||||||
|
text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
||||||
|
}
|
||||||
|
:last-child {
|
||||||
|
font-family: 'Poppins';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 12;
|
||||||
|
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 942px) {
|
@media (max-width: 942px) {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user