diff --git a/client/src/components/LoggedInUser.js b/client/src/components/LoggedInUser.js
new file mode 100644
index 000000000..888dcf174
--- /dev/null
+++ b/client/src/components/LoggedInUser.js
@@ -0,0 +1,49 @@
+import React, { Component } from 'react';
+import {graphql} from 'react-apollo';
+import {getUserByAuthIdQuery} from '../queries/queries';
+
+class LoggedInUser extends Component {
+
+ displayLoggedInUser(){
+
+ const user = this.props.data.userByAuthId;
+ console.log(this.props);
+ if(user){
+ if (user.firstName) {
+ return(
+
+ );
+ } else {
+ return(
+
+ );
+ }
+
+ } else {
+ return( Login / Sign up
);
+ }
+ }
+
+ render() {
+
+ return (
+
+ {this.displayLoggedInUser()}
+
+ );
+ }
+}
+
+export default graphql(getUserByAuthIdQuery, { // What follows is the way to pass a parameter to a query.
+ options: (props) => {
+ return {
+ variables: {
+ id: props.authId
+ }
+ }
+ }
+})(LoggedInUser); // This binds the querty to the component
diff --git a/client/src/components/Material-UI/ButtonAppBar.js b/client/src/components/Material-UI/ButtonAppBar.js
index bcde20091..8bfcec8ec 100644
--- a/client/src/components/Material-UI/ButtonAppBar.js
+++ b/client/src/components/Material-UI/ButtonAppBar.js
@@ -18,6 +18,9 @@ import ModulesIcon from '@material-ui/icons/QueuePlayNext';
import { Link } from 'react-router-dom';
+// components
+import LoggedInUser from '../LoggedInUser';
+
const AboutLink = props =>
const ContactLink = props =>
const SearchLink = props =>
@@ -58,6 +61,8 @@ function ButtonAppBar(props) {
+
+
diff --git a/client/src/components/Navbar.js b/client/src/components/Navbar.js
deleted file mode 100644
index add70af3e..000000000
--- a/client/src/components/Navbar.js
+++ /dev/null
@@ -1,52 +0,0 @@
-import React from 'react';
-import { NavLink, withRouter } from 'react-router-dom'
-
-// Images
-
-import AALogo from '../img/aa-logo-dark-8.png'
-
-const Navbar = (props) => {
- return (
-
-
-
- )
-}
-
-export default withRouter(Navbar)
diff --git a/client/src/queries/queries.js b/client/src/queries/queries.js
index d649b9127..0ac40aeda 100644
--- a/client/src/queries/queries.js
+++ b/client/src/queries/queries.js
@@ -30,6 +30,20 @@ query($id: ID){
}
`
+const getUserByAuthIdQuery = gql`
+query($authId: String){
+ userByAuthId (authId: $authId){
+ id
+ alias
+ firstName
+ lastName
+ role {
+ id
+ }
+ }
+}
+`
+
const getRolesQuery = gql`
{
roles {
@@ -56,4 +70,4 @@ mutation($id: ID!, $firstName:String, $lastName:String, $isDeveloper:Int, $isTra
}
}
`
-export {getUsersQuery, getRolesQuery, addUserMutation, updateUserMutation, getUserProfileQuery}
+export {getUsersQuery, getUserByAuthIdQuery, getRolesQuery, addUserMutation, updateUserMutation, getUserProfileQuery}