Browse Source

fix(dashboard): Fix sort & filter on Promotion list

Michael Bromley 3 months ago
parent
commit
676c45ec44

+ 2 - 2
packages/dashboard/src/app/routes/_authenticated/_promotions/promotions.graphql.ts

@@ -2,8 +2,8 @@ import { configurableOperationFragment } from '@/vdb/graphql/fragments.js';
 import { graphql } from '@/vdb/graphql/graphql.js';
 
 export const promotionListDocument = graphql(`
-    query PromotionList {
-        promotions {
+    query PromotionList($options: PromotionListOptions) {
+        promotions(options: $options) {
             items {
                 id
                 createdAt

+ 8 - 0
packages/dashboard/src/app/routes/_authenticated/_promotions/promotions.tsx

@@ -41,6 +41,14 @@ function PromotionListPage() {
                     couponCode: { contains: searchTerm },
                 };
             }}
+            transformVariables={variables => {
+                return {
+                    options: {
+                        ...variables.options,
+                        filterOperator: 'OR' as const,
+                    },
+                };
+            }}
             customizeColumns={{
                 name: {
                     cell: ({ row }) => <DetailPageButton id={row.original.id} label={row.original.name} />,

+ 1 - 1
packages/dashboard/src/lib/components/data-table/use-generated-columns.tsx

@@ -113,7 +113,7 @@ export function useGeneratedColumns<T extends TypedDocumentNode<any, any>>({
                 id: fieldInfo.name,
                 meta: { fieldInfo, isCustomField },
                 enableColumnFilter,
-                enableSorting: fieldInfo.isScalar && enableSorting,
+                enableSorting: fieldInfo.isScalar && fieldInfo.type !== 'Boolean' && enableSorting,
                 // Filtering is done on the server side, but we set this to 'equalsString' because
                 // otherwise the TanStack Table with apply an "auto" function which somehow
                 // prevents certain filters from working.