import React, { useEffect, useState } from "react"; import { Button, PageSection, Spinner } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; import { useHistory } from "react-router-dom"; import ClientRepresentation from "keycloak-admin/lib/defs/clientRepresentation"; import { TableToolbar } from "../components/table-toolbar/TableToolbar"; import { ClientScopeList } from "./ClientScopesList"; import { ViewHeader } from "../components/view-header/ViewHeader"; import { useAdminClient } from "../context/auth/AdminClient"; export const ClientScopesSection = () => { const { t } = useTranslation("client-scopes"); const history = useHistory(); const [rawData, setRawData] = useState(); const [filteredData, setFilteredData] = useState(); const adminClient = useAdminClient(); useEffect(() => { (async () => { if (filteredData) { return filteredData; } const result = await adminClient.clientScopes.find(); setRawData(result); })(); }, []); const filterData = (search: string) => { setFilteredData( rawData!.filter((group) => group.name!.toLowerCase().includes(search.toLowerCase()) ) ); }; return ( <> {!rawData && (
)} {rawData && ( history.push("/client-scopes/new")}> {t("createClientScope")} } > )}
); };