mirror of
https://github.com/rjNemo/devbook_ts
synced 2026-06-09 20:16:43 +00:00
* 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
36 lines
704 B
TypeScript
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;
|