export const handleResize = (
    e: React.MouseEvent<HTMLDivElement>,
    containerRef: React.RefObject<HTMLDivElement | null>
) => {
    if (!containerRef.current) return; // Ensure containerRef is not null
    const startY = e.clientY;
    const startHeight = containerRef.current.offsetHeight;

    const onMouseMove = (moveEvent: MouseEvent) => {
        const newHeight = Math.max(
            120,
            Math.min(400, startHeight + moveEvent.clientY - startY)
        );
        containerRef.current!.style.height = `${newHeight}px`;
    };

    const onMouseUp = () => {
        document.removeEventListener("mousemove", onMouseMove);
        document.removeEventListener("mouseup", onMouseUp);
    };

    document.addEventListener("mousemove", onMouseMove);
    document.addEventListener("mouseup", onMouseUp);
};
