Skip to content

Commit

Permalink
fix(dhis2): fixed tests parameter field
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarfil committed Feb 18, 2025
1 parent 8a1af87 commit 4606db7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ export type GetConnectionBySlugQueryVariables = Types.Exact<{
}>;


export type GetConnectionBySlugQuery = { __typename?: 'Query', connectionBySlug?: { __typename?: 'CustomConnection' } | { __typename?: 'DHIS2Connection', queryMetadata: { __typename?: 'DHIS2QueryResultPage', totalItems: number, error?: Types.Dhis2ConnectionError | null, items?: Array<{ __typename?: 'DHIS2MetadataItem', id?: string | null, name: string } | { __typename?: 'DHIS2OrganisationUnitLevel', id?: string | null, name: string, level?: number | null }> | null } } | { __typename?: 'GCSConnection' } | { __typename?: 'IASOConnection' } | { __typename?: 'PostgreSQLConnection' } | { __typename?: 'S3Connection' } | null };
export type GetConnectionBySlugQuery = { __typename?: 'Query', connectionBySlug?: { __typename: 'CustomConnection' } | { __typename: 'DHIS2Connection', queryMetadata: { __typename?: 'DHIS2QueryResultPage', totalItems: number, error?: Types.Dhis2ConnectionError | null, items?: Array<{ __typename?: 'DHIS2MetadataItem', id?: string | null, name: string } | { __typename?: 'DHIS2OrganisationUnitLevel', id?: string | null, name: string, level?: number | null }> | null } } | { __typename: 'GCSConnection' } | { __typename: 'IASOConnection' } | { __typename: 'PostgreSQLConnection' } | { __typename: 'S3Connection' } | null };


export const GetConnectionBySlugDocument = gql`
query getConnectionBySlug($workspaceSlug: String!, $connectionSlug: String!, $type: String!, $search: String, $perPage: Int, $page: Int) {
connectionBySlug(workspaceSlug: $workspaceSlug, connectionSlug: $connectionSlug) {
__typename
... on DHIS2Connection {
queryMetadata(type: $type, search: $search, perPage: $perPage, page: $page) {
items {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { gql } from "@apollo/client";
import React, { useCallback, useEffect, useMemo, useState } from "react";
import { useTranslation } from "next-i18next";
import {
Combobox,
MultiCombobox,
} from "../../../core/components/forms/Combobox";
import useDebounce from "../../../core/hooks/useDebounce";
import {
GetConnectionBySlugQuery,
useGetConnectionBySlugLazyQuery,
} from "./GenericConnectionWidget.generated";
import useIntersectionObserver from "../../../core/hooks/useIntersectionObserver";
import { Combobox, MultiCombobox } from "core/components/forms/Combobox";
import useDebounce from "core/hooks/useDebounce";
import { useGetConnectionBySlugLazyQuery } from "./GenericConnectionWidget.generated";
import useIntersectionObserver from "core/hooks/useIntersectionObserver";

type GenericConnectionWidgetProps<T> = {
parameter: any;
Expand All @@ -31,6 +25,7 @@ export const GET_CONNECTION_METADATA = gql`
workspaceSlug: $workspaceSlug
connectionSlug: $connectionSlug
) {
__typename
... on DHIS2Connection {
queryMetadata(
type: $type
Expand Down Expand Up @@ -129,6 +124,11 @@ const GenericConnectionWidget = <T,>({
console.error("Error fetching connection metadata:", error);
return [];
}

if (data?.connectionBySlug?.__typename !== "DHIS2Connection") {
return { items: [], totalItems: 0 }; // Return empty if not DHIS2Connection
}

const items =
data?.connectionBySlug?.queryMetadata?.items?.filter((c) =>
c.name.toLowerCase().includes(debouncedQuery.toLowerCase()),
Expand Down

0 comments on commit 4606db7

Please # to comment.