import React, {FC} from "react";
import {useAtom} from "jotai/index";
import {TestablesPopupWindowsAtom} from "./atoms";
import {TestablesPopupWindow} from "../TestablesPopupWindow";
import {SelectActionPopupWindow} from "./SelectActionPopupWindow";
import {useAtomValue} from "jotai";

export type PopupWindowsProps = {}

/**
 * Do not mix with the select action popup windows as nesting can cause issues.
 */
export const PopupWindows: FC<PopupWindowsProps> = ({}) => {
    const testablePopups = useAtomValue(TestablesPopupWindowsAtom)

    return [
        ...testablePopups.map(data => <TestablesPopupWindow
            context={data.context}
            onClose={data.onClose}
        />)
    ];
}
