fix: resolve response format mismatches causing data loading failures in Dashboard, ImBots, Promotion, Knowledge pages
This commit is contained in:
1 parent
839be8f97f
commit
e9ec429d21
4 files changed
+385
-461
No files matched your search
@@ -102,7 +102,7 @@ const Promotion: React.FC = () => {
|
||||
const loadStats = useCallback(async () => {
|
||||
try {
|
||||
const res = await adminAPI.getPromotionStats();
|
||||
if (res.success) {
|
||||
if (res.data) {
|
||||
setStats(res.data);
|
||||
}
|
||||
} catch (err: any) {
|
||||
@@ -115,7 +115,7 @@ const Promotion: React.FC = () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await adminAPI.getPromotions({ page, page_size: 20 });
|
||||
if (res.success) {
|
||||
if (res.data) {
|
||||
setPromotions(res.data.items);
|
||||
setTotalPromos(res.data.total);
|
||||
setPromoPage(page);
|
||||
@@ -132,7 +132,7 @@ const Promotion: React.FC = () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await adminAPI.getReferralLinks({ page, page_size: 20 });
|
||||
if (res.success) {
|
||||
if (res.data) {
|
||||
setReferralLinks(res.data.items);
|
||||
setTotalLinks(res.data.total);
|
||||
setLinkPage(page);
|
||||
@@ -149,7 +149,7 @@ const Promotion: React.FC = () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await adminAPI.getReferralRewards({ page, page_size: 20 });
|
||||
if (res.success) {
|
||||
if (res.data) {
|
||||
setRewards(res.data.items);
|
||||
setTotalRewards(res.data.total);
|
||||
setRewardPage(page);
|
||||
@@ -165,8 +165,8 @@ const Promotion: React.FC = () => {
|
||||
const loadLeaderboard = useCallback(async () => {
|
||||
try {
|
||||
const res = await adminAPI.getPromotionLeaderboard({ limit: 50 });
|
||||
if (res.success) {
|
||||
setLeaderboard(res.data.leaderboard);
|
||||
if (res.data) {
|
||||
setLeaderboard(res.data.items || res.data.leaderboard || []);
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error('Failed to load leaderboard:', err);
|
||||
@@ -813,7 +813,7 @@ const LinkModal: React.FC<LinkModalProps> = ({ onSave, onCancel }) => {
|
||||
useEffect(() => {
|
||||
adminAPI.getPromotions({ status: 'active', page: 1, page_size: 100 })
|
||||
.then(res => {
|
||||
if (res.success) setPromotions(res.data.items);
|
||||
if (res.data) setPromotions(res.data.items);
|
||||
})
|
||||
.catch(err => console.error('Failed to load active promotions:', err));
|
||||
}, []);
|
||||
|
||||
Reference in new issue
Block a user