-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Line 2:23: PayloadAction not found in '@reduxjs/toolkit' import/named
code:
// import { signInWithEmailAndPassword, firebaseAuth } from '@config/firebase.config';
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { getAuth, signInWithEmailAndPassword } from 'firebase/auth';
const auth = getAuth();
interface AuthSliceState {
userName: string;
password: string;
}
const initialState = {
isAuthenticating: false,
auth: {},
};
export const authSlice = createSlice({
name: 'auth',
initialState,
reducers: {
AUTHENTICATE: (state, action: PayloadAction) => {
console.log(action);
state.isAuthenticating = true;
state.auth = action.payload ?? ' ';
const email = action.payload.userName;
const password = action.payload.password;
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in
const user = userCredential.user;
console.log(user);
// ...
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
console.log(errorCode, errorMessage);
});
},
AUTHENTICATION_DONE: (state) => {
state.isAuthenticating = false;
},
},
});
export const { AUTHENTICATE, AUTHENTICATION_DONE } = authSlice.actions;
export default authSlice.reducer;