Commit 504c8d87 authored by Rémy Huet's avatar Rémy Huet 💻

Add to collection on create

parent 8abe90bf
Pipeline #30929 passed with stage
in 53 seconds
......@@ -24,9 +24,10 @@ export function deleteCategory(token, id) {
}
export function createCategory(token, data) {
console.log(data);
return {
type: 'CREATE_CATEGORY',
payload: axios.post(`${env.api_uri}/api/v1/categories`, data,
payload: axios.post(`${env.api_uri}/api/v1/categories`, { parent_id: data.parentId, ...data },
{
headers: { Authorization: `Bearer ${token}` },
}),
......
......@@ -23,7 +23,7 @@ export default function reducer(state = initialState, action) {
}
case ('DELETE_CATEGORY_PENDING'): {
return {
...state,
...state, // TODO
};
}
case ('DELETE_CATEGORY_FULFILLED'): {
......@@ -32,6 +32,17 @@ export default function reducer(state = initialState, action) {
categories: state.categories.filter(category => category.id !== action.payload.data.id),
};
}
case ('CREATE_CATEGORY_PENDING'): {
return {
...state, // TODO
};
}
case ('CREATE_CATEGORY_FULFILLED'): {
return {
...state,
categories: [...state.categories, action.payload.data],
};
}
default: {
return state;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment