import { FC } from "react";
import { IconBarcode, IconEdit, IconTrash } from "@tabler/icons-react";
import { Flex } from "@mantine/core";
import ActionIconWithTip from "@/components/ui/ActionIconWithTip/ActionIconWithTip";
import { DealProductSchema } from "@/lib/client";
import { useFulfillmentBaseContext } from "@/modules/dealModularEditorTabs/FulfillmentBase/shared/contexts/FulfillmentBaseContext";
import useBarcodePrintActions from "@/modules/dealModularEditorTabs/FulfillmentBase/shared/hooks/utils/useBarcodePrintActions";
import useProductActions from "@/modules/dealModularEditorTabs/FulfillmentBase/shared/hooks/utils/useProductActions";

type Props = {
    dealProduct: DealProductSchema;
};

const ProductViewActions: FC<Props> = ({ dealProduct }) => {
    const { dealProductsCrud } = useFulfillmentBaseContext();
    const { onChangeClick } = useProductActions();
    const { onPrintProductBarcodeClick } = useBarcodePrintActions();

    return (
        <Flex
            mt={"auto"}
            ml={"auto"}
            gap={"sm"}>
            <ActionIconWithTip
                onClick={() => onPrintProductBarcodeClick(dealProduct)}
                tipLabel="Печать штрихкода">
                <IconBarcode />
            </ActionIconWithTip>
            <ActionIconWithTip
                onClick={() => onChangeClick(dealProduct)}
                tipLabel="Редактировать товар">
                <IconEdit />
            </ActionIconWithTip>
            <ActionIconWithTip
                onClick={() => dealProductsCrud.onDelete(dealProduct)}
                tipLabel="Удалить товар">
                <IconTrash />
            </ActionIconWithTip>
        </Flex>
    );
};

export default ProductViewActions;
