Merge branch 'feature/login' of https://github.com/CloudAlb/tcc-vamos-frontend into develop

This commit is contained in:
Hugo Falcao
2022-04-18 21:23:42 -03:00
4 changed files with 267 additions and 91 deletions

192
package-lock.json generated
View File

@@ -47,6 +47,7 @@
},
"devDependencies": {
"@capacitor/cli": "3.4.3",
"@types/axios": "^0.14.0",
"react-scripts": "5.0.1"
}
},
@@ -3570,6 +3571,16 @@
"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.2.tgz",
"integrity": "sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig=="
},
"node_modules/@types/axios": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/@types/axios/-/axios-0.14.0.tgz",
"integrity": "sha1-7CMA++fX3d1+udOr+HmZlkyvzkY=",
"deprecated": "This is a stub types definition for axios (https://github.com/mzabriskie/axios). axios provides its own type definitions, so you don't need @types/axios installed!",
"dev": true,
"dependencies": {
"axios": "*"
}
},
"node_modules/@types/babel__core": {
"version": "7.1.19",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.19.tgz",
@@ -3981,14 +3992,14 @@
"integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA=="
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.19.0.tgz",
"integrity": "sha512-w59GpFqDYGnWFim9p6TGJz7a3qWeENJuAKCqjGSx+Hq/bwq3RZwXYqy98KIfN85yDqz9mq6QXiY5h0FjGQLyEg==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.20.0.tgz",
"integrity": "sha512-fapGzoxilCn3sBtC6NtXZX6+P/Hef7VDbyfGqTTpzYydwhlkevB+0vE0EnmHPVTVSy68GUncyJ/2PcrFBeCo5Q==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.19.0",
"@typescript-eslint/type-utils": "5.19.0",
"@typescript-eslint/utils": "5.19.0",
"@typescript-eslint/scope-manager": "5.20.0",
"@typescript-eslint/type-utils": "5.20.0",
"@typescript-eslint/utils": "5.20.0",
"debug": "^4.3.2",
"functional-red-black-tree": "^1.0.1",
"ignore": "^5.1.8",
@@ -4014,12 +4025,12 @@
}
},
"node_modules/@typescript-eslint/experimental-utils": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-5.19.0.tgz",
"integrity": "sha512-F+X/TTzmb2UXbghY1LrNLNDjMcGZMhKzXuzvu0xD+YEB77EamLM7zMOLuz2kP5807IJRDLBoAFFPYa7HT62sYg==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-5.20.0.tgz",
"integrity": "sha512-w5qtx2Wr9x13Dp/3ic9iGOGmVXK5gMwyc8rwVgZU46K9WTjPZSyPvdER9Ycy+B5lNHvoz+z2muWhUvlTpQeu+g==",
"dev": true,
"dependencies": {
"@typescript-eslint/utils": "5.19.0"
"@typescript-eslint/utils": "5.20.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -4033,14 +4044,14 @@
}
},
"node_modules/@typescript-eslint/parser": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.19.0.tgz",
"integrity": "sha512-yhktJjMCJX8BSBczh1F/uY8wGRYrBeyn84kH6oyqdIJwTGKmzX5Qiq49LRQ0Jh0LXnWijEziSo6BRqny8nqLVQ==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.20.0.tgz",
"integrity": "sha512-UWKibrCZQCYvobmu3/N8TWbEeo/EPQbS41Ux1F9XqPzGuV7pfg6n50ZrFo6hryynD8qOTTfLHtHjjdQtxJ0h/w==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.19.0",
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/typescript-estree": "5.19.0",
"@typescript-eslint/scope-manager": "5.20.0",
"@typescript-eslint/types": "5.20.0",
"@typescript-eslint/typescript-estree": "5.20.0",
"debug": "^4.3.2"
},
"engines": {
@@ -4060,13 +4071,13 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz",
"integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.20.0.tgz",
"integrity": "sha512-h9KtuPZ4D/JuX7rpp1iKg3zOH0WNEa+ZIXwpW/KWmEFDxlA/HSfCMhiyF1HS/drTICjIbpA6OqkAhrP/zkCStg==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/visitor-keys": "5.19.0"
"@typescript-eslint/types": "5.20.0",
"@typescript-eslint/visitor-keys": "5.20.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -4077,12 +4088,12 @@
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz",
"integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.20.0.tgz",
"integrity": "sha512-WxNrCwYB3N/m8ceyoGCgbLmuZwupvzN0rE8NBuwnl7APgjv24ZJIjkNzoFBXPRCGzLNkoU/WfanW0exvp/+3Iw==",
"dev": true,
"dependencies": {
"@typescript-eslint/utils": "5.19.0",
"@typescript-eslint/utils": "5.20.0",
"debug": "^4.3.2",
"tsutils": "^3.21.0"
},
@@ -4103,9 +4114,9 @@
}
},
"node_modules/@typescript-eslint/types": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz",
"integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.20.0.tgz",
"integrity": "sha512-+d8wprF9GyvPwtoB4CxBAR/s0rpP25XKgnOvMf/gMXYDvlUC3rPFHupdTQ/ow9vn7UDe5rX02ovGYQbv/IUCbg==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -4116,13 +4127,13 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz",
"integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.20.0.tgz",
"integrity": "sha512-36xLjP/+bXusLMrT9fMMYy1KJAGgHhlER2TqpUVDYUQg4w0q/NW/sg4UGAgVwAqb8V4zYg43KMUpM8vV2lve6w==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/visitor-keys": "5.19.0",
"@typescript-eslint/types": "5.20.0",
"@typescript-eslint/visitor-keys": "5.20.0",
"debug": "^4.3.2",
"globby": "^11.0.4",
"is-glob": "^4.0.3",
@@ -4143,15 +4154,15 @@
}
},
"node_modules/@typescript-eslint/utils": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz",
"integrity": "sha512-ZuEckdupXpXamKvFz/Ql8YnePh2ZWcwz7APICzJL985Rp5C2AYcHO62oJzIqNhAMtMK6XvrlBTZeNG8n7gS3lQ==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.20.0.tgz",
"integrity": "sha512-lHONGJL1LIO12Ujyx8L8xKbwWSkoUKFSO+0wDAqGXiudWB2EO7WEUT+YZLtVbmOmSllAjLb9tpoIPwpRe5Tn6w==",
"dev": true,
"dependencies": {
"@types/json-schema": "^7.0.9",
"@typescript-eslint/scope-manager": "5.19.0",
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/typescript-estree": "5.19.0",
"@typescript-eslint/scope-manager": "5.20.0",
"@typescript-eslint/types": "5.20.0",
"@typescript-eslint/typescript-estree": "5.20.0",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0"
},
@@ -4189,12 +4200,12 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz",
"integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.20.0.tgz",
"integrity": "sha512-1flRpNF+0CAQkMNlTJ6L/Z5jiODG/e5+7mk6XwtPOUS3UrTz3UOiAg9jG2VtKsWI6rZQfy4C6a232QNRZTRGlg==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/types": "5.20.0",
"eslint-visitor-keys": "^3.0.0"
},
"engines": {
@@ -19102,6 +19113,15 @@
"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.2.tgz",
"integrity": "sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig=="
},
"@types/axios": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/@types/axios/-/axios-0.14.0.tgz",
"integrity": "sha1-7CMA++fX3d1+udOr+HmZlkyvzkY=",
"dev": true,
"requires": {
"axios": "*"
}
},
"@types/babel__core": {
"version": "7.1.19",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.19.tgz",
@@ -19509,16 +19529,6 @@
"integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA=="
},
"@typescript-eslint/eslint-plugin": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.19.0.tgz",
"integrity": "sha512-w59GpFqDYGnWFim9p6TGJz7a3qWeENJuAKCqjGSx+Hq/bwq3RZwXYqy98KIfN85yDqz9mq6QXiY5h0FjGQLyEg==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.19.0",
"@typescript-eslint/type-utils": "5.19.0",
"@typescript-eslint/utils": "5.19.0",
"debug": "^4.3.2",
"functional-red-black-tree": "^1.0.1",
"ignore": "^5.1.8",
"regexpp": "^3.2.0",
"semver": "^7.3.5",
@@ -19526,61 +19536,61 @@
}
},
"@typescript-eslint/experimental-utils": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-5.19.0.tgz",
"integrity": "sha512-F+X/TTzmb2UXbghY1LrNLNDjMcGZMhKzXuzvu0xD+YEB77EamLM7zMOLuz2kP5807IJRDLBoAFFPYa7HT62sYg==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-5.20.0.tgz",
"integrity": "sha512-w5qtx2Wr9x13Dp/3ic9iGOGmVXK5gMwyc8rwVgZU46K9WTjPZSyPvdER9Ycy+B5lNHvoz+z2muWhUvlTpQeu+g==",
"dev": true,
"requires": {
"@typescript-eslint/utils": "5.19.0"
"@typescript-eslint/utils": "5.20.0"
}
},
"@typescript-eslint/parser": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.19.0.tgz",
"integrity": "sha512-yhktJjMCJX8BSBczh1F/uY8wGRYrBeyn84kH6oyqdIJwTGKmzX5Qiq49LRQ0Jh0LXnWijEziSo6BRqny8nqLVQ==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.20.0.tgz",
"integrity": "sha512-UWKibrCZQCYvobmu3/N8TWbEeo/EPQbS41Ux1F9XqPzGuV7pfg6n50ZrFo6hryynD8qOTTfLHtHjjdQtxJ0h/w==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.19.0",
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/typescript-estree": "5.19.0",
"@typescript-eslint/scope-manager": "5.20.0",
"@typescript-eslint/types": "5.20.0",
"@typescript-eslint/typescript-estree": "5.20.0",
"debug": "^4.3.2"
}
},
"@typescript-eslint/scope-manager": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz",
"integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.20.0.tgz",
"integrity": "sha512-h9KtuPZ4D/JuX7rpp1iKg3zOH0WNEa+ZIXwpW/KWmEFDxlA/HSfCMhiyF1HS/drTICjIbpA6OqkAhrP/zkCStg==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/visitor-keys": "5.19.0"
"@typescript-eslint/types": "5.20.0",
"@typescript-eslint/visitor-keys": "5.20.0"
}
},
"@typescript-eslint/type-utils": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz",
"integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.20.0.tgz",
"integrity": "sha512-WxNrCwYB3N/m8ceyoGCgbLmuZwupvzN0rE8NBuwnl7APgjv24ZJIjkNzoFBXPRCGzLNkoU/WfanW0exvp/+3Iw==",
"dev": true,
"requires": {
"@typescript-eslint/utils": "5.19.0",
"@typescript-eslint/utils": "5.20.0",
"debug": "^4.3.2",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/types": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz",
"integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.20.0.tgz",
"integrity": "sha512-+d8wprF9GyvPwtoB4CxBAR/s0rpP25XKgnOvMf/gMXYDvlUC3rPFHupdTQ/ow9vn7UDe5rX02ovGYQbv/IUCbg==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz",
"integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.20.0.tgz",
"integrity": "sha512-36xLjP/+bXusLMrT9fMMYy1KJAGgHhlER2TqpUVDYUQg4w0q/NW/sg4UGAgVwAqb8V4zYg43KMUpM8vV2lve6w==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/visitor-keys": "5.19.0",
"@typescript-eslint/types": "5.20.0",
"@typescript-eslint/visitor-keys": "5.20.0",
"debug": "^4.3.2",
"globby": "^11.0.4",
"is-glob": "^4.0.3",
@@ -19589,15 +19599,15 @@
}
},
"@typescript-eslint/utils": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz",
"integrity": "sha512-ZuEckdupXpXamKvFz/Ql8YnePh2ZWcwz7APICzJL985Rp5C2AYcHO62oJzIqNhAMtMK6XvrlBTZeNG8n7gS3lQ==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.20.0.tgz",
"integrity": "sha512-lHONGJL1LIO12Ujyx8L8xKbwWSkoUKFSO+0wDAqGXiudWB2EO7WEUT+YZLtVbmOmSllAjLb9tpoIPwpRe5Tn6w==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.9",
"@typescript-eslint/scope-manager": "5.19.0",
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/typescript-estree": "5.19.0",
"@typescript-eslint/scope-manager": "5.20.0",
"@typescript-eslint/types": "5.20.0",
"@typescript-eslint/typescript-estree": "5.20.0",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0"
},
@@ -19621,12 +19631,12 @@
}
},
"@typescript-eslint/visitor-keys": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz",
"integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==",
"version": "5.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.20.0.tgz",
"integrity": "sha512-1flRpNF+0CAQkMNlTJ6L/Z5jiODG/e5+7mk6XwtPOUS3UrTz3UOiAg9jG2VtKsWI6rZQfy4C6a232QNRZTRGlg==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/types": "5.20.0",
"eslint-visitor-keys": "^3.0.0"
}
},
@@ -28994,4 +29004,4 @@
"dev": true
}
}
}

