diff --git a/next/pages/api/team/getAllPeople.js b/next/pages/api/team/getAllPeople.js
index 34f9885f..868807d1 100644
--- a/next/pages/api/team/getAllPeople.js
+++ b/next/pages/api/team/getAllPeople.js
@@ -9,6 +9,9 @@ async function getAllPeople() {
data: { query: ` mutation { authToken (input: { email: "${process.env.BACKEND_AUTH_EMAIL.trim()}", password: "${process.env.BACKEND_AUTH_PASSWORD.trim()}" }) { token } }` }
})
+ if(token?.data.errors) return ({status: "err_getTeam_0", errors: token.data.errors[0].message})
+ if(token?.data?.data?.authToken === null) return ({status: "err_getTeam_1"})
+
try {
const res = await axios({
url: API_URL,
@@ -50,6 +53,7 @@ async function getAllPeople() {
`
}
})
+ if(res?.data?.errors) return {status: "err_getTeam_2", errors: res.data.errors[0].message}
const data = res?.data?.data?.allAccount?.edges
return data
} catch (error) {
@@ -59,5 +63,10 @@ async function getAllPeople() {
export default async function handler(req, res) {
const result = await getAllPeople()
+
+ if(result?.status === "err_getTeam_0") return res.status(500).json({errors: result.errors})
+ if(result?.status === "err_getTeam_1") return res.status(500).json({errors: "Erro na geração do token"})
+ if(result?.status === "err_getTeam_2") return res.status(500).json({errors: result.errors})
+
res.status(200).json(result)
}
diff --git a/next/pages/api/team/getCareerPeople.js b/next/pages/api/team/getCareerPeople.js
index abd0173e..9961f808 100644
--- a/next/pages/api/team/getCareerPeople.js
+++ b/next/pages/api/team/getCareerPeople.js
@@ -9,6 +9,9 @@ async function getCareerPeople(team) {
data: { query: ` mutation { authToken (input: { email: "${process.env.BACKEND_AUTH_EMAIL.trim()}", password: "${process.env.BACKEND_AUTH_PASSWORD.trim()}" }) { token } }` }
})
+ if(token?.data.errors) return ({status: "err_getCareer_0"})
+ if(token?.data?.data?.authToken === null) return ({status: "err_getCareer_1"})
+
try {
const res = await axios({
url: API_URL,
@@ -49,6 +52,7 @@ async function getCareerPeople(team) {
`
}
})
+ if(res?.data?.errors) return {status: "err_getCareer_2"}
const data = res?.data?.data?.allAccount?.edges
return data
} catch (error) {
@@ -60,6 +64,9 @@ async function getCareerPeople(team) {
export default async function handler(req, res) {
const result = await getCareerPeople(req.query.team)
+ if(result?.status === "err_getCareer_0") return res.status(500).json([])
+ if(result?.status === "err_getCareer_1") return res.status(500).json([])
+ if(result?.status === "err_getCareer_2") return res.status(500).json([])
if(result.errors) return res.status(500).json({error: result.errors})
if(result === "err") return res.status(500).json({error: "err"})
diff --git a/next/pages/api/user/getIdUser.js b/next/pages/api/user/getIdUser.js
index 34e0f5bf..85ba94dc 100644
--- a/next/pages/api/user/getIdUser.js
+++ b/next/pages/api/user/getIdUser.js
@@ -9,6 +9,9 @@ async function getIdUser(email) {
data: { query: ` mutation { authToken (input: { email: "${process.env.BACKEND_AUTH_EMAIL.trim()}", password: "${process.env.BACKEND_AUTH_PASSWORD.trim()}" }) { token } }` }
})
+ if(token?.data.errors) return ({status: "err_getId_0"})
+ if(token?.data?.data?.authToken === null) return ({status: "err_getId_1"})
+
try {
const res = await axios({
url: API_URL,
@@ -20,6 +23,7 @@ async function getIdUser(email) {
query: `query { allAccount (email: "${email}") {edges{node{id}}} }`
}
})
+ if(res?.data?.errors) return {status: "err_getId_2"}
const data = res.data
return data
} catch (error) {
@@ -31,6 +35,10 @@ async function getIdUser(email) {
export default async function handler(req, res) {
const result = await getIdUser(atob(req.query.p))
+ if(result?.status === "err_getId_0") return res.status(500).json({error: true})
+ if(result?.status === "err_getId_1") return res.status(500).json({error: true})
+ if(result?.status === "err_getId_2") return res.status(500).json({error: true})
+
if(result.errors) return res.status(500).json({error: result.errors})
if(result === "err") return res.status(500).json({error: "err"})
if(result?.data?.allAccount?.edges.length === 0) return res.status(500).json({error: "err"})
diff --git a/next/pages/quem-somos.js b/next/pages/quem-somos.js
index 0ebf3a15..5dfa81dc 100755
--- a/next/pages/quem-somos.js
+++ b/next/pages/quem-somos.js
@@ -22,6 +22,8 @@ import BigTitle from "../components/atoms/BigTitle";
import BodyText from "../components/atoms/BodyText";
import Link from "../components/atoms/Link";
import Carousel from "../components/atoms/Carousel";
+
+import InternalError from "../public/img/internalError";
import WebIcon from "../public/img/icons/webIcon";
import EmailIcon from "../public/img/icons/emailIcon";
import TwitterIcon from "../public/img/icons/twitterIcon";
@@ -33,8 +35,7 @@ import styles from "../styles/quemSomos.module.css";
export async function getServerSideProps() {
const response = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL_FRONTEND}/api/team/getAllPeople`, {method: "GET"})
- .then(res => res.json())
- const data = response
+ const data = await response.json()
return {
props: {
@@ -251,6 +252,22 @@ const TeamBox = ({
}
export default function QuemSomos({ data }) {
+ const [allPeople, setAllPeople] = useState([])
+ const [people, setPeople] = useState([])
+ const [filterTeam, setFilterTeam] = useState("")
+
+ useEffect(() => {
+ if(data.length === 0) return
+ if(data.errors) {
+ console.error(data.errors)
+ setAllPeople([])
+ setPeople([])
+ } else {
+ setAllPeople(sortPeople(data))
+ setPeople(sortPeople(data))
+ }
+ }, [data])
+
const sortPeople = (array) => {
const sortPeopleArray = array
@@ -286,10 +303,6 @@ export default function QuemSomos({ data }) {
return removeDuplicates(data).filter(obj => obj.node.firstName !== "API User" && obj.node.firstName !== "Staging")
}
- const [allPeople] = useState(sortPeople(data))
- const [people, setPeople] = useState(sortPeople(data))
- const [filterTeam, setFilterTeam] = useState("")
-
const schemasTeam = [
"Co-fundadores",
"Associados",
@@ -325,6 +338,10 @@ export default function QuemSomos({ data }) {
setFilterTeam(elm)
const result = await fetch(`/api/team/getCareerPeople?team=${elm}`, {method: "GET"})
.then(res => res.json())
+ if(result.length === 0) {
+ setFilterTeam("")
+ return setPeople(allPeople)
+ }
setPeople(sortPeople(result))
}
}
@@ -693,59 +710,69 @@ export default function QuemSomos({ data }) {
Uma equipe colaborativa
-
-
- {schemasTeam?.map((elm) => (
- handleSelect(elm)}
- >
- {elm}
-
- ))}
-
-
+ {data.length > 1 ?
- {people?.map((elm, index) => (
-
- ))}
+
+ {schemasTeam?.map((elm, i) => (
+ handleSelect(elm)}
+ >
+ {elm}
+
+ ))}
+
+
+
+ {people?.map((elm, index) => (
+
+ ))}
+
-
+ :
+
+
+
+ }
Conta ativa
@@ -70,7 +70,7 @@ export default function ActiveAccount({ data }) {
fontSize={isMobileMod() ? "28px" : "34px"}
lineHeight={isMobileMod() ? "36px" : "44px"}
letterSpacing={isMobileMod() ? "0" : "-0.4px"}
- fontWeith="500"
+ fontweith="500"
textAlign="center"
>Algo deu errado
diff --git a/next/pages/user/check-email.js b/next/pages/user/check-email.js
index 8627a224..a11241f2 100644
--- a/next/pages/user/check-email.js
+++ b/next/pages/user/check-email.js
@@ -68,7 +68,7 @@ export default function CheckEmail() {
fontSize={isMobileMod() ? "28px" : "34px"}
lineHeight={isMobileMod() ? "36px" : "44px"}
letterSpacing={isMobileMod() ? "0" : "-0.4px"}
- fontWeith="500"
+ fontweith="500"
textAlign="center"
>Confirme seu endereço de e-mail