Prechádzať zdrojové kódy

feat(dashboard): Enable filtering products & variants by SKU

Michael Bromley 2 mesiacov pred
rodič
commit
dc7cabf7bb

+ 12 - 1
packages/dashboard/src/app/routes/_authenticated/_product-variants/product-variants.tsx

@@ -77,8 +77,19 @@ function ProductListPage() {
                 },
             }}
             onSearchTermChange={searchTerm => {
+                return searchTerm
+                    ? {
+                          name: { contains: searchTerm },
+                          sku: { contains: searchTerm },
+                      }
+                    : {};
+            }}
+            transformVariables={variables => {
                 return {
-                    name: { contains: searchTerm },
+                    options: {
+                        ...variables.options,
+                        filterOperator: 'OR',
+                    },
                 };
             }}
             route={Route}

+ 13 - 1
packages/dashboard/src/app/routes/_authenticated/_products/products.tsx

@@ -54,8 +54,20 @@ function ProductListPage() {
                 },
             }}
             onSearchTermChange={searchTerm => {
+                return searchTerm
+                    ? {
+                          name: { contains: searchTerm },
+                          slug: { contains: searchTerm },
+                          sku: { contains: searchTerm },
+                      }
+                    : {};
+            }}
+            transformVariables={variables => {
                 return {
-                    name: { contains: searchTerm },
+                    options: {
+                        ...variables.options,
+                        filterOperator: 'OR',
+                    },
                 };
             }}
             defaultVisibility={{