import React, { useContext, useEffect, useState } from "react"; import { Button, PageSection, Spinner } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; import { useHistory } from "react-router-dom"; import { RealmContext } from "../context/realm-context/RealmContext"; import { HttpClientContext } from "../context/http-service/HttpClientContext"; import { ClientRepresentation } from "../realm/models/Realm"; import { TableToolbar } from "../components/table-toolbar/TableToolbar"; import { ClientScopeList } from "./ClientScopesList"; import { ViewHeader } from "../components/view-header/ViewHeader"; export const ClientScopesSection = () => { const { t } = useTranslation("client-scopes"); const history = useHistory(); const [rawData, setRawData] = useState(); const [filteredData, setFilteredData] = useState(); const httpClient = useContext(HttpClientContext)!; const { realm } = useContext(RealmContext); useEffect(() => { (async () => { if (filteredData) { return filteredData; } const result = await httpClient.doGet( `/admin/realms/${realm}/client-scopes` ); setRawData(result.data!); })(); }, []); const filterData = (search: string) => { setFilteredData( rawData!.filter((group) => group.name.toLowerCase().includes(search.toLowerCase()) ) ); }; return ( <> {!rawData && (
)} {rawData && ( history.push("/client-scopes/add-client-scopes/") } > {t("createClientScope")} } > )}
); };