Skip to content

Commit

Permalink
Merge pull request #841 from basedosdados/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
AldemirLucas authored May 14, 2024
2 parents 412d974 + 7a9bd9f commit 37a1ab9
Show file tree
Hide file tree
Showing 28 changed files with 651 additions and 674 deletions.
14 changes: 3 additions & 11 deletions next/components/molecules/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function FooterLink(props) {
)
}

export default function Footer({ pages, ocult = false }) {
export default function Footer({ ocult = false }) {
const mobileCheck = useCheckMobile()
const [isMobileMod, setIsMobileMod] = useState(false)

Expand Down Expand Up @@ -128,7 +128,7 @@ export default function Footer({ pages, ocult = false }) {
<FooterLink href="https://info.basedosdados.org/bd-pro">
BD Pro
</FooterLink>
<FooterLink href="https://info.basedosdados.org/bd-edu-python">
<FooterLink href="https://info.basedosdados.org/bd-edu-sql">
BD Edu
</FooterLink>
</SectionCategories>
Expand All @@ -143,7 +143,7 @@ export default function Footer({ pages, ocult = false }) {
<FooterLink href="/servicos#Consultoria de dados">
Consultoria de dados
</FooterLink>
<FooterLink href="/estudos-de-caso">
<FooterLink href="/servicos#Estudos de caso">
Estudos de caso
</FooterLink>
</SectionCategories>
Expand Down Expand Up @@ -211,14 +211,6 @@ export default function Footer({ pages, ocult = false }) {
marginTop={isMobileMod && "16px"}
>
<BodyText color="#FFF" fontSize="16px" letterSpacing="0.2px">® 2024 Base dos Dados</BodyText>
<BodyText
color="#FFF"
fontSize="12px"
letterSpacing="0.2px"
>
Ícones adaptados de Freepik e disponíveis em Storyset e
Flaticon.
</BodyText>
</HStack>

<HStack spacing={3}>
Expand Down
100 changes: 0 additions & 100 deletions next/components/molecules/KnowOurServices.js

This file was deleted.

8 changes: 3 additions & 5 deletions next/components/molecules/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { triggerGAEvent } from "../../utils";

import BDLogoProImage from "../../public/img/logos/bd_logo_pro";
import BDLogoEduImage from "../../public/img/logos/bd_logo_edu";
import BDLogoLabImage from "../../public/img/logos/bd_logo_lab";
import BDLogoImage from "../../public/img/logos/bd_logo";
import FarBarsIcon from "../../public/img/icons/farBarsIcon";
import SearchIcon from "../../public/img/icons/searchIcon";
Expand Down Expand Up @@ -814,11 +815,8 @@ export default function MenuNav({ simpleTemplate = false, userTemplate = false }
Dados: "/dataset",
Soluções: [
{icon: <BDLogoProImage widthImage="54px"/>, name: "Dados exclusivos", href: "https://info.basedosdados.org/bd-pro"},
{icon: <BDLogoEduImage widthImage="54px"/>, name: "Curso de dados", href: "https://info.basedosdados.org/bd-edu-python"},
{},
{name: "Serviço", href: "/servicos"},
{},
{name: "Estudos de caso", href: "/estudos-de-caso"}
{icon: <BDLogoEduImage widthImage="54px"/>, name: "Curso de dados", href: "https://info.basedosdados.org/bd-edu-sql"},
{icon: <BDLogoLabImage widthImage="54px"/>, name: "Serviços", href: "/servicos"},
],
"Preços": "/precos",
Tutoriais: [
Expand Down
30 changes: 5 additions & 25 deletions next/components/molecules/ThemeCatalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import { useMediaQuery } from "@chakra-ui/react";
import { useCheckMobile } from "../../hooks/useCheckMobile.hook";
import { triggerGAEvent } from "../../utils";

import {
getAllThemes,
getAllDatasets,
getDatasetsByThemes
} from "../../pages/api/themes/index"
import { getDatasetsByThemes } from "../../pages/api/themes/index"

import Carousel from "../atoms/Carousel";
import SectionText from "../atoms/SectionText";
Expand Down Expand Up @@ -275,7 +271,7 @@ function CardThemes ({ responsive, datasetsCards = [], loading }) {
)
}

export default function ThemeCatalog () {
export default function ThemeCatalog ({ data }) {
const [listThemes, setListThemes] = useState([])
const [defaultDatasetsCards, setDefaultDatasetCards] = useState([])
const [fetchThemesTimeout, setFetchThemesTimeout] = useState(null)
Expand All @@ -293,27 +289,11 @@ export default function ThemeCatalog () {

useEffect(() => {
setMobileQuery(mobileCheck)
fetchData()
},[])

const fetchData = async () => {
const promises = []
promises.push(fetchThemes())
promises.push(fetchDatasets())
await Promise.all(promises)
setListThemes(data.themes)
setDefaultDatasetCards(data.defaultDataset)
setLoading(false)
setLoadingTheme(false)
}

const fetchDatasets = async () => {
const defaultDataset = await getAllDatasets()
setDefaultDatasetCards(defaultDataset)
}

const fetchThemes = async () => {
const themes = await getAllThemes()
setListThemes(themes)
}
},[data])

useEffect(() => {
if(selectedTheme.length > 0) {
Expand Down
5 changes: 0 additions & 5 deletions next/components/organisms/BdmTablePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import UserIcon from "../../public/img/icons/userIcon";
import VersionIcon from "../../public/img/icons/versionIcon";
import EmailIcon from "../../public/img/icons/emailIcon";
import GithubIcon from "../../public/img/icons/githubIcon";
import CkanIcon from "../../public/img/icons/ckanIcon";
import WebIcon from "../../public/img/icons/webIcon";
import TwitterIcon from "../../public/img/icons/twitterIcon";
import FileIcon from "../../public/img/icons/fileIcon";
Expand Down Expand Up @@ -117,10 +116,6 @@ export default function BdmTablePage({ id }) {
href = `mailto:${ref.email}`
alt= "email do contribuidor"
}
if(ref.ckan_user) {
href = `/user/${ref.ckan_user}`
alt = "usuário ckan"
}
if(ref.website) {
const website = ref.website.replace(/(https?:)\/\//gim, "")
href = `https://${website}`
Expand Down
5 changes: 2 additions & 3 deletions next/components/templates/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Footer from "../molecules/Footer";
import Menu from "../molecules/Menu";

export function MainPageTemplate({
pages,
children,
backgroundColor = "#FFFFFF",
cleanTemplate = false,
Expand All @@ -15,15 +14,15 @@ export function MainPageTemplate({
return (
<Box backgroundColor={backgroundColor}>
<SiteHead />
<Menu pages={pages} simpleTemplate={cleanTemplate} userTemplate={userTemplate}/>
<Menu simpleTemplate={cleanTemplate} userTemplate={userTemplate}/>
<Box
paddingTop="72px"
paddingBottom="50px"
{...style}
>
{children}
</Box>
<Footer pages={pages} ocult={cleanTemplate || userTemplate}/>
<Footer ocult={cleanTemplate || userTemplate}/>
</Box>
);
}
6 changes: 0 additions & 6 deletions next/hooks/pages.hook.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
// import { getPages } from "../pages/api/pages";

export async function withPages(staticProps = null) {
// let { data: pages } = await getPages();

if (staticProps == null) {
staticProps = {
props: {},
Expand All @@ -14,7 +10,5 @@ export async function withPages(staticProps = null) {
staticProps.props = {};
}

// staticProps.props.pages = pages;

return staticProps;
}
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
4 changes: 2 additions & 2 deletions next/pages/blog/[pageId].js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function BlogPage({ pages = [] }) {

if (!data)
return (
<MainPageTemplate pages={pages}>
<MainPageTemplate>
<Center
minHeight="600px"
width="100%"
Expand All @@ -78,7 +78,7 @@ function BlogPage({ pages = [] }) {
return null

return (
<MainPageTemplate pages={pages}>
<MainPageTemplate>
<VStack
alignItems="center"
width="100%"
Expand Down
Loading

0 comments on commit 37a1ab9

Please sign in to comment.