-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from gauravchl/develop
Build out front-end UI to make the calls to the backend
- Loading branch information
Showing
12 changed files
with
361 additions
and
100 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from "react"; | ||
import "./home.css"; | ||
|
||
function Home(props) { | ||
const { loading, error, data } = props; | ||
return ( | ||
<div className="home"> | ||
<header className="home-header"> | ||
<img | ||
src="https://codebuddies.org/images/logo.svg" | ||
className="home-logo" | ||
alt="logo" | ||
/> | ||
|
||
{loading ? <div>Loading Data from backend</div> : null} | ||
{error ? <div>Error loading data</div> : null} | ||
|
||
{data && data.resources && data.resources.map((r, i) => ( | ||
<div key={i}> | ||
{r.title} : {r.description} | ||
</div> | ||
))} | ||
</header> | ||
</div> | ||
); | ||
} | ||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// env: local || development || production | ||
|
||
const local = { | ||
graphUrl: 'http://localhost:8888/.netlify/functions/graphql', | ||
env: 'local', | ||
}; | ||
|
||
const config = { | ||
graphUrl: process.env.REACT_APP_GRAPH_URL || local.graphUrl, | ||
env: process.env.REACT_APP_ENV || local.env, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from "react"; | ||
import Home from "../components/home.js"; | ||
import { useQuery } from "@apollo/react-hooks"; | ||
import { RESOURCES } from "../queries/resources"; | ||
|
||
function HomeContainer() { | ||
const { loading, error, data } = useQuery(RESOURCES); | ||
|
||
return <Home loading={loading} error={error} data={data} />; | ||
} | ||
|
||
export default HomeContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { gql } from 'apollo-boost'; | ||
|
||
|
||
export const RESOURCES = gql` | ||
{ | ||
resources { | ||
title | ||
description | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from "react"; | ||
import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; | ||
import HomeContainer from "./containers/home"; | ||
import ApolloClient from "apollo-boost"; | ||
import { ApolloProvider } from "@apollo/react-hooks"; | ||
import config from './config' | ||
|
||
const client = new ApolloClient({ | ||
uri: config.graphUrl | ||
}); | ||
|
||
const Routes = () => { | ||
return ( | ||
<div> | ||
<ApolloProvider client={client}> | ||
<Router> | ||
<Switch> | ||
<Route path="/"> | ||
<HomeContainer /> | ||
</Route> | ||
</Switch> | ||
</Router> | ||
</ApolloProvider> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Routes; |