Merge pull request #55 from songquanpeng/main

Fork Sync: Update from parent repository
This commit is contained in:
quzard
2023-06-21 16:20:04 +08:00
committed by GitHub
4 changed files with 22 additions and 13 deletions

View File

@@ -46,4 +46,13 @@ export function renderQuota(quota, digits = 2) {
return '$' + (quota / 1000 * quotaPerUnit).toFixed(digits);
}
return renderNumber(quota);
}
export function renderQuotaWithPrompt(quota, digits) {
let displayInCurrency = localStorage.getItem('display_in_currency');
displayInCurrency = displayInCurrency === 'true';
if (displayInCurrency) {
return `(等价金额:${renderQuota(quota, digits)}`;
}
return '';
}

View File

@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
import { Button, Form, Header, Segment } from 'semantic-ui-react';
import { useParams } from 'react-router-dom';
import { API, downloadTextAsFile, showError, showSuccess } from '../../helpers';
import { renderQuota } from '../../helpers/render';
import { renderQuota, renderQuotaWithPrompt } from '../../helpers/render';
const EditRedemption = () => {
const params = useParams();
@@ -11,7 +11,7 @@ const EditRedemption = () => {
const [loading, setLoading] = useState(isEdit);
const originInputs = {
name: '',
quota: 100,
quota: 100000,
count: 1
};
const [inputs, setInputs] = useState(originInputs);
@@ -88,7 +88,7 @@ const EditRedemption = () => {
</Form.Field>
<Form.Field>
<Form.Input
label={`额度(等价金额 ${renderQuota(quota)}`}
label={`额度${renderQuotaWithPrompt(quota)}`}
name='quota'
placeholder={'请输入单个兑换码中包含的额度'}
onChange={handleInputChange}

View File

@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
import { Button, Form, Header, Message, Segment } from 'semantic-ui-react';
import { useParams } from 'react-router-dom';
import { API, showError, showSuccess, timestamp2string } from '../../helpers';
import { renderQuota } from '../../helpers/render';
import { renderQuota, renderQuotaWithPrompt } from '../../helpers/render';
const EditToken = () => {
const params = useParams();
@@ -138,7 +138,7 @@ const EditToken = () => {
<Message>注意令牌的额度仅用于限制令牌本身的最大额度使用量实际的使用受到账户的剩余额度限制</Message>
<Form.Field>
<Form.Input
label={`额度(等价金额 ${renderQuota(remain_quota)}`}
label={`额度${renderQuotaWithPrompt(remain_quota)}`}
name='remain_quota'
placeholder={'请输入额度'}
onChange={handleInputChange}