Skip to content

Line 2:23: PayloadAction not found in '@reduxjs/toolkit' import/named #1877

@jeyakumar-BTR

Description

@jeyakumar-BTR

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions