diff --git a/package.json b/package.json index cf6bbec..c60b200 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@date-io/date-fns": "^2.14.0", "@emotion/react": "^11.9.0", "@emotion/styled": "^11.8.1", + "@hookform/resolvers": "^2.9.1", "@material-ui/core": "^4.12.4", "@material-ui/icons": "^4.11.3", "@mui/icons-material": "^5.8.2", @@ -28,6 +29,7 @@ "@mui/x-date-pickers": "^5.0.0-alpha.3", "@tinymce/tinymce-react": "^4.1.0", "@types/react-csv": "^1.1.2", + "@types/yup": "^0.29.14", "@typescript-eslint/eslint-plugin": "^5.22.0", "@typescript-eslint/parser": "^5.22.0", "axios": "^0.27.2", @@ -49,9 +51,12 @@ "react-chartjs-2": "^4.1.0", "react-csv": "^2.2.2", "react-dom": "18.1.0", + "react-hook-form": "^7.32.2", "react-icons": "^4.3.1", + "react-input-mask": "^2.0.4", "styled-components": "^5.3.5", - "tinymce": "^6.0.3" + "tinymce": "^6.0.3", + "yup": "^0.32.11" }, "devDependencies": { "@babel/preset-env": "^7.17.10", diff --git a/public/assets/marca1.png b/public/assets/marca1.png new file mode 100644 index 0000000..6eada8c Binary files /dev/null and b/public/assets/marca1.png differ diff --git a/public/assets/marca1.svg b/public/assets/marca1.svg deleted file mode 100644 index 1af4cd6..0000000 --- a/public/assets/marca1.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/components/NotificationQuestionsCard/NotificationQuestionsCard.tsx b/src/components/NotificationQuestionsCard/NotificationQuestionsCard.tsx index b2e4438..9938a23 100644 --- a/src/components/NotificationQuestionsCard/NotificationQuestionsCard.tsx +++ b/src/components/NotificationQuestionsCard/NotificationQuestionsCard.tsx @@ -13,7 +13,7 @@ export default function NotificationQuestionsCard({title, body}: CommonsQuestion const [ showCardBody, setShowCardBody ] = useState(false) return ( - + setShowCardBody(!showCardBody)}>

{title}

