Skip to content

Commit

Permalink
fix: add check for listId to hooks (#1869)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts authored Oct 11, 2023
1 parent 92f9790 commit 4bde212
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/hooks/api/useContributionsByProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const useContributionsByProject = ({
initialData?: DbProjectContributions[];
}) => {
const { data, error } = useSWR<DbProjectContributions[]>(
`lists/${listId}/stats/contributions-by-project?range=${range}`,
listId ? `lists/${listId}/stats/contributions-by-project?range=${range}` : null,
publicApiFetcher as Fetcher<DbProjectContributions[], Error>
// {
// fallbackData: {
Expand Down
2 changes: 1 addition & 1 deletion lib/hooks/api/useContributorList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const useContributorsList = ({
query.append("range", range.toString());

const { data, error, mutate } = useSWR<any>(
`lists/${listId}/contributors?${query}`,
listId ? `lists/${listId}/contributors?${query}` : null,
publicApiFetcher as Fetcher<PagedData<DBListContributor>, Error>,
{
fallbackData: initialData,
Expand Down
2 changes: 1 addition & 1 deletion lib/hooks/api/useContributorsByProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import publicApiFetcher from "lib/utils/public-api-fetcher";
export const useContributorsByProject = (listId: string, range: number) => {
const [repoId, setRepoId] = useState<number | null>(null);
const { data, error } = useSWR<DBProjectContributor[]>(
`lists/${listId}/stats/top-project-contributions-by-contributor?repo_id=${repoId}&range=${range}`,
listId ? `lists/${listId}/stats/top-project-contributions-by-contributor?repo_id=${repoId}&range=${range}` : null,
publicApiFetcher as Fetcher<DBProjectContributor[], Error>
);

Expand Down
2 changes: 1 addition & 1 deletion lib/hooks/api/useMostActiveContributors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const useMostActiveContributors = ({
const apiEndpoint = `lists/${listId}/stats/most-active-contributors?${query.toString()}`;

const { data, error, mutate } = useSWR<PaginatedResponse, Error>(
apiEndpoint,
listId ? apiEndpoint : null,
publicApiFetcher as Fetcher<PaginatedResponse, Error>
);

Expand Down

0 comments on commit 4bde212

Please sign in to comment.