Skip to content

Commit

Permalink
wip page Quem somos
Browse files Browse the repository at this point in the history
  • Loading branch information
AldemirLucas committed Sep 13, 2023
1 parent 0c874b1 commit 5506ac8
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 31 deletions.
48 changes: 48 additions & 0 deletions next/pages/api/team/getAllPeople.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import axios from "axios";

const API_URL= `${process.env.NEXT_PUBLIC_API_URL}/api/v1/graphql`

export default async function getAllPeople() {
try {
const res = await axios({
url: API_URL,
method: "POST",
data: {
query: `
query {
allAccount (profile: A_1){
edges {
node {
firstName
lastName
description
website
email
twitter
linkedin
github
picture
careerSet {
edges {
node {
_id
team
role
startAt
endAt
}
}
}
}
}
}
}
`
}
})
const data = res?.data?.data?.allAccount?.edges
return data
} catch (error) {
console.error(error)
}
}
23 changes: 23 additions & 0 deletions next/pages/api/team/getAllTeams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import axios from "axios";

const API_URL= `${process.env.NEXT_PUBLIC_API_URL}/api/v1/graphql`

export default async function getAllTeams() {
try {
const res = await axios({
url: API_URL,
method: "POST",
data: {
query: `
query {
}
`
}
})
const data = res?.data?.data?.allBdgroup?.edges
return data
} catch (error) {
console.error(error)
}
}
48 changes: 48 additions & 0 deletions next/pages/api/team/getCareerPeople.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import axios from "axios";

const API_URL= `${process.env.NEXT_PUBLIC_API_URL}/api/v1/graphql`

export default async function getCareerPeople(team) {
try {
const res = await axios({
url: API_URL,
method: "POST",
data: {
query: `
query {
allAccount (career_Team: "${team}"){
edges {
node {
firstName
lastName
description
website
email
twitter
linkedin
github
picture
careerSet {
edges {
node {
_id
team
role
startAt
endAt
}
}
}
}
}
}
}
`
}
})
const data = res?.data?.data?.allAccount?.edges
return data
} catch (error) {
console.error(error)
}
}
10 changes: 7 additions & 3 deletions next/pages/api/team/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import getTeams from "./getTeams"
import getPeople from "./getPeople"
import getTeams from "./getTeams";
import getPeople from "./getPeople";
import getAllPeople from "./getAllPeople";
import getCareerPeople from "./getCareerPeople";

export {
getTeams,
getPeople
getPeople,
getAllPeople,
getCareerPeople
}
107 changes: 79 additions & 28 deletions next/pages/quem-somos.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import { MainPageTemplate } from "../components/templates/main";
import { isMobileMod } from "../hooks/useCheckMobile.hook";

import {
getTeams,
getPeople
// getTeams,
// getPeople,
getAllPeople,
getCareerPeople
} from "./api/team";

import Display from "../components/atoms/Display";
Expand All @@ -36,6 +38,16 @@ import DiscordIcon from "../public/img/icons/discordIcon";
import RedirectIcon from "../public/img/icons/redirectIcon";
import styles from "../styles/quemSomos.module.css";

export async function getServerSideProps() {
const data = await getAllPeople()

return {
props: {
data,
},
}
}

const HistoryBox = ({ children, title, date, image }) => {
const { isOpen, onOpen, onClose } = useDisclosure()

Expand Down Expand Up @@ -99,9 +111,24 @@ const HistoryBox = ({ children, title, date, image }) => {
)
}

