import { createSlice, PayloadAction } from '@reduxjs/toolkit' import { GetProfileProps, ProfileProps, ProfileState } from './types' export const initialProfileState: ProfileState = { loading: { loadingGetProfile: false, }, profileData: null, } export const profileSlice = createSlice({ name: 'profile', initialState: initialProfileState, reducers: { save(state, action: PayloadAction) { const { payload } = action return { ...state, ...payload, } }, // ============= login with meta mask ============= getProfile(state, _action: PayloadAction) { state.loading.loadingGetProfile = true }, getProfileSuccess(state, action: PayloadAction) { state.profileData = action.payload state.loading.loadingGetProfile = false }, getProfileFailed(state) { state.loading.loadingGetProfile = false }, }, }) const { reducer } = profileSlice export const { actions: profileActions } = profileSlice export default reducer