upd: lembaga desa
Deskripsi: - list data lembaga desa - tambah data lembaga desa - edit data lembaga desa - pencarian data lembaga desa - delete data lembaga desa No Issues
This commit is contained in:
33
lib/api.ts
33
lib/api.ts
@@ -49,6 +49,39 @@ export const apiGetDataHome = async ({ cat, user }: { cat: 'kegiatan' | 'divisio
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiGetGroup = async ({ user, active, search }: { user: string, active: string, search: string }) => {
|
||||
const response = await api.get(`mobile/group?user=${user}&active=${active}&search=${search}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiCreateGroup = async (data: { user: string, name: string }) => {
|
||||
await api.post('mobile/group', data).then(response => {
|
||||
return response.data;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
};
|
||||
|
||||
export const apiEditGroup = async (data: { user: string, name: string }, id: string) => {
|
||||
await api.put(`mobile/group/${id}`, data).then(response => {
|
||||
return response.data;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
};
|
||||
|
||||
export const apiDeleteGroup = async (data: { user: string, isActive: boolean }, id: string) => {
|
||||
await api.delete(`mobile/group/${id}`, { data }).then(response => {
|
||||
return response.data;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// export const updateEntityById = async (id: any, updatedEntity: any) => {
|
||||
// const response = await api.put(`/entities/${id}`, updatedEntity);
|
||||
// return response.data;
|
||||
|
||||
14
lib/groupSlice.ts
Normal file
14
lib/groupSlice.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
|
||||
const groupUpdate = createSlice({
|
||||
name: 'groupUpdate',
|
||||
initialState: false,
|
||||
reducers: {
|
||||
setUpdateGroup: (state, action) => {
|
||||
return action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setUpdateGroup } = groupUpdate.actions;
|
||||
export default groupUpdate.reducer;
|
||||
@@ -1,6 +1,7 @@
|
||||
import { configureStore } from '@reduxjs/toolkit';
|
||||
import bannerReducer from './bannerSlice';
|
||||
import entitiesReducer from './entitiesSlice';
|
||||
import groupUpdate from './groupSlice';
|
||||
import userReducer from './userSlice';
|
||||
|
||||
|
||||
@@ -8,7 +9,8 @@ const store = configureStore({
|
||||
reducer: {
|
||||
entities: entitiesReducer,
|
||||
banner: bannerReducer,
|
||||
user: userReducer
|
||||
user: userReducer,
|
||||
groupUpdate: groupUpdate
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user