View File

@@ -66,6 +66,7 @@
},
"devDependencies": {
"@capacitor/cli": "3.4.3",
"@types/axios": "^0.14.0",
"react-scripts": "5.0.1"
},
"description": "An Ionic project"

View File

@@ -8,6 +8,9 @@ import { IonReactRouter } from '@ionic/react-router';
import Cadastro from './pages/Cadastro';
import MainPages from './pages/MainPages';
// importação das páginas
import Login from './pages/login/Login';
/* Core CSS required for Ionic components to work properly */
import '@ionic/react/css/core.css';

162
src/pages/login/Login.tsx Normal file
View File

@@ -0,0 +1,162 @@
import {
IonContent,
IonHeader,
IonPage,
IonTitle,
IonToolbar,
IonButtons,
} from "@ionic/react";
import React, { useState } from "react";
import axios from "axios";
import { IonGrid, IonRow, IonCol } from "@ionic/react";
import { personCircle } from "ionicons/icons";
import { useHistory } from "react-router-dom";
import {
IonItem,
IonLabel,
IonInput,
IonButton,
IonIcon,
IonAlert,
} from "@ionic/react";
function validateEmail(email: string) {
const re =
/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))$/;
return re.test(String(email).toLowerCase());
}
const Page: React.FC = () => {
const history = useHistory();
const [email, setEmail] = useState<string>("matheusalb3213@gmail.com");
const [password, setPassword] = useState<string>("1234");
const [isError, setIsError] = useState<boolean>(false);
const [message, setMessage] = useState<string>("");
const handleLogin = () => {
// validação de inputs
if (!email) {
setMessage("Por favor, informe um e-mail válido");
setIsError(true);
return;
}
if (validateEmail(email) === false) {
setMessage("E-mail inválido");
setIsError(true);
return;
}
if (!password || password.length < 6) {
setMessage("Por favor, digite a sua senha");
setIsError(true);
return;
}
const loginData = {
email: email,
password: password,
};
const api = axios.create({
baseURL: `https://625dc16c4c36c7535779792c.mockapi.io/api/v1`,
});
api
// .post("/login", loginData)
.get("/users/2")
.then((res) => {
// login bem-sucedido
history.push("/dashboard/" + email);
})
.catch((error) => {
setMessage("Falha na autenticação! Por favor, crie uma conta");
setIsError(true);
});
};
return (
<IonPage>
<IonHeader>
<IonToolbar>
<IonTitle>Login</IonTitle>
</IonToolbar>
</IonHeader>
<IonRow>
<IonCol>
<IonIcon
style={{ fontSize: "70px", color: "#0040ff" }}
icon={personCircle}
/>
</IonCol>
</IonRow>
<IonContent fullscreen>
<IonHeader collapse="condense">
<IonToolbar>
<IonTitle size="large">Login</IonTitle>
</IonToolbar>
</IonHeader>
<IonGrid>
<IonRow>
<IonCol>
<IonAlert
isOpen={isError}
onDidDismiss={() => setIsError(false)}
cssClass="my-custom-class"
header={"Error!"}
message={message}
buttons={["Dismiss"]}
/>
</IonCol>
</IonRow>
<IonRow>
<IonCol>
<IonItem>
<IonLabel position="floating"> Email</IonLabel>
<IonInput
type="email"
value={email}
onIonChange={(e) => setEmail(e.detail.value!)}
></IonInput>
</IonItem>
</IonCol>
</IonRow>
<IonRow>
<IonCol>
<IonItem>
<IonLabel position="floating"> Senha</IonLabel>
<IonInput
type="password"
value={password}
onIonChange={(e) => setPassword(e.detail.value!)}
></IonInput>
</IonItem>
</IonCol>
</IonRow>
<IonRow>
<IonCol>
<p style={{ fontSize: "small" }}>
Clicando no botão de "LOGIN", você concorda com a nossa{" "}
<a href="#">política de termos e serviços</a>
</p>
<IonButton expand="block" onClick={handleLogin}>
Login
</IonButton>
<p style={{ fontSize: "medium" }}>
Ainda não possui uma conta? <a href="#">Cadastre-se aqui!</a>
</p>
</IonCol>
</IonRow>
</IonGrid>
</IonContent>
</IonPage>
);
};
export default Page;