import React from 'react';
import QrCode from '../../common/qrCode';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../oak-app-domain';
import { Spin } from 'antd';

export default function Render(
    props: WebComponentProps<
        EntityDict,
        'wechatQrCode',
        false,
        {
            url: string;
            expiresAt: number;
            disableDownload: boolean;
            size: number;
            disabled: boolean;
            color: string;
            bgColor: string;
        },
        {}
    >
) {
    const { url, expiresAt, oakLoading, disableDownload, size, disabled, color, bgColor } = props.data;
    if (oakLoading) {
        return <Spin />;
    }
    if (url) {
        return <QrCode url={url} expiresAt={expiresAt} disableDownload={disableDownload} size={size} disabled={disabled} color={color} bgColor={bgColor} />;
    }
    return null;
}