va-tracker/src/ui/store/profileSlice.tsx

62 lines
1.3 KiB
TypeScript

import { createSlice, PayloadAction } from "@reduxjs/toolkit";
interface ProfileData {
firstName: string;
lastName: string;
email: string;
dob: string;
age: string;
address: string;
bankName: string;
accountHolderName: string;
accountNumber: string;
routingNumber: string;
phone:string;
skype:string;
city:string;
state:string;
country:string;
paymentMethod:string;
payoneerAccount:string;
veemAccount:string;
wiseEmail:string
_id: string;
}
interface ProfileState {
profile: ProfileData | null;
loading: boolean;
error: string | null;
}
const initialState: ProfileState = {
profile: null,
loading: false,
error: null,
};
const profileSlice = createSlice({
name: "profile",
initialState,
reducers: {
setLoading: (state, action: PayloadAction<boolean>) => {
state.loading = action.payload;
},
setProfile: (state, action: PayloadAction<ProfileData>) => {
state.profile = action.payload;
state.error = null;
},
setError: (state, action: PayloadAction<string | null>) => {
state.error = action.payload;
},
clearProfile: (state) => {
state.profile = null;
state.error = null;
state.loading = false;
},
},
});
export const { setLoading, setProfile, setError, clearProfile } = profileSlice.actions;
export default profileSlice.reducer;