devbook_ts/src/store/auth/index.ts
Ruidy 7333e3474b
Redux (#5)
* install redux and set authSlice

* connect navBar to the sotre

* create User type

* install react-redux-firebase

* bind to firebase

* connect App to firebase auth; display splash screen while loading auth state

* install firestore

* install firestore

* refactor tests

* edit env variables in ci

* refactor tests

* refactor tests

* edit env variables in ci
2020-05-13 19:40:23 +02:00

36 lines
704 B
TypeScript

// Redux
import {createSlice} from '@reduxjs/toolkit';
// Typing
import User from '../../models/User';
interface SliceState {
isAuthenticated: boolean;
loading: boolean;
user: User | null;
error: string | null;
}
const initialState: SliceState = {
isAuthenticated: false,
loading: true,
user: null,
error: null,
};
const authSlice = createSlice({
name: 'auth',
initialState,
reducers: {},
});
// export actions
export const {} = authSlice.actions;
// export selectors
// export const selectAuthState = (state: RootState) => {
// const {isAuthenticated, loading} = state.auth;
// return {isAuthenticated, loading};
// };
// export reducer
export default authSlice.reducer;