"use client";

import { Center, Divider, Stack, Text } from "@mantine/core";
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
import TagsPageHeader from "@/app/tags/components/TagsPageHeader/TagsPageHeader";
import TagsTable from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/components/TagsTable";
import { DealTagsContextProvider } from "@/drawers/common/ProjectEditorDrawer/tabs/TagsTab/contexts/DealTagsContext";

const PageBody = () => {
    const { selectedProject } = useProjectsContext();

    if (!selectedProject) {
        return (
            <Center>
                <Text>Проект не найден</Text>
            </Center>
        );
    }

    return (
        <DealTagsContextProvider project={selectedProject}>
            <Stack
                gap={"md"}
                h={"100%"}>
                <TagsPageHeader project={selectedProject} />
                <Divider />
                <div style={{ minHeight: "0%" }}>
                    <TagsTable />
                </div>
            </Stack>
        </DealTagsContextProvider>
    );
};

export default PageBody;
