Files
hetty/admin/src/features/scope/components/Rules.tsx

32 lines
798 B
TypeScript
Raw Normal View History

2022-01-28 20:20:15 +01:00
import { Alert } from "@mui/lab";
2022-02-23 15:20:23 +01:00
import { CircularProgress, List } from "@mui/material";
2020-10-29 20:54:17 +01:00
import React from "react";
2022-02-23 15:20:23 +01:00
2020-10-29 20:54:17 +01:00
import RuleListItem from "./RuleListItem";
2022-02-23 15:20:23 +01:00
import { useScopeQuery } from "lib/graphql/generated";
2020-10-29 20:54:17 +01:00
function Rules(): JSX.Element {
2022-02-23 15:20:23 +01:00
const { loading, error, data } = useScopeQuery();
2020-10-29 20:54:17 +01:00
return (
<div>
{loading && <CircularProgress />}
2022-01-28 20:20:15 +01:00
{error && <Alert severity="error">Error fetching scope: {error.message}</Alert>}
{data && data.scope.length > 0 && (
<List
sx={{
bgcolor: "background.paper",
}}
>
2020-10-29 20:54:17 +01:00
{data.scope.map((rule, index) => (
2022-01-28 20:20:15 +01:00
<RuleListItem key={index} rule={rule} scope={data.scope} index={index} />
2020-10-29 20:54:17 +01:00
))}
</List>
)}
</div>
);
}
export default Rules;