Spaces:
Running
Running
File size: 1,119 Bytes
06b47dc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import { Alert, Stack, Text } from "@mantine/core";
import { usePubSub } from "create-pubsub/react";
import { ErrorBoundary } from "react-error-boundary";
import { settingsPubSub } from "../../../modules/pubSub";
import ImageSearchResults from "./Graphical/ImageSearchResults";
import TextSearchResults from "./Textual/TextSearchResults";
const ErrorFallback = ({ error }: { error: Error }) => (
<Alert color="red" title="Error loading search results">
<Text size="sm">{error.message}</Text>
<Text size="xs" c="dimmed">
Please try refreshing the page.
</Text>
</Alert>
);
export default function SearchResultsSection() {
const [settings] = usePubSub(settingsPubSub);
const renderSearchResults = (
Component: React.ComponentType,
enabled: boolean,
) =>
enabled && (
<ErrorBoundary FallbackComponent={ErrorFallback}>
<Component />
</ErrorBoundary>
);
return (
<Stack gap="xl">
{renderSearchResults(ImageSearchResults, settings.enableImageSearch)}
{renderSearchResults(TextSearchResults, settings.enableTextSearch)}
</Stack>
);
}
|