select-harlequinS
Refine2y ago
19 replies
select-harlequin

Return nothing

If I don't want to return anything in the case when getBusiness().id returns null in the permanent filter, how would I achieve that?

export const DiscountList = ({ children }: React.PropsWithChildren) => {
  useDocumentTitle('Discounts - Applausio');
  const go = useGo();
  const { tableProps, filters } = useTable({
    resource: 'discounts',
    onSearch: (values: any) => {
      return [
        {
          field: 'name',
          operator: 'contains',
          value: values.name,
        },
      ];
    },
    pagination: {
      pageSize: 20,
    },
    sorters: {
      initial: [
        {
          field: 'created',
          order: 'desc',
        },
      ],
    },
    filters: {
      permanent: [
        {
          field: 'business.id',
          operator: 'eq',
          value: getBusiness().id,
        },
      ],
      initial: [
        {
          field: 'name',
          operator: 'contains',
          value: undefined,
        },
      ],
    },
    meta: {
      gqlQuery: DISCOUNTS_QUERY,
    },
  });
Was this page helpful?