Skip to content

Commit

Permalink
fix: remove default values on AllCollectives filter (#10530)
Browse files Browse the repository at this point in the history
  • Loading branch information
kewitz authored Jul 9, 2024
1 parent 01e4527 commit 93e7393
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions components/dashboard/sections/collectives/AllCollectives.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useMemo } from 'react';
import { useQuery } from '@apollo/client';
import { compact, isString, omit } from 'lodash';
import { compact, isEmpty, isString, omit } from 'lodash';
import { useRouter } from 'next/router';
import { defineMessage, FormattedMessage, useIntl } from 'react-intl';
import { z } from 'zod';
Expand Down Expand Up @@ -97,12 +97,13 @@ const AllCollectives = ({ subpath }: Omit<DashboardSectionProps, 'accountSlug'>)
const [showCollectiveOverview, setShowCollectiveOverview] = React.useState<Collective | undefined | string>(
subpath[0],
);
const query = useMemo(() => omit(router.query, ['slug', 'section', 'subpath']), [router.query]);

const pushSubpath = subpath => {
router.push(
{
pathname: compact([router.pathname, router.query.slug, router.query.section, subpath]).join('/'),
query: omit(router.query, ['slug', 'section', 'subpath']),
query,
},
undefined,
{
Expand All @@ -115,16 +116,14 @@ const AllCollectives = ({ subpath }: Omit<DashboardSectionProps, 'accountSlug'>)
filters,
schema,
toVariables,
defaultFilterValues: {
host: 'opencollective',
},
meta: { currency: 'USD' },
});

const { data, error, loading, refetch } = useQuery(allCollectivesQuery, {
variables: queryFilter.variables,
context: API_V2_CONTEXT,
fetchPolicy: 'cache-and-network',
skip: isEmpty(query),
});

useEffect(() => {
Expand Down Expand Up @@ -153,7 +152,7 @@ const AllCollectives = ({ subpath }: Omit<DashboardSectionProps, 'accountSlug'>)
<DashboardHeader title={<FormattedMessage defaultMessage="All Collectives" id="uQguR/" />} />
<Filterbar {...queryFilter} />
{error && <MessageBoxGraphqlError error={error} mb={2} />}
{!error && !loading && !hostedAccounts?.nodes.length ? (
{!error && !loading && !hostedAccounts?.nodes.length && !isEmpty(query) ? (
<EmptyResults
hasFilters={queryFilter.hasFilters}
entityType="COLLECTIVES"
Expand Down

0 comments on commit 93e7393

Please sign in to comment.