Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help. i want use form in Modal.confirm. ver:5.11.1 #92

Open
tieucoctu opened this issue Apr 25, 2024 · 0 comments
Open

help. i want use form in Modal.confirm. ver:5.11.1 #92

tieucoctu opened this issue Apr 25, 2024 · 0 comments

Comments

@tieucoctu
Copy link

tieucoctu commented Apr 25, 2024

export const ModalConfirm = (props: Props) => {
  const {
    title,
    typeColor = 'info',
    cancelText = 'Huỷ',
    okText = 'Xác nhận',
    handleConfirm,
    content,
    okButtonProps,
    ...restProps
  } = props;

  return Modal.confirm({
    ...restProps,
    cancelText,
    className: `wrap-modal-confirm wrap-btn modal-${typeColor}`,
    title: title,
    content: content,
    centered: true,
    open: false,
    async onOk(): Promise<void> {
      await handleConfirm?.();
    },
    okText,
    okButtonProps: { ...okButtonProps, className: `btn-${typeColor} ` },
    cancelButtonProps: { className: `ant-btn-primary btn-grey` },
  });
};
export const InfoPopup = (props: Props) => ModalConfirm({ ...props, icon: <InfoCircleFilled />, typeColor: 'info' });
export const ErrorPopup = (props: Props) => ModalConfirm({ ...props, icon: <WarningFilled />, typeColor: 'error' });
export const WarningPopup = (props: Props) =>
  ModalConfirm({ ...props, icon: <ExclamationCircleFilled />, typeColor: 'primary' });
export const SuccessPopup = (props: Props) =>
  ModalConfirm({ ...props, icon: <CheckCircleFilled />, typeColor: 'success' });

use component

  const handleDeleteRole = () => {
            return ErrorPopup({
              title: 'Bạn có chắc chắn muốn xóa?',
              width: 480,
              okButtonProps: {
                htmlType: 'submit',
              },
              content: (
                <Form onFinish={SubmitDelete}>
                  <p>Thao tác thực hiện xoá vai trò này khỏi danh sách quản lý các vai trò.</p>
                  <p>vui lòng nhập lý do.</p>
                  <Form.Item name={'note'} rules={[{ required: true, message: 'Vui loại nhap lý do' }]}>
                    <TextArea
                      className="text-area-content"
                      autoSize={{ minRows: 6 }}
                      onChange={(e) => handleOnChangeNode(e.target.value)}
                      placeholder="Nhập lý do..."
                    />
                  </Form.Item>
                </Form>
              ),
              handleConfirm: () => SubmitDelete({ id: record?.id }),
            });
          };

Uploading Screenshot 2024-04-25 103247.png…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant