import { Fragment } from 'react';

import { dialogModel } from '@/models/dialogModel';

import Dialog from './index';

/**
 * Dialog 容器组件
 * 负责渲染所有通过 dialogModel 打开的对话框
 */
export const DialogContainer: React.FC = () => {
    const { dialogs } = dialogModel.useModel();
    return (
        <Fragment>
            {dialogs.map((dialog) => (
                <Dialog
                    key={dialog.id}
                    {...dialog}
                    open={true}
                    id={dialog.id}
                    zIndex={dialog.zIndex}
                />
            ))}
        </Fragment>
    );
};
