refactor(actions): return only serializable fields in product actions

This commit is contained in:
Nils-Johan Gynther
2026-04-19 17:28:28 +02:00
parent 7f51829462
commit 40b0d5fd3a
+15 -2
View File
@@ -20,7 +20,13 @@ export async function createProductAction(name: string) {
throw new Error(e.message ?? `HTTP ${res.status}`);
}
return res.json();
const product = await res.json();
// Return only serializable fields (Dates can't be serialized across RSC boundary)
return {
id: product.id,
name: product.name,
canonicalName: product.canonicalName,
};
}
export async function updateProductCategoryAction(productId: number, categoryId: number) {
@@ -37,5 +43,12 @@ export async function updateProductCategoryAction(productId: number, categoryId:
throw new Error(e.message ?? `HTTP ${res.status}`);
}
return res.json();
const product = await res.json();
// Return only serializable fields
return {
id: product.id,
name: product.name,
canonicalName: product.canonicalName,
categoryId: product.categoryId,
};
}