add api instace and auth
This commit is contained in:
commit
4803f8a1f9
231
package-lock.json
generated
231
package-lock.json
generated
@ -4595,6 +4595,171 @@
|
|||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 6"
|
"node": ">= 6"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@next/swc-android-arm-eabi": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-BxBr3QAAAXWgk/K7EedvzxJr2dE014mghBSA9iOEAv0bMgF+MRq4PoASjuHi15M2zfowpcRG8XQhMFtxftCleQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"android"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@next/swc-android-arm64": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-EboEk3ROYY7U6WA2RrMt/cXXMokUTXXfnxe2+CU+DOahvbrO8QSWhlBl9I9ZbFzJx28AGB9Yo3oQHCvph/4Lew==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"android"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@next/swc-darwin-arm64": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-P0EXU12BMSdNj1F7vdkP/VrYDuCNwBExtRPDYawgSUakzi6qP0iKJpya2BuLvNzXx+XPU49GFuDC5X+SvY0mOw==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@next/swc-darwin-x64": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-9FptMnbgHJK3dRDzfTpexs9S2hGpzOQxSQbe8omz6Pcl7rnEp9x4uSEKY51ho85JCjL4d0tDLBcXEJZKKLzxNg==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@next/swc-linux-arm-gnueabihf": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-PvfEa1RR55dsik/IDkCKSFkk6ODNGJqPY3ysVUZqmnWMDSuqFtf7BPWHFa/53znpvVB5XaJ5Z1/6aR5CTIqxPw==",
|
||||||
|
"cpu": [
|
||||||
|
"arm"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@next/swc-linux-arm64-gnu": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-53QOvX1jBbC2ctnmWHyRhMajGq7QZfl974WYlwclXarVV418X7ed7o/EzGY+YVAEKzIVaAB9JFFWGXn8WWo0gQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@next/swc-linux-arm64-musl": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-CMWAkYqfGdQCS+uuMA1A2UhOfcUYeoqnTW7msLr2RyYAys15pD960hlDfq7QAi8BCAKk0sQ2rjsl0iqMyziohQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@next/swc-linux-x64-gnu": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-AC7jE4Fxpn0s3ujngClIDTiEM/CQiB2N2vkcyWWn6734AmGT03Duq6RYtPMymFobDdAtZGFZd5nR95WjPzbZAQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@next/swc-linux-x64-musl": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-c9Vjmi0EVk0Kou2qbrynskVarnFwfYIi+wKufR9Ad7/IKKuP6aEhOdZiIIdKsYWRtK2IWRF3h3YmdnEa2WLUag==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@next/swc-win32-arm64-msvc": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-3UTOL/5XZSKFelM7qN0it35o3Cegm6LsyuERR3/OoqEExyj3aCk7F025b54/707HTMAnjlvQK3DzLhPu/xxO4g==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@next/swc-win32-ia32-msvc": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-8ZWoj6nCq6fI1yCzKq6oK0jE6Mxlz4MrEsRyu0TwDztWQWe7rh4XXGLAa2YVPatYcHhMcUL+fQQbqd1MsgaSDA==",
|
||||||
|
"cpu": [
|
||||||
|
"ia32"
|
||||||
|
],
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -7417,6 +7582,72 @@
|
|||||||
"yaml": {
|
"yaml": {
|
||||||
"version": "1.10.2",
|
"version": "1.10.2",
|
||||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz"
|
"resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz"
|
||||||
|
},
|
||||||
|
"@next/swc-android-arm-eabi": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-BxBr3QAAAXWgk/K7EedvzxJr2dE014mghBSA9iOEAv0bMgF+MRq4PoASjuHi15M2zfowpcRG8XQhMFtxftCleQ==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@next/swc-android-arm64": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-EboEk3ROYY7U6WA2RrMt/cXXMokUTXXfnxe2+CU+DOahvbrO8QSWhlBl9I9ZbFzJx28AGB9Yo3oQHCvph/4Lew==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@next/swc-darwin-arm64": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-P0EXU12BMSdNj1F7vdkP/VrYDuCNwBExtRPDYawgSUakzi6qP0iKJpya2BuLvNzXx+XPU49GFuDC5X+SvY0mOw==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@next/swc-darwin-x64": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-9FptMnbgHJK3dRDzfTpexs9S2hGpzOQxSQbe8omz6Pcl7rnEp9x4uSEKY51ho85JCjL4d0tDLBcXEJZKKLzxNg==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@next/swc-linux-arm-gnueabihf": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-PvfEa1RR55dsik/IDkCKSFkk6ODNGJqPY3ysVUZqmnWMDSuqFtf7BPWHFa/53znpvVB5XaJ5Z1/6aR5CTIqxPw==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@next/swc-linux-arm64-gnu": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-53QOvX1jBbC2ctnmWHyRhMajGq7QZfl974WYlwclXarVV418X7ed7o/EzGY+YVAEKzIVaAB9JFFWGXn8WWo0gQ==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@next/swc-linux-arm64-musl": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-CMWAkYqfGdQCS+uuMA1A2UhOfcUYeoqnTW7msLr2RyYAys15pD960hlDfq7QAi8BCAKk0sQ2rjsl0iqMyziohQ==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@next/swc-linux-x64-gnu": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-AC7jE4Fxpn0s3ujngClIDTiEM/CQiB2N2vkcyWWn6734AmGT03Duq6RYtPMymFobDdAtZGFZd5nR95WjPzbZAQ==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@next/swc-linux-x64-musl": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-c9Vjmi0EVk0Kou2qbrynskVarnFwfYIi+wKufR9Ad7/IKKuP6aEhOdZiIIdKsYWRtK2IWRF3h3YmdnEa2WLUag==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@next/swc-win32-arm64-msvc": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-3UTOL/5XZSKFelM7qN0it35o3Cegm6LsyuERR3/OoqEExyj3aCk7F025b54/707HTMAnjlvQK3DzLhPu/xxO4g==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@next/swc-win32-ia32-msvc": {
|
||||||
|
"version": "12.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.1.6.tgz",
|
||||||
|
"integrity": "sha512-8ZWoj6nCq6fI1yCzKq6oK0jE6Mxlz4MrEsRyu0TwDztWQWe7rh4XXGLAa2YVPatYcHhMcUL+fQQbqd1MsgaSDA==",
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,6 +39,7 @@
|
|||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^10.1.0",
|
||||||
"install": "^0.13.0",
|
"install": "^0.13.0",
|
||||||
"next": "12.1.6",
|
"next": "12.1.6",
|
||||||
|
"nookies": "^2.5.2",
|
||||||
"npm": "^8.10.0",
|
"npm": "^8.10.0",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"patternomaly": "^1.3.2",
|
"patternomaly": "^1.3.2",
|
||||||
@ -54,6 +55,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/preset-env": "^7.17.10",
|
"@babel/preset-env": "^7.17.10",
|
||||||
"@types/chartjs": "^0.0.31",
|
"@types/chartjs": "^0.0.31",
|
||||||
|
"@types/cookies": "^0.7.7",
|
||||||
"@types/faker": "5.5.3",
|
"@types/faker": "5.5.3",
|
||||||
"@types/node": "^17.0.31",
|
"@types/node": "^17.0.31",
|
||||||
"@types/nprogress": "^0.2.0",
|
"@types/nprogress": "^0.2.0",
|
||||||
|
|||||||
@ -293,7 +293,7 @@ export default function ClientTable() {
|
|||||||
Unidade - {row.clientCode}
|
Unidade - {row.clientCode}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="left">{row.name}</TableCell>
|
<TableCell align="left">{row.name}</TableCell>
|
||||||
<TableCell align="left">{row.unity}</TableCell>
|
<TableCell align="left">{row.unity}button</TableCell>
|
||||||
<TableCell align="left"><StyledStatus status={row.status}>{row.status}</StyledStatus></TableCell>
|
<TableCell align="left"><StyledStatus status={row.status}>{row.status}</StyledStatus></TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
|
|||||||
14
src/components/buttons/faqButton/FaqButton1.tsx
Normal file
14
src/components/buttons/faqButton/FaqButton1.tsx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
import { FaqButtonView1 } from './FaqButtonView1'
|
||||||
|
|
||||||
|
interface FaqButtonInterface {
|
||||||
|
title: string
|
||||||
|
onClick: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function FaqButton1({title, onClick}: FaqButtonInterface) {
|
||||||
|
return (
|
||||||
|
<FaqButtonView1 onClick={() => onClick()}>{title}</FaqButtonView1>
|
||||||
|
)
|
||||||
|
}
|
||||||
14
src/components/buttons/faqButton/FaqButton2.tsx
Normal file
14
src/components/buttons/faqButton/FaqButton2.tsx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
import { FaqButtonView2 } from './FaqButtonView2'
|
||||||
|
|
||||||
|
interface FaqButtonInterface {
|
||||||
|
title: string
|
||||||
|
onClick: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function FaqButton2({title, onClick}: FaqButtonInterface) {
|
||||||
|
return (
|
||||||
|
<FaqButtonView2 onClick={() => onClick()}>{title}</FaqButtonView2>
|
||||||
|
)
|
||||||
|
}
|
||||||
21
src/components/buttons/faqButton/FaqButtonView1.ts
Normal file
21
src/components/buttons/faqButton/FaqButtonView1.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import styled from 'styled-components'
|
||||||
|
|
||||||
|
export const FaqButtonView1 = styled.button`
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-left: 65px;
|
||||||
|
width: 350px;
|
||||||
|
height: 45px;
|
||||||
|
cursor: pointer;
|
||||||
|
background: #DDDDDD;
|
||||||
|
border-radius: 8px;
|
||||||
|
border-style: none;
|
||||||
|
|
||||||
|
font-family: 'Poppins';
|
||||||
|
font-size: 90%;
|
||||||
|
|
||||||
|
|
||||||
|
color: #6A707E;
|
||||||
|
`
|
||||||
22
src/components/buttons/faqButton/FaqButtonView2.ts
Normal file
22
src/components/buttons/faqButton/FaqButtonView2.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import styled from 'styled-components'
|
||||||
|
|
||||||
|
export const FaqButtonView2 = styled.button`
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: -46px;
|
||||||
|
margin-left: 430px;
|
||||||
|
width: 350px;
|
||||||
|
height: 45px;
|
||||||
|
cursor: pointer;
|
||||||
|
background: #254F7F;
|
||||||
|
border-radius: 8px;
|
||||||
|
border-style: none;
|
||||||
|
|
||||||
|
font-family: 'Poppins';
|
||||||
|
font-size: 90%;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
color: #FFFFFF;
|
||||||
|
`
|
||||||
@ -1,20 +1,21 @@
|
|||||||
import React from 'react'
|
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
import RenderIf from '../../../utils/renderIf'
|
import RenderIf from '../../../utils/renderIf'
|
||||||
import { LoginButtonView } from './LoginButtonView'
|
import { LoginButtonView } from './LoginButtonView'
|
||||||
|
|
||||||
interface LoginButtonInterface {
|
interface LoginButtonInterface {
|
||||||
title: string,
|
title: string,
|
||||||
link?: boolean | undefined,
|
link?: boolean | undefined,
|
||||||
onClick?: () => void
|
onClick: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function LoginButton({ title, link, onClick }: LoginButtonInterface) {
|
export default function LoginButton({ title, link, onClick }: LoginButtonInterface) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RenderIf isTrue={link? true : false}>
|
<RenderIf isTrue={link? true : false}>
|
||||||
<Link href='/dashboard' >
|
<Link href='/dashboard'>
|
||||||
<LoginButtonView>
|
<LoginButtonView onClick={() => onClick()}>
|
||||||
{title}
|
{title}
|
||||||
</LoginButtonView>
|
</LoginButtonView>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@ -1,18 +1,11 @@
|
|||||||
import React from 'react';
|
import { BarElement, CategoryScale, Chart as ChartJS, Legend, LinearScale, Title, Tooltip } from 'chart.js';
|
||||||
import {
|
|
||||||
Chart as ChartJS,
|
|
||||||
CategoryScale,
|
|
||||||
LinearScale,
|
|
||||||
BarElement,
|
|
||||||
Title,
|
|
||||||
Tooltip,
|
|
||||||
Legend,
|
|
||||||
} from 'chart.js';
|
|
||||||
import { Bar } from 'react-chartjs-2';
|
|
||||||
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
||||||
import { ChartView } from './ChartView';
|
|
||||||
import ChartTitle from './ChartTitle';
|
|
||||||
import { draw, generate } from 'patternomaly'
|
import { draw, generate } from 'patternomaly'
|
||||||
|
import React from 'react';
|
||||||
|
import { Bar } from 'react-chartjs-2';
|
||||||
|
|
||||||
|
import ChartTitle from './ChartTitle';
|
||||||
|
import { ChartView } from './ChartView';
|
||||||
|
|
||||||
ChartJS.register(
|
ChartJS.register(
|
||||||
CategoryScale,
|
CategoryScale,
|
||||||
@ -57,8 +50,6 @@ export function SingleBar({ title, subtitle, dataProps, label, dataset, dataset1
|
|||||||
const percentage = (value*100 / sum).toFixed(0)+"%";
|
const percentage = (value*100 / sum).toFixed(0)+"%";
|
||||||
const result = `${value}\n ${percentage}`
|
const result = `${value}\n ${percentage}`
|
||||||
|
|
||||||
console.log(value)
|
|
||||||
|
|
||||||
return value==null? null : result
|
return value==null? null : result
|
||||||
},
|
},
|
||||||
display: true,
|
display: true,
|
||||||
|
|||||||
@ -35,7 +35,7 @@ export default function Sidebar() {
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const user = {
|
const user = {
|
||||||
role: 'client'
|
role: 'admin'
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -53,10 +53,10 @@ export default function Sidebar() {
|
|||||||
<Image src='/assets/logo.svg' width={100} height={100} />
|
<Image src='/assets/logo.svg' width={100} height={100} />
|
||||||
</div>
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
<Link href='/administrative'><li className={router.pathname=='/administrative' ? 'actualPath' : null } ><Image src='/assets/sidebar/economyIcon.svg' width={25} height={25} />{'Clientes >'}</li></Link>
|
<Link href='/administrative/clients'><li className={router.pathname=='/administrative' ? 'actualPath' : null } ><Image src='/assets/sidebar/economyIcon.svg' width={25} height={25} />{'Clientes >'}</li></Link>
|
||||||
<Link href='/administrative/general'><li className={router.pathname=='/administrative/general'? 'actualPath' : null} ><Image src='/assets/sidebar/dashboardIcon.svg' width={25} height={25} />{'Visão Geral'}</li></Link>
|
<Link href='/administrative/general'><li className={router.pathname=='/administrative/general'? 'actualPath' : null} ><Image src='/assets/sidebar/dashboardIcon.svg' width={25} height={25} />{'Visão Geral'}</li></Link>
|
||||||
<Link href='/administrative/faq'><li className={router.pathname=='/administrative/faq' ? 'actualPath' : null } ><Image src='/assets/sidebar/saqIcon.svg' width={25} height={25} />{'FAQ >'}</li></Link>
|
<Link href='/administrative/faq'><li className={router.pathname=='/administrative/faq' ? 'actualPath' : null } ><Image src='/assets/sidebar/saqIcon.svg' width={25} height={25} />{'FAQ >'}</li></Link>
|
||||||
<Link href='/administrative/notifications'><li className={router.pathname=='/administrative/notifications'? 'actualPath' : null}><Image src='/assets/sidebar/notificationsIcon.svg' width={25} height={25} />{'Notificações >'}<div className='notification'><p>25</p></div></li></Link>
|
<Link href='/administrative/notification'><li className={router.pathname=='/administrative/notifications'? 'actualPath' : null}><Image src='/assets/sidebar/notificationsIcon.svg' width={25} height={25} />{'Notificações >'}<div className='notification'><p>25</p></div></li></Link>
|
||||||
{/* <li onClick={() => setEconomiaDrawer(!economiaDrawer)} className={router.pathname=='/grossSavings' || router.pathname=='/accumulatedSavings' || router.pathname=='/estimatedCost' || router.pathname=='/costIndicator' ? 'actualPath' : null } ><Image src='/assets/sidebar/economyIcon.svg' width={25} height={25} />{'Economia >'}</li>
|
{/* <li onClick={() => setEconomiaDrawer(!economiaDrawer)} className={router.pathname=='/grossSavings' || router.pathname=='/accumulatedSavings' || router.pathname=='/estimatedCost' || router.pathname=='/costIndicator' ? 'actualPath' : null } ><Image src='/assets/sidebar/economyIcon.svg' width={25} height={25} />{'Economia >'}</li>
|
||||||
<div className='economiaDrawer drawer' >
|
<div className='economiaDrawer drawer' >
|
||||||
<Link href='/administrative/grossSavings'><li className={router.pathname=='/grossSavings'? 'actualPathDrawer' : null}>Economia Bruta</li></Link>
|
<Link href='/administrative/grossSavings'><li className={router.pathname=='/grossSavings'? 'actualPathDrawer' : null}>Economia Bruta</li></Link>
|
||||||
|
|||||||
@ -182,7 +182,7 @@ export const SidebarView = styled.nav<SidebarViewInterface>`
|
|||||||
|
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
|
||||||
height: 5rem;
|
height: 3.5rem;
|
||||||
}
|
}
|
||||||
.imageNext {
|
.imageNext {
|
||||||
display: none;
|
display: none;
|
||||||
@ -194,8 +194,8 @@ export const SidebarView = styled.nav<SidebarViewInterface>`
|
|||||||
background-color: #FFF;
|
background-color: #FFF;
|
||||||
|
|
||||||
li {
|
li {
|
||||||
height: 7rem;
|
height: 5rem;
|
||||||
font-size: 170%;
|
font-size: 150%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aside {
|
aside {
|
||||||
@ -207,15 +207,17 @@ export const SidebarView = styled.nav<SidebarViewInterface>`
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
ul {
|
ul {
|
||||||
li {
|
li {
|
||||||
height: 2rem;
|
height: 3rem;
|
||||||
|
font-size: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media (max-width: 1008px) {
|
@media (max-width: 1008px) {
|
||||||
font-size: 14px;
|
font-size: 26px;
|
||||||
ul {
|
ul {
|
||||||
li {
|
li {
|
||||||
height: 6rem;
|
height: 7rem;
|
||||||
|
font-size: 99.98%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
55
src/contexts/AuthContext.tsx
Normal file
55
src/contexts/AuthContext.tsx
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import React, { createContext, useState } from "react";
|
||||||
|
import Router from 'next/router'
|
||||||
|
|
||||||
|
import { setCookie } from "nookies";
|
||||||
|
|
||||||
|
import { signInRequest } from "../services/auth";
|
||||||
|
import api from "../services/api";
|
||||||
|
|
||||||
|
type UserType = {
|
||||||
|
name: string;
|
||||||
|
email: string;
|
||||||
|
avatar_url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type SignInData = {
|
||||||
|
email: string;
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthContextType = {
|
||||||
|
isAuthenticated: boolean;
|
||||||
|
user: UserType;
|
||||||
|
signIn: (data: SignInData) => Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const AuthContext = createContext({} as AuthContextType)
|
||||||
|
|
||||||
|
export function AuthProvider({children}: {children: React.ReactNode}) {
|
||||||
|
const [user, setUser] = useState<UserType | null>(null)
|
||||||
|
|
||||||
|
const isAuthenticated = !!user
|
||||||
|
|
||||||
|
async function signIn({email, password}: SignInData) {
|
||||||
|
const { token, user }: any = await signInRequest({
|
||||||
|
email,
|
||||||
|
password
|
||||||
|
})
|
||||||
|
|
||||||
|
setCookie(undefined, '@smartAuth-token', token, {
|
||||||
|
maxAge: 60 * 60 * 1, // 1 hour
|
||||||
|
})
|
||||||
|
|
||||||
|
api.defaults.headers['Authorization'] = `Bearer ${token}`
|
||||||
|
|
||||||
|
setUser(user)
|
||||||
|
|
||||||
|
Router.push('/dashboard')
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AuthContext.Provider value={{ user, isAuthenticated, signIn }}>
|
||||||
|
{children}
|
||||||
|
</AuthContext.Provider>
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -1,19 +1,23 @@
|
|||||||
import React, { useState, useEffect } from 'react'
|
|
||||||
import { useRouter } from 'next/router'
|
|
||||||
import { AppProps } from 'next/app'
|
import { AppProps } from 'next/app'
|
||||||
|
import Head from 'next/head'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
import NProgress from 'nprogress'
|
import NProgress from 'nprogress'
|
||||||
|
import React, { useContext, useEffect, useState } from 'react'
|
||||||
// import Footer from '../components/footer/Footer'
|
|
||||||
import Sidebar from '../components/sidebar/Sidebar'
|
|
||||||
import { GlobalStyle } from '../styles/globals'
|
|
||||||
import { AppView } from '../styles/app/AppView'
|
|
||||||
import '../styles/nprogress/nprogress.css'
|
|
||||||
import '../styles/globals.ts'
|
|
||||||
|
|
||||||
import Home from '.'
|
import Home from '.'
|
||||||
import Head from 'next/head'
|
// import Footer from '../components/footer/Footer'
|
||||||
import VerifyEmail from './verifyEmail'
|
import Sidebar from '../components/sidebar/Sidebar'
|
||||||
|
import { AuthContext, AuthProvider } from '../contexts/AuthContext'
|
||||||
|
import { AppView } from '../styles/app/AppView'
|
||||||
|
import { GlobalStyle } from '../styles/globals'
|
||||||
import ForgotPassword from './forgotPassword'
|
import ForgotPassword from './forgotPassword'
|
||||||
|
import VerifyEmail from './verifyEmail'
|
||||||
|
|
||||||
|
import '../styles/globals.ts'
|
||||||
|
import '../styles/nprogress/nprogress.css'
|
||||||
|
import { GetServerSideProps } from 'next'
|
||||||
|
import { parseCookies } from 'nookies'
|
||||||
|
import getAPIClient from '../services/ssrApi'
|
||||||
|
|
||||||
function MyApp({ Component, pageProps }: AppProps) {
|
function MyApp({ Component, pageProps }: AppProps) {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@ -40,7 +44,7 @@ function MyApp({ Component, pageProps }: AppProps) {
|
|||||||
}, [router])
|
}, [router])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<AuthProvider>
|
||||||
<AppView>
|
<AppView>
|
||||||
<Head>
|
<Head>
|
||||||
<link rel="icon" type="imagem/png" href="/assets/logose.png" />
|
<link rel="icon" type="imagem/png" href="/assets/logose.png" />
|
||||||
@ -61,8 +65,7 @@ function MyApp({ Component, pageProps }: AppProps) {
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
</AppView>
|
</AppView>
|
||||||
{/* <Footer /> */}
|
</AuthProvider>
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
91
src/pages/administrative/clients.tsx
Normal file
91
src/pages/administrative/clients.tsx
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
import Box from '@mui/material/Box';
|
||||||
|
import Button from '@mui/material/Button';
|
||||||
|
import Modal from '@mui/material/Modal';
|
||||||
|
import TextField from '@mui/material/TextField';
|
||||||
|
import Typography from '@mui/material/Typography';
|
||||||
|
import { DataGrid, GridColDef, GridValueGetterParams } from '@mui/x-data-grid';
|
||||||
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
|
import AdministrativeHeader from '../../components/administrativeHeader/AdministrativeHeader';
|
||||||
|
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 ConfirmModal from '../../components/modal/ConfirmModal';
|
||||||
|
import PageTitle from '../../components/pageTitle/PageTitle'
|
||||||
|
import { ClientsView, ConfirmModalView } from '../../styles/layouts/clients/ClientsView'
|
||||||
|
|
||||||
|
const style = {
|
||||||
|
position: 'absolute' as const,
|
||||||
|
top: '50%',
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translate(-50%, -50%)',
|
||||||
|
width: 900,
|
||||||
|
height: 500,
|
||||||
|
bgcolor: 'background.paper',
|
||||||
|
border: '2px solid #000',
|
||||||
|
boxShadow: 24,
|
||||||
|
p: 4,
|
||||||
|
overflowY: 'scroll'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default function clients() {
|
||||||
|
const [open, setOpen] = React.useState(false);
|
||||||
|
const [openModalInativar, setOpenModalInativar] = useState(false)
|
||||||
|
const handleOpen = () => setOpen(true);
|
||||||
|
const handleClose = () => setOpen(false);
|
||||||
|
|
||||||
|
const [openModal, setOpenModal] = useState(false)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{display: 'flex', flexDirection: 'column', width: '100%'}}>
|
||||||
|
<ClientsView>
|
||||||
|
<Header name='' />
|
||||||
|
<PageTitle title='Clientes' subtitle='Clientes Smart Energia'/>
|
||||||
|
{/* <BasicButton title='Adicionar' onClick={handleOpen}/> */}
|
||||||
|
<div className='buttons'>
|
||||||
|
<button className='btn2' onClick={handleOpen}>Adicionar</button>
|
||||||
|
<button className='btn1' onClick={() => setOpenModalInativar(true)}>Inativar</button>
|
||||||
|
</div>
|
||||||
|
<Modal
|
||||||
|
open={open}
|
||||||
|
onClose={handleClose}
|
||||||
|
aria-labelledby="modal-modal-title"
|
||||||
|
aria-describedby="modal-modal-description"
|
||||||
|
>
|
||||||
|
<Box sx={style}>
|
||||||
|
<h1>Adicionar Cliente</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}} variant="outlined" />
|
||||||
|
<TextField id="outlined-basic" label="E-mail/Usuário" sx={{width:350, ml:8}} variant="outlined" />
|
||||||
|
<TextField id="outlined-basic" label="Senha" sx={{width:350, ml:5, mt:2}} variant="outlined" />
|
||||||
|
<TextField id="outlined-basic" label="Confirma Senha" sx={{width:350, ml:8, mt:2}} variant="outlined" />
|
||||||
|
<TextField id="outlined-basic" label="Codigo do Cliente Smart Energia" sx={{width:350, ml:5, mt:2}} variant="outlined" />
|
||||||
|
<TextField id="outlined-basic" label="Imagem/Logotipo" sx={{width:350, ml:8, mt:2}} variant="outlined" />
|
||||||
|
<br /><br />
|
||||||
|
<FaqButton1 title='Cancelar' onClick={()=>console.log()} />
|
||||||
|
<FaqButton2 title='Salvar' onClick={()=>console.log()}/>
|
||||||
|
</Box>
|
||||||
|
</Modal>
|
||||||
|
<section>
|
||||||
|
<ClientsTable />
|
||||||
|
</section>
|
||||||
|
</ClientsView>
|
||||||
|
|
||||||
|
<ConfirmModal open={openModalInativar} handleIsClose={(value) => {setOpenModalInativar(value)}}>
|
||||||
|
<ConfirmModalView>
|
||||||
|
<BasicButton title='Confirmar' onClick={() => setOpenModalInativar(true)}/>
|
||||||
|
<BasicButton title='Cancelar' onClick={() => setOpenModalInativar(true)}/>
|
||||||
|
</ConfirmModalView>
|
||||||
|
</ConfirmModal>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
54
src/pages/administrative/faq/faqView.ts
Normal file
54
src/pages/administrative/faq/faqView.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import styled from 'styled-components'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const FaqView = styled.nav`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
|
||||||
|
.btn{
|
||||||
|
background: #254F7F;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: white;
|
||||||
|
width: 164px;
|
||||||
|
height: 40px;
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
.btn2{
|
||||||
|
background: #FFBC10;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: white;
|
||||||
|
width: 164px;
|
||||||
|
height: 40px;
|
||||||
|
border: none;
|
||||||
|
margin-left: 3px;
|
||||||
|
}
|
||||||
|
.buttons{
|
||||||
|
display: flex;
|
||||||
|
margin-top:50px ;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-self:flex-start ;
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
.title{
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-self:flex-start ;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-left: 19px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
.teste{
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin-left: 100px;
|
||||||
|
} */
|
||||||
|
|
||||||
|
|
||||||
|
`
|
||||||
@ -1,24 +1,81 @@
|
|||||||
|
import Box from '@mui/material/Box';
|
||||||
|
import Button from '@mui/material/Button';
|
||||||
|
import Modal from '@mui/material/Modal';
|
||||||
|
import Stack from '@mui/material/Stack';
|
||||||
import TextField from '@mui/material/TextField';
|
import TextField from '@mui/material/TextField';
|
||||||
|
import Typography from '@mui/material/Typography';
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import React from 'react'
|
import Image from 'next/image'
|
||||||
|
import Link from 'next/link'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
|
import React, { useEffect, useState } from 'react'
|
||||||
|
|
||||||
import AdministrativeHeader from '../../../components/administrativeHeader/AdministrativeHeader';
|
|
||||||
import FaqTable from '../../../components/administrativeTables/FaqTable';
|
import FaqTable from '../../../components/administrativeTables/FaqTable';
|
||||||
import BasicButton from '../../../components/buttons/basicButton/BasicButton';
|
import BasicButton from '../../../components/buttons/basicButton/BasicButton';
|
||||||
import CommonQuestionsCard from '../../../components/faqQuestionsCard/FaqQuestionsCard'
|
import FaqButton1 from '../../../components/buttons/faqButton/FaqButton1';
|
||||||
|
import FaqButton2 from '../../../components/buttons/faqButton/FaqButton2';
|
||||||
import Header from '../../../components/header/Header'
|
import Header from '../../../components/header/Header'
|
||||||
|
import PageTitle from '../../../components/pageTitle/PageTitle'
|
||||||
import { FaqView } from '../../../styles/layouts/commonQuestions/FaqView'
|
import { FaqView } from '../../../styles/layouts/commonQuestions/FaqView'
|
||||||
|
|
||||||
export default function commonQuestions() {
|
const style = {
|
||||||
|
position: 'absolute' as const,
|
||||||
|
top: '50%',
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translate(-50%, -50%)',
|
||||||
|
width: 900,
|
||||||
|
height: 500,
|
||||||
|
bgcolor: 'background.paper',
|
||||||
|
border: '2px solid #000',
|
||||||
|
boxShadow: 24,
|
||||||
|
p: 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Sidebar() {
|
||||||
|
|
||||||
|
const [open, setOpen] = React.useState(false);
|
||||||
|
const handleOpen = () => setOpen(true);
|
||||||
|
const handleClose = () => setOpen(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<FaqView>
|
||||||
<title>Smart Energia - FAQ</title>
|
<Header name=''/>
|
||||||
</Head>
|
|
||||||
<FaqView>
|
<PageTitle title='Perguntas Frequentes' subtitle='Perguntas Frequentes'/>
|
||||||
<Header name=''/>
|
|
||||||
<FaqTable />
|
<div className='buttons'>
|
||||||
</FaqView>
|
<button className='btn2' onClick={handleOpen}>Adicionar</button>
|
||||||
|
<button className='btn1' onClick={handleOpen}>Inativar</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<Modal
|
||||||
|
open={open}
|
||||||
|
onClose={handleClose}
|
||||||
|
aria-labelledby="modal-modal-title"
|
||||||
|
aria-describedby="modal-modal-description"
|
||||||
|
>
|
||||||
|
<Box sx={style}>
|
||||||
|
<h1>Adicionar/Editar Pergunta</h1>
|
||||||
|
<Typography sx={{color:'gray', fontSize:12}}variant="h5" gutterBottom component="div">
|
||||||
|
Adicionar/Editar Pergunta
|
||||||
|
</Typography>
|
||||||
|
<br />
|
||||||
|
<TextField id="outlined-basic" label="Pergunta" sx={{width:710, ml:8}} variant="outlined" /> <br /><br />
|
||||||
|
<TextField id="outlined-basic" label="Resposta" sx={{width:710, ml:8}} variant="outlined" />
|
||||||
|
<br /><br />
|
||||||
|
<FaqButton1 title='Cancelar' onClick={function (): void {
|
||||||
|
throw new Error('Function not implemented.');
|
||||||
|
} } />
|
||||||
|
<FaqButton2 title='Salvar' onClick={function (): void {
|
||||||
|
throw new Error('Function not implemented.');
|
||||||
|
} } />
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
</Modal>
|
||||||
|
<FaqTable />
|
||||||
|
|
||||||
|
</FaqView>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
139
src/pages/administrative/notification/index.tsx
Normal file
139
src/pages/administrative/notification/index.tsx
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
import CheckBoxIcon from '@mui/icons-material/CheckBox';
|
||||||
|
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
|
||||||
|
import RadioButtonCheckedIcon from '@mui/icons-material/RadioButtonChecked';
|
||||||
|
import RadioButtonUncheckedIcon from '@mui/icons-material/RadioButtonUnchecked';
|
||||||
|
import Autocomplete from '@mui/material/Autocomplete';
|
||||||
|
import Box from '@mui/material/Box';
|
||||||
|
import Checkbox from '@mui/material/Checkbox';
|
||||||
|
import FormControl from '@mui/material/FormControl';
|
||||||
|
import InputLabel from '@mui/material/InputLabel';
|
||||||
|
import MenuItem from '@mui/material/MenuItem';
|
||||||
|
import Modal from '@mui/material/Modal';
|
||||||
|
import Select, { SelectChangeEvent } from '@mui/material/Select';
|
||||||
|
import TextField from '@mui/material/TextField';
|
||||||
|
import Typography from '@mui/material/Typography';
|
||||||
|
import Head from 'next/head'
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
import NotificationsTable from '../../../components/administrativeTables/NotificationsTable'
|
||||||
|
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 PageTitle from '../../../components/pageTitle/PageTitle'
|
||||||
|
import api from '../../../services/api';
|
||||||
|
import { FaqView } from '../../../styles/layouts/commonQuestions/FaqView'
|
||||||
|
import { NotificationView } from './notificationView'
|
||||||
|
|
||||||
|
const style = {
|
||||||
|
position: 'absolute' as const,
|
||||||
|
top: '50%',
|
||||||
|
left: '50%',
|
||||||
|
transform: 'translate(-50%, -50%)',
|
||||||
|
width: 900,
|
||||||
|
height: 500,
|
||||||
|
bgcolor: 'background.paper',
|
||||||
|
border: '2px solid #000',
|
||||||
|
boxShadow: 24,
|
||||||
|
p: 4,
|
||||||
|
overflowY: 'scroll'
|
||||||
|
};
|
||||||
|
|
||||||
|
const icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
|
||||||
|
const checkedIcon = <CheckBoxIcon fontSize="small" />;
|
||||||
|
|
||||||
|
export default function commonQuestions() {
|
||||||
|
|
||||||
|
const [open, setOpen] = React.useState(false);
|
||||||
|
const handleOpen = () => setOpen(true);
|
||||||
|
const handleClose = () => setOpen(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FaqView>
|
||||||
|
<Head>
|
||||||
|
<title>Smart Energia - Notificações</title>
|
||||||
|
</Head>
|
||||||
|
<Header name=''/>
|
||||||
|
<PageTitle title='Notificações' subtitle='Notificações'/>
|
||||||
|
|
||||||
|
<div className='buttons'>
|
||||||
|
<button className='btn2' onClick={handleOpen}>Disparar nova</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<Modal
|
||||||
|
open={open}
|
||||||
|
onClose={handleClose}
|
||||||
|
aria-labelledby="modal-modal-title"
|
||||||
|
aria-describedby="modal-modal-description"
|
||||||
|
>
|
||||||
|
<Box sx={style}>
|
||||||
|
<h1>Disparar Notificações</h1>
|
||||||
|
<Typography sx={{color:'gray', fontSize:12}}variant="h5" gutterBottom component="div">
|
||||||
|
Pode ser que todas as notificaçõs demorem alguns minutos para estarem disponíveis</Typography>
|
||||||
|
<br />
|
||||||
|
<TextField id="outlined-basic" label="Título" sx={{width:700, ml:8}} variant="outlined" /> <br /><br />
|
||||||
|
|
||||||
|
<Autocomplete
|
||||||
|
multiple
|
||||||
|
id="checkboxes-tags-demo"
|
||||||
|
options={top100Films}
|
||||||
|
disableCloseOnSelect
|
||||||
|
getOptionLabel={(option) => option.title}
|
||||||
|
renderOption={(props, option, { selected }) => (
|
||||||
|
<li {...props}>
|
||||||
|
<Checkbox
|
||||||
|
icon={icon}
|
||||||
|
checkedIcon={checkedIcon}
|
||||||
|
style={{ marginRight: 8 }}
|
||||||
|
checked={selected}
|
||||||
|
/>
|
||||||
|
{option.title}
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
sx={{ml:8}}
|
||||||
|
style={{ width: 700 }}
|
||||||
|
renderInput={(params) => (
|
||||||
|
<TextField {...params} label="Corpo/Conteúdo da notificação" placeholder="Corpo/Conteúdo da notificação" />
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
<Checkbox sx={{ml:7}}
|
||||||
|
icon={<RadioButtonUncheckedIcon />}
|
||||||
|
checkedIcon={<RadioButtonCheckedIcon />}
|
||||||
|
/>
|
||||||
|
<Typography sx={{color:'#1976D2', fontSize:12, ml:12, mt:-3.7}} >
|
||||||
|
Disparar para todos os clientes</Typography>
|
||||||
|
<Checkbox sx={{ml:7}}
|
||||||
|
icon={<RadioButtonUncheckedIcon />}
|
||||||
|
checkedIcon={<RadioButtonCheckedIcon />}
|
||||||
|
/>
|
||||||
|
<Typography sx={{color:'#1976D2', fontSize:12, ml:12, mt:-3.7}} >
|
||||||
|
Disparar somente para alguns clientes</Typography>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FaqButton1 title='Cancelar' onClick={function (): void {
|
||||||
|
throw new Error('Function not implemented.');
|
||||||
|
} } />
|
||||||
|
<FaqButton2 title='Salvar' onClick={function (): void {
|
||||||
|
throw new Error('Function not implemented.');
|
||||||
|
} } />
|
||||||
|
</Box>
|
||||||
|
</Modal>
|
||||||
|
<NotificationsTable />
|
||||||
|
</FaqView>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const top100Films = [
|
||||||
|
{ title: 'The Shawshank Redemption', year: 1994 },
|
||||||
|
{ title: 'The Godfather', year: 1972 },
|
||||||
|
{ title: 'The Godfather: Part II', year: 1974 },
|
||||||
|
{ title: 'The Dark Knight', year: 2008 },
|
||||||
|
{ title: '12 Angry Men', year: 1957 },
|
||||||
|
{ title: "Schindler's List", year: 1993 },
|
||||||
|
{ title: 'Pulp Fiction', year: 1994 },
|
||||||
|
{
|
||||||
|
title: 'The Lord of the Rings: The Return of the King',
|
||||||
|
year: 2003,
|
||||||
|
},
|
||||||
|
];
|
||||||
83
src/pages/administrative/notification/notificationView.ts
Normal file
83
src/pages/administrative/notification/notificationView.ts
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
import styled from 'styled-components'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const NotificationView = styled.nav`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: calc(90% + 2rem);
|
||||||
|
line-height: 72px;
|
||||||
|
text-align: center;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-weight: 400;
|
||||||
|
font-size: 99.98%;
|
||||||
|
line-height: 21px;
|
||||||
|
text-align: center;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
|
||||||
|
color: #AAAAAA;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CommonQuestionsSection {
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
border: 1px solid #DDDDDD;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .modal{
|
||||||
|
display: flex;
|
||||||
|
justify-self: flex-end;
|
||||||
|
align-self: center;
|
||||||
|
margin-left: 100px;
|
||||||
|
|
||||||
|
} */
|
||||||
|
.btn2{
|
||||||
|
background: #254F7F;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: white;
|
||||||
|
width: 164px;
|
||||||
|
height: 45px;
|
||||||
|
border: none;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.btn1{
|
||||||
|
background:#FFBC10;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: white;
|
||||||
|
width: 164px;
|
||||||
|
height: 45px;
|
||||||
|
border: none;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-left: 6px;
|
||||||
|
}
|
||||||
|
.buttons{
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-self: flex-start;
|
||||||
|
margin-top: 45px;
|
||||||
|
margin-left: 16px;
|
||||||
|
|
||||||
|
}
|
||||||
|
.title{
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-self: flex-start;
|
||||||
|
margin-left: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`
|
||||||
@ -17,6 +17,10 @@ import Chart from '../components/graph/Chart'
|
|||||||
import { LineBarChart } from '../components/graph/LineBarChart'
|
import { LineBarChart } from '../components/graph/LineBarChart'
|
||||||
import { ConsumoEstimado } from '../services/consumoEstimado'
|
import { ConsumoEstimado } from '../services/consumoEstimado'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
|
import recoverUserInformation from '../services/auth'
|
||||||
|
import { parseCookies } from 'nookies'
|
||||||
|
import { GetServerSideProps } from 'next'
|
||||||
|
import getAPIClient from '../services/ssrApi'
|
||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
|
|
||||||
@ -53,9 +57,28 @@ export default function Dashboard() {
|
|||||||
</GraphCard>
|
</GraphCard>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<button onClick={() => {
|
||||||
|
const id = 1
|
||||||
|
console.log(recoverUserInformation(id))
|
||||||
|
}}></button>
|
||||||
</DashboardView>
|
</DashboardView>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||||
|
const apiClient = getAPIClient(ctx)
|
||||||
|
const { ['@smartAuth-token']: token } = parseCookies(ctx)
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
return {
|
||||||
|
redirect: {
|
||||||
|
destination: '/',
|
||||||
|
permanent: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,33 +1,38 @@
|
|||||||
import React, { useState } from 'react'
|
import FormControl from '@mui/material/FormControl';
|
||||||
|
import IconButton from '@mui/material/IconButton';
|
||||||
|
import InputAdornment from '@mui/material/InputAdornment';
|
||||||
|
import InputLabel from '@mui/material/InputLabel';
|
||||||
|
import OutlinedInput from '@mui/material/OutlinedInput';
|
||||||
|
import TextField from '@mui/material/TextField';
|
||||||
|
import Head from 'next/head';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import OutlinedInput from '@mui/material/OutlinedInput';
|
import React, { useContext, useState } from 'react'
|
||||||
import InputLabel from '@mui/material/InputLabel';
|
import { AiOutlineEye, AiOutlineEyeInvisible } from 'react-icons/ai';
|
||||||
import InputAdornment from '@mui/material/InputAdornment';
|
|
||||||
import LoginButton from '../components/buttons/loginButton/LoginButton';
|
import LoginButton from '../components/buttons/loginButton/LoginButton';
|
||||||
import FormControl from '@mui/material/FormControl';
|
import { AuthContext } from '../contexts/AuthContext';
|
||||||
import IconButton from '@mui/material/IconButton';
|
import { api } from '../services/api';
|
||||||
import TextField from '@mui/material/TextField';
|
import { LoginContainer, LoginView } from '../styles/layouts/login/LoginView';
|
||||||
|
import Dashboard from './dashboard';
|
||||||
import {AiOutlineEyeInvisible, AiOutlineEye} from 'react-icons/ai';
|
|
||||||
|
|
||||||
import { LoginView, LoginContainer } from '../styles/layouts/login/LoginView';
|
|
||||||
import Head from 'next/head';
|
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const [state, setstate]=useState(false);
|
const [state, setstate] = useState(false);
|
||||||
|
|
||||||
const [values, setValues] = React.useState({
|
const [values, setValues] = useState({
|
||||||
password: '',
|
password: '',
|
||||||
showPassword: false,
|
showPassword: false,
|
||||||
});
|
});
|
||||||
|
const [email, setEmail] = useState<string>()
|
||||||
|
const [password, setPassword] = useState<string>()
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const rota = router.pathname
|
const rota = router.pathname
|
||||||
|
|
||||||
const handleChange = (prop) => (event) => {
|
const handleChange = (prop) => (event) => {
|
||||||
setValues({ ...values, [prop]: event.target.value });
|
setValues({ ...values, [prop]: event.target.value });
|
||||||
|
setPassword(event.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClickShowPassword = () => {
|
const handleClickShowPassword = () => {
|
||||||
@ -41,6 +46,12 @@ export default function Home() {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { signIn } = useContext(AuthContext)
|
||||||
|
|
||||||
|
async function handleSignIn() {
|
||||||
|
await signIn({email, password})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LoginView auth={rota} >
|
<LoginView auth={rota} >
|
||||||
<Head>
|
<Head>
|
||||||
@ -48,14 +59,16 @@ export default function Home() {
|
|||||||
</Head>
|
</Head>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Image src='/assets/marca1.svg' width={520} height={350} />
|
<Image src='/assets/marca1.svg' width={520} height={350} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoginContainer>
|
<LoginContainer>
|
||||||
<h1>Bem-Vindo</h1>
|
<h1>Bem-Vindo</h1>
|
||||||
<h2>Estratégias Inteligentes em<br /> Gestão de Energia</h2>
|
<h2>Estratégias Inteligentes em<br /> Gestão de Energia</h2>
|
||||||
|
|
||||||
<TextField id="outlined-basic" sx={{ m: 1, width: '90%' }}label="Login" variant="outlined" />
|
<TextField id="outlined-basic" sx={{ m: 1, width: '90%' }} label="Login" variant="outlined" onChange={value => {
|
||||||
|
setEmail(value.target.value)
|
||||||
|
}}/>
|
||||||
<FormControl sx={{ m: 1, width: '90%' }} variant="outlined">
|
<FormControl sx={{ m: 1, width: '90%' }} variant="outlined">
|
||||||
<InputLabel htmlFor="outlined-adornment-password">Password</InputLabel>
|
<InputLabel htmlFor="outlined-adornment-password">Password</InputLabel>
|
||||||
<OutlinedInput
|
<OutlinedInput
|
||||||
@ -80,14 +93,13 @@ export default function Home() {
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
<Link href='verifyEmail' >Esqueceu a senha ?</Link>
|
<Link href='verifyEmail' >Esqueceu a senha ?</Link>
|
||||||
|
|
||||||
<LoginButton title='ENTRAR' link />
|
<LoginButton title='ENTRAR' onClick={() => handleSignIn()}/>
|
||||||
|
|
||||||
<fieldset className="line">
|
<fieldset className="line">
|
||||||
<legend className="text">Ou</legend>
|
<legend className="text">Ou</legend>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<p><a href='tel:+55(41) 3012-5900' >+55(41) 3012-5900</a><br/><a href='https://www.energiasmart.com.br' target="_blank" rel="noreferrer" >www.energiasmart.com.br</a></p>
|
<p><a href='tel:+55(41) 3012-5900' >+55(41) 3012-5900</a><br/><a href='https://www.energiasmart.com.br' target="_blank" rel="noreferrer" >www.energiasmart.com.br</a></p>
|
||||||
|
|
||||||
</LoginContainer>
|
</LoginContainer>
|
||||||
|
|
||||||
</LoginView>
|
</LoginView>
|
||||||
|
|||||||
@ -34,7 +34,7 @@ export default function region() {
|
|||||||
function handleGreen(minimo, mi, ma, maximo) {
|
function handleGreen(minimo, mi, ma, maximo) {
|
||||||
if (minimo - mi >= 100 && minimo - mi < 200) {
|
if (minimo - mi >= 100 && minimo - mi < 200) {
|
||||||
return 'green'
|
return 'green'
|
||||||
} else if ( mi*2 >= 200 && mi*2 <250 ) {
|
} else if ( mi*2 >= 200 && mi*2 < 250 ) {
|
||||||
return'dullGreen'
|
return'dullGreen'
|
||||||
} else if ( (ma-mi)/2 >=250 && (ma-mi)/2 < 300 ) {
|
} else if ( (ma-mi)/2 >=250 && (ma-mi)/2 < 300 ) {
|
||||||
return 'white'
|
return 'white'
|
||||||
@ -195,7 +195,7 @@ export default function region() {
|
|||||||
|
|
||||||
<RenderIf isTrue={page==='perMouth'? true : false}>
|
<RenderIf isTrue={page==='perMouth'? true : false}>
|
||||||
<GoBack onClick={() => setPage('table')}>{'< voltar para tabela PLD'}</GoBack>
|
<GoBack onClick={() => setPage('table')}>{'< voltar para tabela PLD'}</GoBack>
|
||||||
<PageTitle title='Resumo PLD - Mensal' subtitle=''/>
|
<PageTitle title='Resumo PLD - Diários' subtitle=''/>
|
||||||
<PldGraphView>
|
<PldGraphView>
|
||||||
<section className='toolsbar'>
|
<section className='toolsbar'>
|
||||||
<div className='select'>
|
<div className='select'>
|
||||||
|
|||||||
@ -56,12 +56,14 @@ export default function Telemetria() {
|
|||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
<MenuItem value="">
|
<MenuItem value="">
|
||||||
<em>None</em>
|
<em>Nenhum</em>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem value="">07/09/2021</MenuItem>
|
|
||||||
<MenuItem value={10}>Filial 3</MenuItem>
|
<MenuItem value={10}>Unidade 1</MenuItem>
|
||||||
<MenuItem value={20}>Twenty</MenuItem>
|
<MenuItem value={20}>Unidade 2</MenuItem>
|
||||||
<MenuItem value={30}>Thirty</MenuItem>
|
<MenuItem value={30}>Unidade 3</MenuItem>
|
||||||
|
<MenuItem value={30}>Unidade 4</MenuItem>
|
||||||
|
<MenuItem value={30}>Unidade 5</MenuItem>
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</div>
|
</div>
|
||||||
@ -79,12 +81,13 @@ export default function Telemetria() {
|
|||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
<MenuItem value="">
|
<MenuItem value="">
|
||||||
<em>None</em>
|
<em>Nenhum</em>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem value="">07/09/2021</MenuItem>
|
<MenuItem value={10}>20/05/2022</MenuItem>
|
||||||
<MenuItem value={10}>Filial 3</MenuItem>
|
<MenuItem value={20}>10/06/2022</MenuItem>
|
||||||
<MenuItem value={20}>Twenty</MenuItem>
|
<MenuItem value={30}>05/06/2021</MenuItem>
|
||||||
<MenuItem value={30}>Thirty</MenuItem>
|
<MenuItem value={30}>05/06/2021</MenuItem>
|
||||||
|
<MenuItem value={30}>05/06/2021</MenuItem>
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</div>
|
</div>
|
||||||
@ -102,12 +105,13 @@ export default function Telemetria() {
|
|||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
<MenuItem value="">
|
<MenuItem value="">
|
||||||
<em>None</em>
|
<em>Nenhum</em>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem value="">07/09/2021</MenuItem>
|
<MenuItem value={10}>20/05/2022</MenuItem>
|
||||||
<MenuItem value={10}>Filial 3</MenuItem>
|
<MenuItem value={20}>10/06/2022</MenuItem>
|
||||||
<MenuItem value={20}>Twenty</MenuItem>
|
<MenuItem value={30}>05/06/2021</MenuItem>
|
||||||
<MenuItem value={30}>Thirty</MenuItem>
|
<MenuItem value={30}>05/06/2021</MenuItem>
|
||||||
|
<MenuItem value={30}>05/06/2021</MenuItem>
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</div>
|
</div>
|
||||||
@ -125,7 +129,7 @@ export default function Telemetria() {
|
|||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
<MenuItem value="">
|
<MenuItem value="">
|
||||||
<em>None</em>
|
<em>Nenhum</em>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem value="">07/09/2021</MenuItem>
|
<MenuItem value="">07/09/2021</MenuItem>
|
||||||
<MenuItem value={10}>Filial 3</MenuItem>
|
<MenuItem value={10}>Filial 3</MenuItem>
|
||||||
|
|||||||
@ -1,22 +1,3 @@
|
|||||||
import axios, { AxiosRequestConfig } from "axios";
|
import getAPIClient from "./ssrApi";
|
||||||
import { getToken } from "./auth";
|
|
||||||
|
|
||||||
const api = axios.create({
|
export const api = getAPIClient()
|
||||||
// baseURL: "http://192.168.0.132:3000/",
|
|
||||||
baseURL: "http://localhost:3000/",
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
api.interceptors.request.use(config => {
|
|
||||||
const token = getToken();
|
|
||||||
// console.log(token)
|
|
||||||
if (config.headers === undefined && token === undefined) {
|
|
||||||
config.headers = {Authorization: `Bearer ${token}`};
|
|
||||||
}
|
|
||||||
return config;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
export default api
|
|
||||||
|
|||||||
@ -1,10 +1,74 @@
|
|||||||
export const TOKEN_KEY = "@test";
|
import api from "./api";
|
||||||
export const isAuthenticated = () => localStorage.getItem(TOKEN_KEY) !== null;
|
|
||||||
// export const isAuthenticated = true;
|
export const TOKEN_KEY = "@smartAuth-token";
|
||||||
export const getToken = () => localStorage.getItem(TOKEN_KEY);
|
|
||||||
export const login = (token: any) => {
|
|
||||||
localStorage.setItem(TOKEN_KEY, token);
|
|
||||||
};
|
|
||||||
export const logout = () => {
|
export const logout = () => {
|
||||||
localStorage.removeItem(TOKEN_KEY);
|
localStorage.removeItem(TOKEN_KEY);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface SignInRequestData {
|
||||||
|
email: string,
|
||||||
|
password: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserObjectType = {
|
||||||
|
name: string;
|
||||||
|
email: string;
|
||||||
|
client_id: number
|
||||||
|
id: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function signInRequest(data: SignInRequestData) {
|
||||||
|
let user: UserObjectType, token: string
|
||||||
|
|
||||||
|
await api.post('/auth/login', {
|
||||||
|
"email": data.email,
|
||||||
|
"password": data.password,
|
||||||
|
"device_name": "test"
|
||||||
|
}).then(res => {
|
||||||
|
user = {
|
||||||
|
name: res.data.user.name,
|
||||||
|
email: res.data.user.email,
|
||||||
|
client_id: res.data.user.client_id,
|
||||||
|
id: res.data.user.id
|
||||||
|
}
|
||||||
|
token = res.data.token
|
||||||
|
}).catch(res => {
|
||||||
|
console.log(res)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
token: token,
|
||||||
|
user: {
|
||||||
|
name: user.name,
|
||||||
|
email: user.email,
|
||||||
|
client_id: user.client_id,
|
||||||
|
id: user.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function recoverUserInformation(id) {
|
||||||
|
let user: UserObjectType
|
||||||
|
|
||||||
|
await api.get(`/user/${id}`).then(res => {
|
||||||
|
console.log(res)
|
||||||
|
user = {
|
||||||
|
name: res.data.user.name,
|
||||||
|
email: res.data.user.email,
|
||||||
|
client_id: res.data.user.client_id,
|
||||||
|
id: res.data.user.id
|
||||||
|
}
|
||||||
|
}).catch(res => {
|
||||||
|
console.log(res)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
user: {
|
||||||
|
name: user?.name,
|
||||||
|
email: user?.email,
|
||||||
|
client_id: user?.client_id,
|
||||||
|
id: user?.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
32
src/services/ssrApi.ts
Normal file
32
src/services/ssrApi.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import axios, { AxiosRequestConfig } from "axios";
|
||||||
|
import * as cookie from 'cookie';
|
||||||
|
import * as express from 'express';
|
||||||
|
import * as next from 'next';
|
||||||
|
import { parseCookies } from "nookies";
|
||||||
|
|
||||||
|
export default function getAPIClient(ctx?: Pick<next.NextPageContext, 'req'> | {
|
||||||
|
req: next.NextApiRequest;
|
||||||
|
} | {
|
||||||
|
req: express.Request;
|
||||||
|
} | null | undefined) {
|
||||||
|
|
||||||
|
const { '@smartAuth-token': token } = parseCookies()
|
||||||
|
|
||||||
|
const api = axios.create({
|
||||||
|
baseURL: "https://smart-energia-api.herokuapp.com/api",
|
||||||
|
});
|
||||||
|
|
||||||
|
api.interceptors.request.use(config => {
|
||||||
|
// console.log(config)
|
||||||
|
// config.headers = {Authorization: `Bearer ${token}`};
|
||||||
|
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (token) {
|
||||||
|
api.defaults.headers['Authorization'] = `Bearer ${token}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return api
|
||||||
|
}
|
||||||
@ -10,6 +10,10 @@ export const GlobalStyle = createGlobalStyle`
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
padding: 2.5rem;
|
padding: 2.5rem;
|
||||||
|
|
||||||
|
button {
|
||||||
|
cursor: pointer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
|
|||||||
@ -19,6 +19,30 @@ export const ClientsView = styled.main`
|
|||||||
margin: 45px 0 22px 0;
|
margin: 45px 0 22px 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.btn2{
|
||||||
|
background: #254F7F;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: white;
|
||||||
|
width: 164px;
|
||||||
|
height: 48px;
|
||||||
|
border: none;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.btn1{
|
||||||
|
background:#FFBC10;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: white;
|
||||||
|
width: 164px;
|
||||||
|
height: 48px;
|
||||||
|
border: none;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
.buttons{
|
||||||
|
display: flex;
|
||||||
|
margin-top: 40px;
|
||||||
|
|
||||||
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
export const ClientsModalView = styled.main`
|
export const ClientsModalView = styled.main`
|
||||||
@ -49,4 +73,6 @@ export const ConfirmModalView = styled.main`
|
|||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|||||||
60
src/styles/layouts/clientsAdmin/clientsAdminView.ts
Normal file
60
src/styles/layouts/clientsAdmin/clientsAdminView.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import styled from 'styled-components'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const NotificationView = styled.nav`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
|
||||||
|
.btn{
|
||||||
|
background: #254F7F;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: white;
|
||||||
|
width: 164px;
|
||||||
|
height: 40px;
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
.btn2{
|
||||||
|
background: #FFBC10;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: white;
|
||||||
|
width: 164px;
|
||||||
|
height: 40px;
|
||||||
|
border: none;
|
||||||
|
margin-left: 3px;
|
||||||
|
}
|
||||||
|
.buttons{
|
||||||
|
display: flex;
|
||||||
|
margin-top:50px ;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-self:flex-start ;
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
.title{
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-self:flex-start ;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-left: 19px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
.teste{
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin-left: 100px;
|
||||||
|
} */
|
||||||
|
.text1{
|
||||||
|
margin-left: 70px;
|
||||||
|
}
|
||||||
|
.header{
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
`
|
||||||
@ -33,4 +33,40 @@ export const FaqView = styled.main`
|
|||||||
hr {
|
hr {
|
||||||
border: 1px solid #DDDDDD;
|
border: 1px solid #DDDDDD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* .modal{
|
||||||
|
display: flex;
|
||||||
|
justify-self: flex-end;
|
||||||
|
align-self: center;
|
||||||
|
margin-left: 100px;
|
||||||
|
|
||||||
|
} */
|
||||||
|
.btn2{
|
||||||
|
background: #254F7F;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: white;
|
||||||
|
width: 164px;
|
||||||
|
height: 45px;
|
||||||
|
border: none;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.btn1{
|
||||||
|
background:#FFBC10;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: white;
|
||||||
|
width: 164px;
|
||||||
|
height: 45px;
|
||||||
|
border: none;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-left: 6px;
|
||||||
|
}
|
||||||
|
.buttons{
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-self: flex-start;
|
||||||
|
margin-top: 45px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|||||||
81
yarn.lock
81
yarn.lock
@ -1393,10 +1393,49 @@
|
|||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
|
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
|
||||||
|
|
||||||
|
"@types/body-parser@*":
|
||||||
|
version "1.19.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.2.tgz#aea2059e28b7658639081347ac4fab3de166e6f0"
|
||||||
|
dependencies:
|
||||||
|
"@types/connect" "*"
|
||||||
|
"@types/node" "*"
|
||||||
|
|
||||||
"@types/chartjs@^0.0.31":
|
"@types/chartjs@^0.0.31":
|
||||||
version "0.0.31"
|
version "0.0.31"
|
||||||
resolved "https://registry.npmjs.org/@types/chartjs/-/chartjs-0.0.31.tgz"
|
resolved "https://registry.npmjs.org/@types/chartjs/-/chartjs-0.0.31.tgz"
|
||||||
|
|
||||||
|
"@types/connect@*":
|
||||||
|
version "3.4.35"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1"
|
||||||
|
dependencies:
|
||||||
|
"@types/node" "*"
|
||||||
|
|
||||||
|
"@types/cookies@^0.7.7":
|
||||||
|
version "0.7.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/cookies/-/cookies-0.7.7.tgz#7a92453d1d16389c05a5301eef566f34946cfd81"
|
||||||
|
dependencies:
|
||||||
|
"@types/connect" "*"
|
||||||
|
"@types/express" "*"
|
||||||
|
"@types/keygrip" "*"
|
||||||
|
"@types/node" "*"
|
||||||
|
|
||||||
|
"@types/express-serve-static-core@^4.17.18":
|
||||||
|
version "4.17.28"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.28.tgz#c47def9f34ec81dc6328d0b1b5303d1ec98d86b8"
|
||||||
|
dependencies:
|
||||||
|
"@types/node" "*"
|
||||||
|
"@types/qs" "*"
|
||||||
|
"@types/range-parser" "*"
|
||||||
|
|
||||||
|
"@types/express@*":
|
||||||
|
version "4.17.13"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.13.tgz#a76e2995728999bab51a33fabce1d705a3709034"
|
||||||
|
dependencies:
|
||||||
|
"@types/body-parser" "*"
|
||||||
|
"@types/express-serve-static-core" "^4.17.18"
|
||||||
|
"@types/qs" "*"
|
||||||
|
"@types/serve-static" "*"
|
||||||
|
|
||||||
"@types/faker@5.5.3":
|
"@types/faker@5.5.3":
|
||||||
version "5.5.3"
|
version "5.5.3"
|
||||||
resolved "https://registry.npmjs.org/@types/faker/-/faker-5.5.3.tgz"
|
resolved "https://registry.npmjs.org/@types/faker/-/faker-5.5.3.tgz"
|
||||||
@ -1416,6 +1455,18 @@
|
|||||||
version "0.0.29"
|
version "0.0.29"
|
||||||
resolved "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz"
|
resolved "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz"
|
||||||
|
|
||||||
|
"@types/keygrip@*":
|
||||||
|
version "1.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/keygrip/-/keygrip-1.0.2.tgz#513abfd256d7ad0bf1ee1873606317b33b1b2a72"
|
||||||
|
|
||||||
|
"@types/mime@^1":
|
||||||
|
version "1.3.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a"
|
||||||
|
|
||||||
|
"@types/node@*":
|
||||||
|
version "17.0.42"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.42.tgz#d7e8f22700efc94d125103075c074396b5f41f9b"
|
||||||
|
|
||||||
"@types/node@^17.0.31":
|
"@types/node@^17.0.31":
|
||||||
version "17.0.31"
|
version "17.0.31"
|
||||||
resolved "https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz"
|
resolved "https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz"
|
||||||
@ -1432,6 +1483,14 @@
|
|||||||
version "15.7.5"
|
version "15.7.5"
|
||||||
resolved "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz"
|
resolved "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz"
|
||||||
|
|
||||||
|
"@types/qs@*":
|
||||||
|
version "6.9.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb"
|
||||||
|
|
||||||
|
"@types/range-parser@*":
|
||||||
|
version "1.2.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc"
|
||||||
|
|
||||||
"@types/react-csv@^1.1.2":
|
"@types/react-csv@^1.1.2":
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/@types/react-csv/-/react-csv-1.1.2.tgz#a5694d7e5cbf4bc1d4baa178a3fa7ac3466ea8c5"
|
resolved "https://registry.yarnpkg.com/@types/react-csv/-/react-csv-1.1.2.tgz#a5694d7e5cbf4bc1d4baa178a3fa7ac3466ea8c5"
|
||||||
@ -1462,6 +1521,13 @@
|
|||||||
version "0.16.2"
|
version "0.16.2"
|
||||||
resolved "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz"
|
resolved "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz"
|
||||||
|
|
||||||
|
"@types/serve-static@*":
|
||||||
|
version "1.13.10"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.10.tgz#f5e0ce8797d2d7cc5ebeda48a52c96c4fa47a8d9"
|
||||||
|
dependencies:
|
||||||
|
"@types/mime" "^1"
|
||||||
|
"@types/node" "*"
|
||||||
|
|
||||||
"@types/styled-components@^5.1.25":
|
"@types/styled-components@^5.1.25":
|
||||||
version "5.1.25"
|
version "5.1.25"
|
||||||
resolved "https://registry.npmjs.org/@types/styled-components/-/styled-components-5.1.25.tgz"
|
resolved "https://registry.npmjs.org/@types/styled-components/-/styled-components-5.1.25.tgz"
|
||||||
@ -2001,6 +2067,10 @@ convert-source-map@^1.5.0, convert-source-map@^1.7.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
safe-buffer "~5.1.1"
|
safe-buffer "~5.1.1"
|
||||||
|
|
||||||
|
cookie@^0.4.1:
|
||||||
|
version "0.4.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432"
|
||||||
|
|
||||||
core-js-compat@^3.21.0, core-js-compat@^3.22.1:
|
core-js-compat@^3.21.0, core-js-compat@^3.22.1:
|
||||||
version "3.22.5"
|
version "3.22.5"
|
||||||
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.22.5.tgz#7fffa1d20cb18405bd22756ca1353c6f1a0e8614"
|
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.22.5.tgz#7fffa1d20cb18405bd22756ca1353c6f1a0e8614"
|
||||||
@ -3520,6 +3590,13 @@ node-releases@^2.0.3:
|
|||||||
version "2.0.4"
|
version "2.0.4"
|
||||||
resolved "https://registry.npmjs.org/node-releases/-/node-releases-2.0.4.tgz"
|
resolved "https://registry.npmjs.org/node-releases/-/node-releases-2.0.4.tgz"
|
||||||
|
|
||||||
|
nookies@^2.5.2:
|
||||||
|
version "2.5.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/nookies/-/nookies-2.5.2.tgz#cc55547efa982d013a21475bd0db0c02c1b35b27"
|
||||||
|
dependencies:
|
||||||
|
cookie "^0.4.1"
|
||||||
|
set-cookie-parser "^2.4.6"
|
||||||
|
|
||||||
nopt@^5.0.0:
|
nopt@^5.0.0:
|
||||||
version "5.0.0"
|
version "5.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/nopt/-/nopt-5.0.0.tgz#530942bb58a512fccafe53fe210f13a25355dc88"
|
resolved "https://registry.yarnpkg.com/nopt/-/nopt-5.0.0.tgz#530942bb58a512fccafe53fe210f13a25355dc88"
|
||||||
@ -4210,6 +4287,10 @@ set-blocking@^2.0.0:
|
|||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
|
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
|
||||||
|
|
||||||
|
set-cookie-parser@^2.4.6:
|
||||||
|
version "2.5.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/set-cookie-parser/-/set-cookie-parser-2.5.0.tgz#96b59525e1362c94335c3c761100bb6e8f2da4b0"
|
||||||
|
|
||||||
shallowequal@^1.1.0:
|
shallowequal@^1.1.0:
|
||||||
version "1.1.0"
|
version "1.1.0"
|
||||||
resolved "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz"
|
resolved "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user