Skip to content

Commit

Permalink
Merge pull request #840 from basedosdados/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
AldemirLucas authored May 14, 2024
2 parents 74bfc03 + f022eca commit 7a9bd9f
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 59 deletions.
9 changes: 9 additions & 0 deletions next/pages/api/team/getAllPeople.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
}
7 changes: 7 additions & 0 deletions next/pages/api/team/getCareerPeople.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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"})

Expand Down
8 changes: 8 additions & 0 deletions next/pages/api/user/getIdUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand All @@ -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"})
Expand Down
139 changes: 83 additions & 56 deletions next/pages/quem-somos.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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: {
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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))
}
}
Expand Down Expand Up @@ -693,59 +710,69 @@ export default function QuemSomos({ data }) {
Uma equipe colaborativa
</Display>

<Stack
position="relative"
gridGap="96px"
spacing={0}
flexDirection={isMobileMod() ? "column" :"row"}
paddingBottom="32px"
>
<Box
display="flex"
height="100%"
flexDirection="column"
gridGap="16px"
position={isMobileMod() ? "relative" : "sticky"}
top={isMobileMod()? "0" : "120px"}
z-index="20"
>
{schemasTeam?.map((elm) => (
<Text
fontSize="16px"
color={filterTeam === elm ? "#2B8C4D" :"#6F6F6F"}
fontFamily="ubuntu"
fontWeight="500"
width="max-content"
cursor="pointer"
letterSpacing="0.2px"
onClick={() => handleSelect(elm)}
>
{elm}
</Text>
))}
</Box>

{data.length > 1 ?
<Stack
width="100%"
spacing={{ base: "72px", lg: "96px" }}
position="relative"
gridGap="96px"
spacing={0}
flexDirection={isMobileMod() ? "column" :"row"}
paddingBottom="32px"
>
{people?.map((elm, index) => (
<TeamBox
key={index}
index={index}
name={`${elm.node.firstName} ${elm.node.lastName}`}
picture={elm.node.picture}
description={elm.node.description}
website={elm.node.website}
email={elm.node.email}
twitter={elm.node.twitter}
linkedin={elm.node.linkedin}
github={elm.node.github}
career={elm.node.careers.edges}
/>
))}
<Box
display="flex"
height="100%"
flexDirection="column"
gridGap="16px"
position={isMobileMod() ? "relative" : "sticky"}
top={isMobileMod()? "0" : "120px"}
z-index="20"
>
{schemasTeam?.map((elm, i) => (
<Text
key={i}
fontSize="16px"
color={filterTeam === elm ? "#2B8C4D" :"#6F6F6F"}
fontFamily="ubuntu"
fontWeight="500"
width="max-content"
cursor="pointer"
letterSpacing="0.2px"
onClick={() => handleSelect(elm)}
>
{elm}
</Text>
))}
</Box>

<Stack
width="100%"
spacing={{ base: "72px", lg: "96px" }}
>
{people?.map((elm, index) => (
<TeamBox
key={index}
index={index}
name={`${elm.node.firstName} ${elm.node.lastName}`}
picture={elm.node.picture}
description={elm.node.description}
website={elm.node.website}
email={elm.node.email}
twitter={elm.node.twitter}
linkedin={elm.node.linkedin}
github={elm.node.github}
career={elm.node.careers.edges}
/>
))}
</Stack>
</Stack>
</Stack>
:
<Stack justifyContent="center" alignItems="center">
<InternalError
widthImage="300"
heightImage="300"
/>
</Stack>
}

<Stack
width="100%"
Expand Down
4 changes: 2 additions & 2 deletions next/pages/user/activate-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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"
>Conta ativa</Display>

Expand All @@ -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</Display>

Expand Down
2 changes: 1 addition & 1 deletion next/pages/user/check-email.js
Original file line number Diff line number Diff line change
Expand Up @@ -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</Display>

Expand Down

0 comments on commit 7a9bd9f

Please sign in to comment.