import React, { FC } from "react";
import { Stack } from "@mantine/core";
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
import CreateProjectButton from "@/app/deals/drawers/ProjectsEditorDrawer/components/CreateProjectButton";
import ProjectMobile from "@/app/deals/drawers/ProjectsEditorDrawer/components/ProjectMobile";

type Props = {
    setSelectedProjectId: (projectId: number | null) => void;
    onClose: () => void;
};

const ProjectsDrawerBody: FC<Props> = ({ setSelectedProjectId, onClose }) => {
    const { projects } = useProjectsContext();

    return (
        <>
            <Stack gap={0}>
                {projects.map((project, index) => (
                    <ProjectMobile
                        key={index}
                        project={project}
                        setSelectedProjectId={setSelectedProjectId}
                        closeDrawer={onClose}
                    />
                ))}
            </Stack>
            <CreateProjectButton />
        </>
    );
};

export default ProjectsDrawerBody;
