This commit is contained in:
2025-10-09 09:02:15 +07:00
parent f7c96a0258
commit 4b11ee2180
4 changed files with 50 additions and 5 deletions

View File

@@ -1,16 +1,19 @@
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import type { User } from "../../types/user.type";
import { Apis } from "../../apis";
import type { CartItem } from "../../types/cart.type";
interface UserState {
data: User | null,
loading: boolean;
cart: CartItem[] | []
}
const InitUserState: UserState = {
data: null,
loading: false
loading: false,
cart: []
}
@@ -18,7 +21,9 @@ const userSlice = createSlice({
name: "user",
initialState: InitUserState,
reducers: {
initCartData: (state, action) =>{
state.cart = action.payload
}
},
extraReducers: (bd) => {
bd.addCase(fetchUserData.pending, (state, action) => {