refactor(actions): return only serializable fields in product actions
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user