fix: display issue for quota

- DRY up `LogsTable.js` codebase
- Fix formatting in `LogsTable.js`
- Display 'free' for a 0 quota instead of empty string
This commit is contained in:
Laisky.Cai 2024-03-02 01:10:59 +00:00
parent 268690219e
commit a7c43ab248
2 changed files with 6 additions and 2 deletions

View File

@ -319,7 +319,7 @@ const LogsTable = () => {
}} }}
width={1} width={1}
> >
额度 费用
</Table.HeaderCell> </Table.HeaderCell>
<Table.HeaderCell <Table.HeaderCell
style={{ cursor: 'pointer' }} style={{ cursor: 'pointer' }}

View File

@ -38,6 +38,10 @@ export function renderNumber(num) {
} }
export function renderQuota(quota, digits = 2) { export function renderQuota(quota, digits = 2) {
if (quota === 0) {
return 'free';
}
let quotaPerUnit = localStorage.getItem('quota_per_unit'); let quotaPerUnit = localStorage.getItem('quota_per_unit');
let displayInCurrency = localStorage.getItem('display_in_currency'); let displayInCurrency = localStorage.getItem('display_in_currency');
quotaPerUnit = parseFloat(quotaPerUnit); quotaPerUnit = parseFloat(quotaPerUnit);
@ -55,4 +59,4 @@ export function renderQuotaWithPrompt(quota, digits) {
return `(等价金额:${renderQuota(quota, digits)}`; return `(等价金额:${renderQuota(quota, digits)}`;
} }
return ''; return '';
} }