Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions client/src/components/donors/Donors.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react';
import { FaUser, FaPlus, FaAngleDown, FaSpinner, FaDownload } from 'react-icons/fa';
import { getEvents, getEventById, getEventDonors } from '../../services/eventService';
import { getAvailableDonors, removeDonorFromEvent, getEventDonorStats, updateEventDonor, exportEventDonorsToCsv } from '../../services/donorService';

Check warning on line 4 in client/src/components/donors/Donors.jsx

View workflow job for this annotation

GitHub Actions / lint

'getAvailableDonors' is defined but never used
import { useLocation } from 'react-router-dom';
import './Donors.css';
import DonorList from './DonorList';
Expand Down Expand Up @@ -57,7 +57,7 @@
// Fetch events on component mount
useEffect(() => {
fetchEvents();
}, []);

Check warning on line 60 in client/src/components/donors/Donors.jsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'fetchEvents'. Either include it or remove the dependency array

// Handle event selection from location state
useEffect(() => {
Expand Down Expand Up @@ -90,7 +90,7 @@
fetchEventStats();
}
}
}, [selectedEvent, searchQuery, currentPage]);

Check warning on line 93 in client/src/components/donors/Donors.jsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'fetchEventDonors' and 'fetchEventStats'. Either include them or remove the dependency array

// Fetch events
const fetchEvents = async () => {
Expand Down Expand Up @@ -287,31 +287,9 @@
/**
* Open the add donor modal
*/
const handleOpenAddDonorModal = async () => {
const handleOpenAddDonorModal = () => {
if (!selectedEvent) return;

try {
// 先显示模态框
setShowAddDonorModal(true);

setLoading(prev => ({ ...prev, availableDonors: true }));
setError(prev => ({ ...prev, availableDonors: null }));

// 获取第一页可用捐赠者
const result = await getAvailableDonors(selectedEvent.id, {
page: 1,
limit: modalItemsPerPage,
search: ''
});

setModalTotalPages(result.total_pages || 1);
setModalTotalDonors(result.total_count || 0);
} catch (error) {
console.error('Error fetching available donors:', error);
setError(prev => ({ ...prev, availableDonors: error.message }));
} finally {
setLoading(prev => ({ ...prev, availableDonors: false }));
}
setShowAddDonorModal(true);
};

// Handle search
Expand Down
9 changes: 1 addition & 8 deletions client/src/services/eventService.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,7 @@ export const getEvents = async (params = {}) => {
*/
export const getEventById = async (eventId) => {
try {
const response = await fetchWithAuth(`${API_URL}/api/events/${eventId}`);

if (!response.ok) {
throw new Error(`Failed to get event info: ${response.status}`);
}

const data = await response.json();
return data;
return await fetchWithAuth(`${API_URL}/api/events/${eventId}`);
} catch (error) {
console.error('Error fetching event:', error);
throw error;
Expand Down
5 changes: 0 additions & 5 deletions client/src/utils/ProgressPoller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ export class ProgressPoller {
if (this.isStopped) return;

try {
const token = localStorage.getItem('token');
if (!token) {
throw new Error('No authentication token found');
}

const data = await fetchWithAuth(`/api/progress/${this.operationId}`)

// Ensure we have valid progress data
Expand Down
Loading