import { DrawerForm } from '@ant-design/pro-form';
import { memo } from 'react';
import type { AppDetailViewProps } from './view';
import AppDetailView from './view';

export interface AppDetailProps extends AppDetailViewProps {
  /**
   * @description 触发的trigger
   */
  triggerRender?: JSX.Element;
  /**
   * @description title
   */
  title?: string | JSX.Element;
  /**
   * @description setOpen
   */
  setOpen?: (val: boolean) => void;
  /**
   * @description open
   */
  open?: boolean;
}

const AppDetail = (props: AppDetailProps) => {
  const { appId, title, open, setOpen, isOptShow = false, triggerRender, userId } = props;

  return (
    <DrawerForm
      title={title}
      width={1200}
      visible={open}
      trigger={triggerRender}
      onFinish={async () => true}
      drawerProps={{
        destroyOnClose: true,
        onClose: () => {
          setOpen?.(false);
        },
      }}
      submitter={{
        submitButtonProps: {
          style: {
            display: 'none',
          },
        },
      }}
    >
      {open && <AppDetailView appId={appId} isOptShow={isOptShow} userId={userId} />}
    </DrawerForm>
  );
};
export default memo(AppDetail);
