修复兑换码bug

This commit is contained in:
CaIon 2023-11-10 00:46:07 +08:00
parent 89be66b75b
commit f01932dc34
2 changed files with 11 additions and 1 deletions

View File

@ -49,5 +49,5 @@
"singleQuote": true,
"jsxSingleQuote": true
},
"proxy": "https://nekoapi.com"
"proxy": "http://localhost:3000"
}

View File

@ -166,16 +166,26 @@ const RedemptionsTable = () => {
setShowEdit(false);
}
const setCount = (data) => {
if (data.length >= (activePage) * ITEMS_PER_PAGE) {
setTokenCount(data.length + 1);
} else {
setTokenCount(data.length);
}
}
const loadRedemptions = async (startIdx) => {
const res = await API.get(`/api/redemption/?p=${startIdx}`);
const {success, message, data} = res.data;
if (success) {
if (startIdx === 0) {
setRedemptions(data);
setCount(data);
} else {
let newRedemptions = redemptions;
newRedemptions.push(...data);
setRedemptions(newRedemptions);
setCount(newRedemptions);
}
} else {
showError(message);