upd:banner home
deskripsi: - load banner di halaman home - nb : blm selesai No Issues
This commit is contained in:
@@ -20,11 +20,16 @@ export const apiGetProfile = async ({ id }: { id: string }) => {
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiGetSearch = async ({ text, user }: { text: string, user:string }) => {
|
||||
export const apiGetSearch = async ({ text, user }: { text: string, user: string }) => {
|
||||
const response = await api.get(`mobile/home/search?search=${text}&user=${user}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiGetBanner = async ({ user }: { user: string }) => {
|
||||
const response = await api.get(`mobile/banner?user=${user}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
|
||||
// export const createEntity = async (newEntity: any) => {
|
||||
// const response = await api.post('/entities', newEntity);
|
||||
|
||||
29
lib/bannerSlice.ts
Normal file
29
lib/bannerSlice.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
|
||||
const bannerSlice = createSlice({
|
||||
name: 'banner',
|
||||
initialState: [],
|
||||
reducers: {
|
||||
setEntities: (state, action) => {
|
||||
return action.payload;
|
||||
},
|
||||
|
||||
addEntity: (state: any, action: any) => {
|
||||
state.push(action.payload);
|
||||
},
|
||||
updateEntity: (state: any, action) => {
|
||||
const { id, updatedEntity } = action.payload;
|
||||
const index = state.findIndex((entity: any) => entity.id === id);
|
||||
if (index !== -1) {
|
||||
state[index] = updatedEntity;
|
||||
}
|
||||
},
|
||||
// removeEntity: (state, action) => {
|
||||
// const idToRemove = action.payload;
|
||||
// return state.filter((entity: any) => entity.id !== idToRemove);
|
||||
// },
|
||||
},
|
||||
});
|
||||
|
||||
export const { setEntities, addEntity, updateEntity } = bannerSlice.actions;
|
||||
export default bannerSlice.reducer;
|
||||
11
lib/store.ts
11
lib/store.ts
@@ -1,11 +1,18 @@
|
||||
import { configureStore } from '@reduxjs/toolkit';
|
||||
import { combineReducers, combineSlices, configureStore } from '@reduxjs/toolkit';
|
||||
import bannerReducer from './bannerSlice';
|
||||
import entitiesReducer from './entitiesSlice';
|
||||
|
||||
|
||||
const reducer = combineSlices({
|
||||
entitiesReducer,bannerReducer
|
||||
})
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
entities: entitiesReducer,
|
||||
banner: bannerReducer,
|
||||
}
|
||||
// Add other reducers as needed
|
||||
},
|
||||
});
|
||||
|
||||
export default store;
|
||||
Reference in New Issue
Block a user