Skip to content

Commit

Permalink
donor data
Browse files Browse the repository at this point in the history
  • Loading branch information
lsylcy0307 committed Apr 28, 2024
1 parent 0948861 commit 0b4745e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
14 changes: 11 additions & 3 deletions client/src/Popup/PopupPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
TableRow,
TableCell,
} from '@mui/material';
import IDonor from '../util/types/donor';
import { useData } from '../util/api';

interface BasicDonationStat {
Expand All @@ -39,9 +40,10 @@ function PopupPage() {
setOpenPopup(false);
};

const donorID = '65daa67d6c34e8adb9f2d2c4';
const donorID = '662e7657350953c9287c543c';
const donations = useData(`donation/donor/${donorID}`);

const donor = useData(`donor/${donorID}`);
const [donorData, setDonatorData] = useState<IDonor | null>(null);
const [donationsData, setDonationsData] = useState<any>([]);
const [donationsStats, setDonationsStats] = useState<DonationStats>();
const [purposeID, setPurposeID] = useState('');
Expand All @@ -55,6 +57,12 @@ function PopupPage() {
setPurposesData(data);
}, [purposes]);

useEffect(() => {
const data = donor?.data || null;
setDonatorData(data);
console.log(data);
}, [donor]);

useEffect(() => {
const data = donations?.data || [];
setDonationsData(data);
Expand Down Expand Up @@ -199,7 +207,7 @@ function PopupPage() {

{/* Popup */}
<Dialog open={openPopup} onClose={handleClosePopup}>
<DialogTitle>John Smith Summary</DialogTitle>
<DialogTitle>{donorData?.contact_name} Summary</DialogTitle>
<DialogContent>
<TableContainer component={Paper}>
<Table>
Expand Down
15 changes: 15 additions & 0 deletions client/src/util/types/donor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
interface IDonor {
_id: string;
contact_name: string;
contact_email: string;
contact_address: string;
contact_phone: string;
donor_group: string;
registered_date: Date;
last_donation_date: Date;
last_communication_date: Date;
type: string;
comments: string;
}

export default IDonor;
1 change: 1 addition & 0 deletions server/src/models/donor.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ interface IDonor extends mongoose.Document {
donor_group: string;
registered_date: Date;
last_donation_date: Date;
last_communication_date: Date;
type: string;
comments: string;
}
Expand Down

0 comments on commit 0b4745e

Please sign in to comment.