68 lines
1.9 KiB
React
68 lines
1.9 KiB
React
import React from 'react';
|
|
import { Button } from 'antd';
|
|
import { Copy } from '@/components/common/icons/ActionIcons';
|
|
import { Modal } from '@/components/ui';
|
|
import { renderQuota, timestamp2string } from '@/helpers';
|
|
import {
|
|
formatRedemptionExpiry,
|
|
renderRedemptionStatus,
|
|
} from '../RedemptionsColumnDefs';
|
|
|
|
export default function RedemptionDetailsModal({
|
|
record,
|
|
onClose,
|
|
copyText,
|
|
t,
|
|
}) {
|
|
const fields = record
|
|
? [
|
|
[t('ID'), record.id],
|
|
[t('额度'), renderQuota(parseInt(record.quota))],
|
|
[t('创建时间'), timestamp2string(record.created_time)],
|
|
[t('过期时间'), formatRedemptionExpiry(record.expired_time, t)],
|
|
[t('兑换人ID'), record.used_user_id || t('无')],
|
|
]
|
|
: [];
|
|
|
|
return (
|
|
<Modal
|
|
centered
|
|
visible={Boolean(record)}
|
|
title={t('查看详情')}
|
|
onCancel={onClose}
|
|
footer={<Button onClick={onClose}>{t('关闭')}</Button>}
|
|
destroyOnHidden
|
|
>
|
|
{record && (
|
|
<div className='redemption-details'>
|
|
<div className='redemption-details-heading'>
|
|
<h3>{record.name}</h3>
|
|
{renderRedemptionStatus(record.status, record, t)}
|
|
</div>
|
|
<div className='redemption-code'>
|
|
<div className='redemption-code-header'>
|
|
<span>{t('兑换码')}</span>
|
|
<Button
|
|
icon={<Copy size={16} aria-hidden />}
|
|
size='small'
|
|
onClick={() => copyText(record.key)}
|
|
>
|
|
{t('复制')}
|
|
</Button>
|
|
</div>
|
|
<code>{record.key}</code>
|
|
</div>
|
|
<dl className='redemption-details-fields'>
|
|
{fields.map(([label, value]) => (
|
|
<div key={label}>
|
|
<dt>{label}</dt>
|
|
<dd>{value}</dd>
|
|
</div>
|
|
))}
|
|
</dl>
|
|
</div>
|
|
)}
|
|
</Modal>
|
|
);
|
|
}
|