install firestore

This commit is contained in:
Ruidy Nemausat 2020-05-13 18:40:26 +02:00
parent 0196ab4b9a
commit e87094170e
3 changed files with 14 additions and 13 deletions

View file

@ -3,20 +3,22 @@ import React, {FC} from 'react';
import {Link} from 'react-router-dom'; import {Link} from 'react-router-dom';
import * as ROUTES from '../constants/routes'; import * as ROUTES from '../constants/routes';
//Redux //Redux
// import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {selectProfile} from '../store/firebase';
// import {selectAuthState} from '../store/auth'; // import {selectAuthState} from '../store/auth';
// Style // Style
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faCode, faSignOutAlt, faUser} from '@fortawesome/free-solid-svg-icons'; import {faCode, faSignOutAlt, faUser} from '@fortawesome/free-solid-svg-icons';
interface IProps { interface IProps {
isAuthenticated?: boolean; isEmpty: boolean;
loading?: boolean; isLoaded: boolean;
} }
/** /**
* Main Navbar serves navigation routes. * Main Navbar serves navigation routes.
*/ */
const NavBar: FC<IProps> = ({isAuthenticated = true, loading = false}) => { const NavBar: FC<IProps> = ({isEmpty, isLoaded}) => {
const publicLinks = ( const publicLinks = (
<ul data-testid="publicLinks"> <ul data-testid="publicLinks">
<li> <li>
@ -65,7 +67,7 @@ const NavBar: FC<IProps> = ({isAuthenticated = true, loading = false}) => {
); );
/** Display appropriated links after loading given authenticated prop */ /** Display appropriated links after loading given authenticated prop */
const RenderLinks = !loading && isAuthenticated ? privateLinks : publicLinks; const RenderLinks = !isLoaded && !isEmpty ? privateLinks : publicLinks;
return ( return (
<nav className="navbar bg-dark"> <nav className="navbar bg-dark">
@ -80,5 +82,5 @@ const NavBar: FC<IProps> = ({isAuthenticated = true, loading = false}) => {
}; };
/** connect HOC subscribes to the store */ /** connect HOC subscribes to the store */
export default NavBar; export default connect(selectProfile)(NavBar);
//connect(selectAuthState)(NavBar); //NavBar;

View file

@ -2,3 +2,5 @@ import {RootState} from '..';
/** export firebase authentication */ /** export firebase authentication */
export const selectAuthState = (state: RootState) => state.firebase.auth; export const selectAuthState = (state: RootState) => state.firebase.auth;
/** export current user profile */
export const selectProfile = (state: RootState) => state.firebase.profile;

View file

@ -1,12 +1,9 @@
// Redux // Redux
import {configureStore} from '@reduxjs/toolkit'; import {configureStore} from '@reduxjs/toolkit';
import authReducer from './auth/'; // import authReducer from './auth/';
// Firebase // Firebase
import { import {firebaseReducer, FirebaseReducer} from 'react-redux-firebase';
firebaseReducer, import {firestoreReducer} from 'redux-firestore';
FirebaseReducer,
firestoreReducer,
} from 'react-redux-firebase';
// Typing // Typing
import User from '../models/User'; import User from '../models/User';
import {Schema} from './firebase/config'; import {Schema} from './firebase/config';