mirror of
https://github.com/docmost/docmost.git
synced 2026-08-22 20:12:11 +10:00
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { Container, Title, Text, Group, Box } from "@mantine/core";
|
|
import { useTranslation } from "react-i18next";
|
|
import { useGetSpacesQuery } from "@/features/space/queries/space-query";
|
|
import CreateSpaceModal from "@/features/space/components/create-space-modal";
|
|
import { AllSpacesList } from "@/features/space/components/spaces-page";
|
|
import FavoriteSpacesGrid from "@/features/space/components/spaces-page/favorite-spaces-grid";
|
|
import { usePaginateAndSearch } from "@/hooks/use-paginate-and-search";
|
|
import useUserRole from "@/hooks/use-user-role";
|
|
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
|
|
|
export default function Spaces() {
|
|
const { t } = useTranslation();
|
|
const { isAdmin } = useUserRole();
|
|
const { search, cursor, goNext, goPrev, handleSearch } = usePaginateAndSearch();
|
|
|
|
const { data, isLoading } = useGetSpacesQuery({
|
|
cursor,
|
|
limit: 30,
|
|
query: search,
|
|
});
|
|
|
|
return (
|
|
<>
|
|
<DocumentTitle title={t("Spaces")} />
|
|
|
|
<Container size={"800"} pt="xl">
|
|
<Group justify="space-between" mb="xl">
|
|
<Title order={1} size="h3">{t("Spaces")}</Title>
|
|
{isAdmin && <CreateSpaceModal />}
|
|
</Group>
|
|
|
|
<FavoriteSpacesGrid />
|
|
|
|
<Box>
|
|
<Text size="sm" c="dimmed" mb="md">
|
|
{t("All spaces")}
|
|
</Text>
|
|
|
|
<AllSpacesList
|
|
spaces={data?.items || []}
|
|
onSearch={handleSearch}
|
|
hasPrevPage={data?.meta?.hasPrevPage}
|
|
hasNextPage={data?.meta?.hasNextPage}
|
|
onNext={() => goNext(data?.meta?.nextCursor)}
|
|
onPrev={goPrev}
|
|
/>
|
|
</Box>
|
|
</Container>
|
|
</>
|
|
);
|
|
}
|