mirror of
https://github.com/rjNemo/devbook_ts
synced 2026-06-12 13:36:43 +00:00
install firestore
This commit is contained in:
parent
0196ab4b9a
commit
e87094170e
3 changed files with 14 additions and 13 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue