fix: Product form TypeScript and API errors
Fixed Issues: 1. TypeScript error on .indeterminate property (line 332) - Cast checkbox element to any for indeterminate access 2. API error handling for categories/tags endpoints - Added is_wp_error() checks - Return empty array on error instead of 500 Next: Implement modern tabbed product form (Shopify-style)
This commit is contained in:
@@ -329,7 +329,11 @@ export default function Products() {
|
|||||||
<th className="w-12 p-3">
|
<th className="w-12 p-3">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={allSelected}
|
checked={allSelected}
|
||||||
ref={(el) => el && (el.indeterminate = someSelected && !allSelected)}
|
ref={(el) => {
|
||||||
|
if (el) {
|
||||||
|
(el as any).indeterminate = someSelected && !allSelected;
|
||||||
|
}
|
||||||
|
}}
|
||||||
onCheckedChange={toggleAll}
|
onCheckedChange={toggleAll}
|
||||||
aria-label={__('Select all')}
|
aria-label={__('Select all')}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -347,6 +347,10 @@ class ProductsController {
|
|||||||
'hide_empty' => false,
|
'hide_empty' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (is_wp_error($terms)) {
|
||||||
|
return new WP_REST_Response([], 200); // Return empty array on error
|
||||||
|
}
|
||||||
|
|
||||||
$categories = [];
|
$categories = [];
|
||||||
foreach ($terms as $term) {
|
foreach ($terms as $term) {
|
||||||
$categories[] = [
|
$categories[] = [
|
||||||
@@ -370,6 +374,10 @@ class ProductsController {
|
|||||||
'hide_empty' => false,
|
'hide_empty' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (is_wp_error($terms)) {
|
||||||
|
return new WP_REST_Response([], 200); // Return empty array on error
|
||||||
|
}
|
||||||
|
|
||||||
$tags = [];
|
$tags = [];
|
||||||
foreach ($terms as $term) {
|
foreach ($terms as $term) {
|
||||||
$tags[] = [
|
$tags[] = [
|
||||||
|
|||||||
Reference in New Issue
Block a user