import { Center, Container, Loader, Stack } from "@mantine/core"; import { usePubSub } from "create-pubsub/react"; import { Suspense, useEffect } from "react"; import { lazy } from "react"; import { Pattern, match } from "ts-pattern"; import { addLogEntry } from "../../../modules/logEntries"; import { queryPubSub, searchStatePubSub, textGenerationStatePubSub, } from "../../../modules/pubSub"; const AiResponseSection = lazy( () => import("../../AiResponse/AiResponseSection"), ); const SearchResultsSection = lazy( () => import("../../Search/Results/SearchResultsSection"), ); const MenuButton = lazy(() => import("./Menu/MenuButton")); const SearchForm = lazy(() => import("../../Search/Form/SearchForm")); export default function MainPage() { const [query, updateQuery] = usePubSub(queryPubSub); const [searchState] = usePubSub(searchStatePubSub); const [textGenerationState] = usePubSub(textGenerationStatePubSub); useEffect(() => { addLogEntry(`Search state changed to '${searchState}'`); }, [searchState]); useEffect(() => { addLogEntry(`Text generation state changed to '${textGenerationState}'`); }, [textGenerationState]); return ( "center") .otherwise(() => undefined)} > } > } /> {match(textGenerationState) .with(Pattern.not("idle"), () => ( )) .otherwise(() => null)} {match(searchState) .with(Pattern.not("idle"), () => ( )) .otherwise(() => null)} ); }