const TeamBox = ({ index, data }) => {
const TeamBox = ({
index,
data,
name,
picture,
description,
website,
email,
twitter,
linkedin,
github,
career
}) => {
const hasLeftSpacing = (index % 2 == 0) ? false : true

const role = career[0]?.node.role
console.log(career)

const iconTeamBox = (ref) => {
let href = ""

Expand Down Expand Up @@ -134,14 +161,14 @@ const TeamBox = ({ index, data }) => {
}
}

const iconLinks = () => {
const IconLinks = () => {
return (
<Box display="flex" flexDirection="row" gridGap="5px">
{data.website ? <WebIcon {...iconTeamBox({website: data.website})}/> : null}
{data.email ? <EmailIcon {...iconTeamBox({email: data.email})}/> : null}
{data.twitter ? <TwitterIcon {...iconTeamBox({twitter: data.twitter})}/> : null}
{data.linkedin ? <LinkedinIcon {...iconTeamBox({linkedin: data.linkedin})}/> : null}
{data.github ? <GithubIcon {...iconTeamBox({github: data.github})}/> : null}
{website ? <WebIcon {...iconTeamBox({website: website})}/> : null}
{email ? <EmailIcon {...iconTeamBox({email: email})}/> : null}
{twitter ? <TwitterIcon {...iconTeamBox({twitter: twitter})}/> : null}
{linkedin ? <LinkedinIcon {...iconTeamBox({linkedin: linkedin})}/> : null}
{github ? <GithubIcon {...iconTeamBox({github: github})}/> : null}
</Box>
)
}
Expand All @@ -164,8 +191,8 @@ const TeamBox = ({ index, data }) => {
overflow="hidden"
>
<Image
alt={data?.name || ""}
src={data.photo_url ? data.photo_url : "https://basedosdados-static.s3.us-east-2.amazonaws.com/equipe/sem_foto.png"}
alt={name}
src={picture ? picture : "https://basedosdados-static.s3.us-east-2.amazonaws.com/equipe/sem_foto.png"}
width="100%"
height="100%"
/>
Expand All @@ -176,29 +203,39 @@ const TeamBox = ({ index, data }) => {
fontSize="18px"
marginRight="16px"
>
{data?.name}
{name}
</BodyText>
{!isMobileMod() && iconLinks()}
{!isMobileMod() && <IconLinks/>}
</Box>

<BodyText
fontSize="16px"
fontWeight="400"
marginBottom="4px"
letterSpacing="0.2px"
color="#6F6F6F"
>
{data?.role.join(", ")}
{/* {data?.role.join(", ")} */}
{role}
</BodyText>

<BodyText
fontSize="16px"
letterSpacing="0.2px"
lineHeight="25px"
marginBottom={isMobileMod() ? "12px" : "0"}
>
{description}
</BodyText>
<BodyText fontSize="16px" letterSpacing="0.2px" lineHeight="25px" marginBottom={isMobileMod() ? "12px" : "0"}>{data?.description}</BodyText>
{isMobileMod() && iconLinks()}
</Box>
</Box>
)
}

export default function QuemSomos() {
const [allPeople, setAllPeople] = useState([])
const [people, setPeople] = useState([])
export default function QuemSomos({ data }) {
const [allPeople, setAllPeople] = useState(data)
const [people, setPeople] = useState(data)
const [filterTeam, setFilterTeam] = useState("")

const schemasTeam = [
Expand Down Expand Up @@ -251,13 +288,14 @@ export default function QuemSomos() {
return newArraySorting
}

useEffect(() => {
setPeople(sortingTeam(allPeople))
},[allPeople])
// useEffect(() => {
// setPeople(sortingTeam(allPeople))
// },[allPeople])

useEffect(() => {
setAllPeople(groupingTeamAndRole(Object.values(getPeople)).filter(Boolean))
},[])
// useEffect(() => {
// // setAllPeople(groupingTeamAndRole(Object.values(getPeople)).filter(Boolean))
// setAllPeople([])
// },[])

const groupingTeamAndRole = (array) => array.map((elm) => {
const person = elm
Expand All @@ -266,7 +304,8 @@ export default function QuemSomos() {
const level = []
const endDate = []

const getById = getTeams.filter((elm) => elm.person_id === person.id)
// const getById = getTeams.filter((elm) => elm.person_id === person.id)
const getById= []

if(getById) getById.map((res) => {
team.push(res.team)
Expand Down Expand Up @@ -298,14 +337,16 @@ export default function QuemSomos() {
},[filterTeam])

const filterPeopleByTeam = (team) => {
const teamPeople = getTeams.filter((elm) => elm.team === team)
// const teamPeople = getTeams.filter((elm) => elm.team === team)
const teamPeople = []

const mapId = () => teamPeople.map((elm) => elm.person_id)

const personIdList = Array.from(new Set(mapId()))

const filterPeople = () => personIdList.map((personId) => getPeople[personId])

// const filterPeople = () => personIdList.map((personId) => getPeople[personId])
const filterPeople = []

const newGroupPerson = groupingTeamAndRole(filterPeople()).filter(Boolean)

setPeople(sortingTeam(newGroupPerson, [team]))
Expand Down Expand Up @@ -737,8 +778,18 @@ export default function QuemSomos() {
>
{people?.map((elm, index) => (
<TeamBox
key={index}
index={index}
data={elm}
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.careerSet.edges}
/>
))}
</Stack>
Expand Down

0 comments on commit 5506ac8

Please sign in to comment.