"use client";

import React, { FC } from "react";
import { Drawer } from "@mantine/core";
import DealEditorBody from "@/app/deals/drawers/DealEditorDrawer/components/DealEditorBody";
import { DrawerProps } from "@/drawers/types";
import { DealsCrud } from "@/hooks/cruds/useDealsCrud";
import useIsMobile from "@/hooks/utils/useIsMobile";
import { DealSchema } from "@/lib/client";

type Props = {
    deal: DealSchema;
    dealsCrud: DealsCrud;
};

const DealEditorDrawer: FC<DrawerProps<Props>> = ({
    opened,
    onClose,
    props,
}) => {
    const isMobile = useIsMobile();

    return (
        <Drawer
            size={isMobile ? "100%" : "40%"}
            position={"right"}
            onClose={onClose}
            removeScrollProps={{ allowPinchZoom: true }}
            withCloseButton={false}
            opened={opened}
            trapFocus={false}
            styles={{
                body: {
                    height: "100%",
                    display: "flex",
                    flexDirection: "column",
                    padding: 0,
                },
            }}>
            <DealEditorBody
                {...props}
                onClose={onClose}
            />
        </Drawer>
    );
};

export default DealEditorDrawer;
