u
This commit is contained in:
@@ -361,9 +361,9 @@ export const category = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PATCH /api/category/:id [VORSCHLAG — Route/response fehlt noch in dashback]
|
* PATCH /api/category/:id
|
||||||
* Body: { parentId } — moves the category under a new parent.
|
* Body: { parentId } — moves the category under a new parent.
|
||||||
* → 200 { category: { id, parentId, name, slug } }
|
* → 200 { category: { id, parentId, sort } } (kein name/slug im Response)
|
||||||
*/
|
*/
|
||||||
move(categoryId, parentId) {
|
move(categoryId, parentId) {
|
||||||
return http(`/api/category/${categoryId}`, {
|
return http(`/api/category/${categoryId}`, {
|
||||||
|
|||||||
@@ -371,9 +371,14 @@ const categorySlice = createSlice({
|
|||||||
.addCase(moveCategory.fulfilled, (state, action) => {
|
.addCase(moveCategory.fulfilled, (state, action) => {
|
||||||
const moved = action.payload;
|
const moved = action.payload;
|
||||||
if (moved == null || state.categories == null) return;
|
if (moved == null || state.categories == null) return;
|
||||||
|
const existing = state.categories[String(moved.id)] ?? {};
|
||||||
|
// Der Move-Response enthält nur { id, parentId, sort } — keinen Namen.
|
||||||
|
// parentId/sort werden übernommen, der bestehende Name bleibt erhalten
|
||||||
|
// (das Backend hat ihn beim Move nicht verändert).
|
||||||
state.categories[String(moved.id)] = {
|
state.categories[String(moved.id)] = {
|
||||||
...(state.categories[String(moved.id)] ?? {}),
|
...existing,
|
||||||
...moved,
|
parentId: moved.parentId,
|
||||||
|
sort: moved.sort,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.addCase(createArticle.fulfilled, (state, action) => {
|
.addCase(createArticle.fulfilled, (state, action) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user