Skip to content

Commit

Permalink
Merge pull request #698 from basedosdados/feat/quem-somos
Browse files Browse the repository at this point in the history
Feat/quem somos
  • Loading branch information
AldemirLucas authored Sep 15, 2023
2 parents eb5e290 + db757ca commit 5dc08f1
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 126 deletions.
50 changes: 50 additions & 0 deletions next/pages/api/team/getAllPeople.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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 {
edges {
node {
firstName
lastName
description
website
email
twitter
linkedin
github
picture
isActiveStaff
careers {
edges {
node {
_id
team
role
startAt
endAt
}
}
}
}
}
}
}
`
}
})
const result = res?.data?.data?.allAccount?.edges
const data = result.filter(item => item.node.isActiveStaff === 'true')
return data
} catch (error) {
console.error(error)
}
}
39 changes: 39 additions & 0 deletions next/pages/api/team/getAllTeams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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 {
allCareer {
edges {
node {
team
}
}
}
}
`
}
})
const result = res?.data?.data?.allCareer?.edges
const teamsSet = new Set()

result.forEach(item => {
const team = item.node.team.trim()
if (team !== "") {
teamsSet.add(team)
}
})

const data = Array.from(teamsSet)
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 (careers_Team: "${team}"){
edges {
node {
firstName
lastName
description
website
email
twitter
linkedin
github
picture
careers {
edges {
node {
_id
team
role
startAt
endAt
}
}
}
}
}
}
}
`
}
})
const data = res?.data?.data?.allAccount?.edges
return data
} catch (error) {
console.error(error)
}
}
12 changes: 9 additions & 3 deletions next/pages/api/team/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import getTeams from "./getTeams"
import getPeople from "./getPeople"
import getTeams from "./getTeams";
import getPeople from "./getPeople";
import getAllPeople from "./getAllPeople";
import getCareerPeople from "./getCareerPeople";
import getAllTeams from "./getAllTeams";

export {
getTeams,
getPeople
getPeople,
getAllPeople,
getCareerPeople,
getAllTeams
}
Loading

0 comments on commit 5dc08f1

Please sign in to comment.