setShowCardBody(!showCardBody)} /> diff --git a/src/components/NotificationQuestionsCard/NotificationQuestionsCardView.ts b/src/components/NotificationQuestionsCard/NotificationQuestionsCardView.ts index 91d16dd..4e12edb 100644 --- a/src/components/NotificationQuestionsCard/NotificationQuestionsCardView.ts +++ b/src/components/NotificationQuestionsCard/NotificationQuestionsCardView.ts @@ -13,6 +13,7 @@ export const FaqQuestionsCardHeader = styled.div` margin-top: 53px; width: 100%; + cursor: pointer; img { cursor: pointer; diff --git a/src/components/faqQuestionsCard/FaqQuestionsCard.tsx b/src/components/faqQuestionsCard/FaqQuestionsCard.tsx index 5ceda20..3bdd341 100644 --- a/src/components/faqQuestionsCard/FaqQuestionsCard.tsx +++ b/src/components/faqQuestionsCard/FaqQuestionsCard.tsx @@ -13,9 +13,10 @@ export default function CommonsQuestionsCard({question, answer}: CommonsQuestion const [ showCardBody, setShowCardBody ] = useState(false) return ( - - -

{question}

+ setShowCardBody(!showCardBody)}> + +

{question}

+ setShowCardBody(!showCardBody)} />
diff --git a/src/components/faqQuestionsCard/FaqQuestionsCardView.ts b/src/components/faqQuestionsCard/FaqQuestionsCardView.ts index 91d16dd..4e12edb 100644 --- a/src/components/faqQuestionsCard/FaqQuestionsCardView.ts +++ b/src/components/faqQuestionsCard/FaqQuestionsCardView.ts @@ -13,6 +13,7 @@ export const FaqQuestionsCardHeader = styled.div` margin-top: 53px; width: 100%; + cursor: pointer; img { cursor: pointer; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 6229b84..614c0e7 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -8,23 +8,44 @@ import Head from 'next/head'; import Image from 'next/image'; import Link from 'next/link'; import { useRouter } from 'next/router' -import React, { useContext, useState } from 'react' +import React, { useContext, useState, useEffect,useCallback } from 'react' import { AiOutlineEye, AiOutlineEyeInvisible } from 'react-icons/ai'; +import * as yup from 'yup'; +import { yupResolver } from '@hookform/resolvers/yup'; +import { useForm } from 'react-hook-form'; +import RenderIf from '../utils/renderIf'; +import Snackbar from '@mui/material/Snackbar'; import LoginButton from '../components/buttons/loginButton/LoginButton'; import { AuthContext } from '../contexts/AuthContext'; import { api } from '../services/api'; import { LoginContainer, LoginView } from '../styles/layouts/login/LoginView'; import Dashboard from './dashboard'; +import MuiAlert, { AlertProps } from '@mui/material/Alert'; + + +const Alert = React.forwardRef(function Alert( + props, + ref, +) { + return ; +}); + export default function Home() { + const [openSnackSuccess, setOpenSnackSuccess] = useState(false); + const [openSnackError, setOpenSnackError] = useState(false); + const [openSnackSuccessDelete, setOpenSnackSuccessDelete] = useState(false); + const [openSnackErrorDelete, setOpenSnackErrorDelete] = useState(false); + const [state, setstate] = useState(false); const [values, setValues] = useState({ - password: '', + + password: null, showPassword: false, }); - const [email, setEmail] = useState() + const [email, setEmail] = useState("") const [password, setPassword] = useState() const router = useRouter() @@ -42,6 +63,7 @@ export default function Home() { }); }; + const handleMouseDownPassword = (event) => { event.preventDefault(); }; @@ -49,25 +71,69 @@ export default function Home() { const { signIn } = useContext(AuthContext) async function handleSignIn() { - await signIn({email, password}) + if (email === "" || password === ""){ + setOpenSnackError(true) + }else{ + await signIn({email, password}).then(res => {console.log('')}).catch(res => setOpenSnackError(true)) + } } + const handleCloseSnack = (event?: React.SyntheticEvent | Event, reason?: string) => { + if (reason === 'clickaway') { + return; + } + + setOpenSnackError(false); + setOpenSnackSuccess(false); + }; + + useEffect(() => { + setValues({ + password: "", + showPassword: false, + }); + setEmail("") + }, [rota]) + return ( - + Smart Energia + + + notificação cadastrada com sucesso! + + + + + Prencha os Campos corretamente! + + + {/* + + notificação excluida com sucesso! + + */} + {/* + + Notificação não excluida! + + */}
- +

Bem-Vindo

Estratégias Inteligentes em
Gestão de Energia

- { - setEmail(value.target.value) + + { + setEmail(value.target.value) }}/> Password diff --git a/src/pages/industryInfo.tsx b/src/pages/industryInfo.tsx index 8ed8d5f..6e6da73 100644 --- a/src/pages/industryInfo.tsx +++ b/src/pages/industryInfo.tsx @@ -13,7 +13,7 @@ export default function industryInfo() {
- +
diff --git a/src/pages/notifications.tsx b/src/pages/notifications.tsx index 2f94d6c..9a318af 100644 --- a/src/pages/notifications.tsx +++ b/src/pages/notifications.tsx @@ -16,7 +16,7 @@ export default function Notifications({notificationData}: any) { Smart Energia - Notificações
- +

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

{ diff --git a/src/pages/verifyEmail.tsx b/src/pages/verifyEmail.tsx index b4612bc..e26c3d0 100644 --- a/src/pages/verifyEmail.tsx +++ b/src/pages/verifyEmail.tsx @@ -46,7 +46,7 @@ export default function VerifyEmail() { Smart Energia - Verificar Email - + router.push('/')} />

Bem-Vindo

Estratégias Inteligentes em
Gestão de Energia

diff --git a/src/styles/layouts/forgotPassword/verifyEmail.ts b/src/styles/layouts/forgotPassword/verifyEmail.ts index d6ca2ab..8891e62 100644 --- a/src/styles/layouts/forgotPassword/verifyEmail.ts +++ b/src/styles/layouts/forgotPassword/verifyEmail.ts @@ -4,7 +4,7 @@ import styled from 'styled-components'; export const VerifyEmailView = styled.main<{auth: string}>` display: flex; display: ${props => props.auth == '/verifyEmail'? null : 'none'}; - justify-content: flex-end; + justify-content:center; align-items: center; width: 100%; diff --git a/yarn.lock b/yarn.lock index ed043f2..388eeb8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -771,6 +771,13 @@ dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.15.4": + version "7.18.3" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.18.3.tgz#c7b654b57f6f63cf7f8b418ac9ca04408c4579f4" + integrity sha512-38Y8f7YUhce/K7RMwTp7m0uCumpv9hZkitCbBClqQIow1qSbCvGkcegKOXpEWCQLfWmevgRiWokZ1GkpfhbZug== + dependencies: + regenerator-runtime "^0.13.4" + "@babel/template@^7.16.7": version "7.16.7" resolved "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz" @@ -944,6 +951,11 @@ version "1.1.3" resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6" +"@hookform/resolvers@^2.9.1": + version "2.9.1" + resolved "https://registry.yarnpkg.com/@hookform/resolvers/-/resolvers-2.9.1.tgz#59121e38d8fc95d2fd1f41c9631393cd21e10b65" + integrity sha512-80lyFFcExEB7A09PFnl8k7A3obQyDF6MyO/FThtwetk+MTedYMs08Aqf7mgWnOawFGyz5QF+TZXJSYiIZW2tEg== + "@humanwhocodes/config-array@^0.9.2": version "0.9.5" resolved "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.5.tgz" @@ -1459,6 +1471,11 @@ version "1.0.2" resolved "https://registry.yarnpkg.com/@types/keygrip/-/keygrip-1.0.2.tgz#513abfd256d7ad0bf1ee1873606317b33b1b2a72" +"@types/lodash@^4.14.175": + version "4.14.182" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.182.tgz#05301a4d5e62963227eaafe0ce04dd77c54ea5c2" + integrity sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q== + "@types/mime@^1": version "1.3.2" resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a" @@ -1536,6 +1553,11 @@ "@types/react" "*" csstype "^3.0.2" +"@types/yup@^0.29.14": + version "0.29.14" + resolved "https://registry.yarnpkg.com/@types/yup/-/yup-0.29.14.tgz#754f1dccedcc66fc2bbe290c27f5323b407ceb00" + integrity sha512-Ynb/CjHhE/Xp/4bhHmQC4U1Ox+I2OpfRYF3dnNgQqn1cHa6LK3H1wJMNPT02tSVZA6FYuXE2ITORfbnb6zBCSA== + "@typescript-eslint/eslint-plugin@^5.22.0": version "5.22.0" resolved "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.22.0.tgz" @@ -2921,6 +2943,13 @@ internal-slot@^1.0.3: has "^1.0.3" side-channel "^1.0.4" +invariant@^2.2.4: + version "2.2.4" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" + integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== + dependencies: + loose-envify "^1.0.0" + ip-regex@^4.1.0: version "4.3.0" resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-4.3.0.tgz#687275ab0f57fa76978ff8f4dddc8a23d5990db5" @@ -3344,6 +3373,11 @@ locate-path@^2.0.0: p-locate "^2.0.0" path-exists "^3.0.0" +lodash-es@^4.17.21: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee" + integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw== + lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" @@ -3356,7 +3390,7 @@ lodash.once@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" -lodash@^4.17.11: +lodash@^4.17.11, lodash@^4.17.21: version "4.17.21" resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz" @@ -3369,7 +3403,7 @@ log-update@^4.0.0: slice-ansi "^4.0.0" wrap-ansi "^6.2.0" -loose-envify@^1.1.0, loose-envify@^1.4.0: +loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0: version "1.4.0" resolved "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz" dependencies: @@ -3537,6 +3571,11 @@ mute-stream@~0.0.4: version "0.0.8" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" +nanoclone@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/nanoclone/-/nanoclone-0.2.1.tgz#dd4090f8f1a110d26bb32c49ed2f5b9235209ed4" + integrity sha512-wynEP02LmIbLpcYw8uBKpcfF6dmg2vcpKqxeH5UcoKEYdExslsdUA4ugFauuaeYdTB76ez6gJW8XAZ6CgkXYxA== + nanoid@^3.1.30: version "3.3.4" resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz" @@ -4035,6 +4074,11 @@ prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1: object-assign "^4.1.1" react-is "^16.13.1" +property-expr@^2.0.4: + version "2.0.5" + resolved "https://registry.yarnpkg.com/property-expr/-/property-expr-2.0.5.tgz#278bdb15308ae16af3e3b9640024524f4dc02cb4" + integrity sha512-IJUkICM5dP5znhCckHSv30Q4b5/JA5enCtkRHYaOVOAocnH/1BQEYTC5NMfT3AVl/iXKdr3aqQbQn9DxyWknwA== + punycode@^2.1.0: version "2.1.1" resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz" @@ -4071,10 +4115,23 @@ react-dom@18.1.0: loose-envify "^1.1.0" scheduler "^0.22.0" +react-hook-form@^7.32.2: + version "7.32.2" + resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.32.2.tgz#58ec2ab0239ce97969baa2faa03ced13fae913ac" + integrity sha512-F1A6n762xaRhvtQH5SkQQhMr19cCkHZYesTcKJJeNmrphiZp/cYFTIzC05FnQry0SspM54oPJ9tXFXlzya8VNQ== + react-icons@^4.3.1: version "4.3.1" resolved "https://registry.npmjs.org/react-icons/-/react-icons-4.3.1.tgz" +react-input-mask@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/react-input-mask/-/react-input-mask-2.0.4.tgz#9ade5cf8196f4a856dbf010820fe75a795f3eb14" + integrity sha512-1hwzMr/aO9tXfiroiVCx5EtKohKwLk/NT8QlJXHQ4N+yJJFyUuMT+zfTpLBwX/lK3PkuMlievIffncpMZ3HGRQ== + dependencies: + invariant "^2.2.4" + warning "^4.0.2" + react-is@^16.13.1, react-is@^16.7.0: version "16.13.1" resolved "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz" @@ -4569,6 +4626,11 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +toposort@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/toposort/-/toposort-2.0.2.tgz#ae21768175d1559d48bef35420b2f4962f09c330" + integrity sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg== + treeverse@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/treeverse/-/treeverse-2.0.0.tgz#036dcef04bc3fd79a9b79a68d4da03e882d8a9ca" @@ -4689,6 +4751,13 @@ walk-up-path@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/walk-up-path/-/walk-up-path-1.0.0.tgz#d4745e893dd5fd0dbb58dd0a4c6a33d9c9fec53e" +warning@^4.0.2: + version "4.0.3" + resolved "https://registry.yarnpkg.com/warning/-/warning-4.0.3.tgz#16e9e077eb8a86d6af7d64aa1e05fd85b4678ca3" + integrity sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w== + dependencies: + loose-envify "^1.0.0" + wcwidth@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" @@ -4755,3 +4824,16 @@ yallist@^4.0.0: yaml@^1.10.2, yaml@^1.7.2: version "1.10.2" resolved "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz" + +yup@^0.32.11: + version "0.32.11" + resolved "https://registry.yarnpkg.com/yup/-/yup-0.32.11.tgz#d67fb83eefa4698607982e63f7ca4c5ed3cf18c5" + integrity sha512-Z2Fe1bn+eLstG8DRR6FTavGD+MeAwyfmouhHsIUgaADz8jvFKbO/fXc2trJKZg+5EBjh4gGm3iU/t3onKlXHIg== + dependencies: + "@babel/runtime" "^7.15.4" + "@types/lodash" "^4.14.175" + lodash "^4.17.21" + lodash-es "^4.17.21" + nanoclone "^0.2.1" + property-expr "^2.0.4" + toposort "^2.0.2"