add create client with role
This commit is contained in:
parent
b731c80830
commit
d056493014
@ -14,15 +14,13 @@ interface GradientButtonInterface {
|
||||
onClick?: () => void
|
||||
}
|
||||
|
||||
export default function GradientButton({ title, description, orange, purple, green, link, onClick }: GradientButtonInterface) {
|
||||
const router = useRouter()
|
||||
|
||||
function handleClick() {
|
||||
onClick()
|
||||
}
|
||||
export default function GradientButton({ title, description, orange, purple, green, onClick }: GradientButtonInterface) {
|
||||
// function handleClick() {
|
||||
// onClick()
|
||||
// }
|
||||
|
||||
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>{description}</p>
|
||||
</GradientButtonView>
|
||||
|
||||
@ -32,8 +32,6 @@ export const GradientButtonView = styled.button`
|
||||
|
||||
border-style: none;
|
||||
|
||||
cursor: pointer;
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
@ -24,12 +24,10 @@ interface SingleBarInterface{
|
||||
label: Array<string>,
|
||||
dataset: string,
|
||||
barLabel?: boolean | undefined,
|
||||
year?: boolean | undefined,
|
||||
month?: boolean | undefined,
|
||||
dataset1?: string,
|
||||
brutoAnual?: boolean | undefined,
|
||||
}
|
||||
|
||||
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 options: object = {
|
||||
@ -76,6 +74,11 @@ export function SingleBar({ title, subtitle, dataProps, label, dataset, dataset1
|
||||
const data: any = {
|
||||
labels,
|
||||
datasets: [
|
||||
{
|
||||
label: '',
|
||||
data: [],
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
{
|
||||
label: dataset,
|
||||
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'
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
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>
|
||||
{
|
||||
!admin?
|
||||
<Image src={logo} width={170} height={50} />
|
||||
// <Image src={logo} width={170} height={50} />
|
||||
null
|
||||
:
|
||||
null
|
||||
}
|
||||
|
||||
@ -67,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 [nivelAcess, setnivelAcess] = useState<any>(2);
|
||||
const [openSnackSuccess, setOpenSnackSuccess] = useState<boolean>(false)
|
||||
const [openSnackError, setOpenSnackError] = useState<boolean>(false)
|
||||
const [openSnackSuccessDelete, setOpenSnackSuccessDelete] =
|
||||
@ -116,9 +116,9 @@ 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)
|
||||
formData.append('role', nivelAcess)
|
||||
|
||||
api.post('/user', formData)
|
||||
.then((res) => {
|
||||
setOpenSnackSuccess(true)
|
||||
setOpenModalInativar(false)
|
||||
@ -358,7 +358,7 @@ export default function clients({ clients, userName }) {
|
||||
fullWidth
|
||||
>
|
||||
<MenuItem value={1}>Administrador</MenuItem>
|
||||
<MenuItem value={0}>Cliente</MenuItem>
|
||||
<MenuItem value={2}>Cliente</MenuItem>
|
||||
|
||||
</Select>
|
||||
</FormControl>
|
||||
|
||||
@ -21,9 +21,11 @@ import { parseCookies } from 'nookies'
|
||||
import getAPIClient from '../services/ssrApi'
|
||||
import { api } from '../services/api'
|
||||
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 DiscretizedConsumptionChartLine from '../components/graph/DiscretizedConsumptionChartLine'
|
||||
import router, { useRouter } from 'next/router'
|
||||
import { DemRegXDemConChart } from '../components/graph/DemRegXDemConChart'
|
||||
|
||||
const style = {
|
||||
display: 'flex',
|
||||
@ -58,11 +60,16 @@ export default function chartTelemetry({userName}) {
|
||||
|
||||
const { ['user-cod_client']: cod_client } = parseCookies()
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const {startDate, endDate} = router.query
|
||||
|
||||
async function getChartsData() {
|
||||
console.log(router.query)
|
||||
await api.post('/telemetry/powerFactor', {
|
||||
"filters": [
|
||||
{"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 => {
|
||||
setFatorPotenciaData(res.data.data)
|
||||
@ -73,7 +80,7 @@ export default function chartTelemetry({userName}) {
|
||||
await api.post('/telemetry/demand', {
|
||||
"filters": [
|
||||
{"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 => {
|
||||
setDemRegXDemCon(res.data.data)
|
||||
@ -85,7 +92,7 @@ export default function chartTelemetry({userName}) {
|
||||
"type": "5_min",
|
||||
"filters": [
|
||||
{"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 => {
|
||||
setDiscretizedConsumptionData(res.data.data)
|
||||
@ -156,7 +163,7 @@ export default function chartTelemetry({userName}) {
|
||||
aria-describedby="modal-modal-description"
|
||||
>
|
||||
<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>
|
||||
</Modal>
|
||||
|
||||
|
||||
@ -105,12 +105,21 @@ export default function Telemetria({userName}: any) {
|
||||
</RenderIf>
|
||||
|
||||
<Buttons>
|
||||
<GradientButton title='GRÁFICO' description='Gerar gráficos com os dados selecionados' orange onClick={() => router.replace('/chartTelemetry', { query: {
|
||||
startDate,
|
||||
endDate,
|
||||
discretization
|
||||
}})}/>
|
||||
<GradientButton title='GRÁFICO' description='Gerar gráficos com os dados selecionados' orange onClick={() => router.replace('/chartTelemetry')}/>
|
||||
<Link href={{
|
||||
pathname: '/chartTelemetry',
|
||||
query: {
|
||||
startDate,
|
||||
endDate,
|
||||
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='DADOS' description='hORÁRIOS DO MÊS ATUAL' onClick={() => setShowChart(!showChart)} green />
|
||||
</Buttons>
|
||||
|
||||
@ -80,6 +80,58 @@ export const Buttons = styled.div`
|
||||
padding-left: 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) {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user