Skip to content

Commit

Permalink
added org fields for new donors created in new donation form
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesjin123 committed May 5, 2024
1 parent 0e37f24 commit d899ea5
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
62 changes: 62 additions & 0 deletions client/src/NewDonation/NewDonationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ function NewDonationPage() {
const [donator, setDonator] = useState<DonorType | null>(null);
const [isNewDonator, setIsNewDonator] = useState(false);
const [isNewPurpose, setIsNewPurpose] = useState(false);
const [showOrgFields, setShowOrgFields] = useState(false);
const [newDonatorEmail, setNewDonatorEmail] = useState('');
const [newDonatorAddress, setNewDonatorAddress] = useState('');
const [orgEmail, setOrgEmail] = useState('');
const [orgAddress, setOrgAddress] = useState('');
const [orgName, setOrgName] = useState('');
const [newDonatorGroup, setNewDonatorGroup] = useState('');
const [campaignPurpose, setCampaignPurpose] = useState<PurposeType | null>(
null,
Expand Down Expand Up @@ -89,7 +93,29 @@ function NewDonationPage() {
setNewDonatorAddress(event.target.value);
};

const handleOrgEmailChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setOrgEmail(event.target.value);
};

const handleOrgAddressChange = (
event: React.ChangeEvent<HTMLInputElement>,
) => {
setOrgAddress(event.target.value);
};

const handleOrgNameChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setOrgName(event.target.value);
};

const handleNewDonatorGroupChange = (event: SelectChangeEvent) => {
if (
event.target.value !== 'Individual' &&
event.target.value !== 'Board Member'
) {
setShowOrgFields(true);
} else {
setShowOrgFields(false);
}
setNewDonatorGroup(event.target.value);
};

Expand All @@ -114,6 +140,9 @@ function NewDonationPage() {
type: '0', // no input field for this yet
// comments: null,
// _id: null,
org_address: orgAddress,
org_email: orgEmail,
org_name: orgName,
};

postData('donor/create', newDonator)
Expand Down Expand Up @@ -423,6 +452,39 @@ function NewDonationPage() {
/>
</Grid>
)}
{showOrgFields && (
<Grid item xs={12}>
<TextField
label="Organization Address"
type="text"
value={orgAddress}
onChange={handleOrgAddressChange}
sx={{ width: '40%' }}
/>
</Grid>
)}
{showOrgFields && (
<Grid item xs={12}>
<TextField
label="Organization Email"
type="text"
value={orgEmail}
onChange={handleOrgEmailChange}
sx={{ width: '40%' }}
/>
</Grid>
)}
{showOrgFields && (
<Grid item xs={12}>
<TextField
label="Organization Name"
type="text"
value={orgName}
onChange={handleOrgNameChange}
sx={{ width: '40%' }}
/>
</Grid>
)}

<Grid item xs={12}>
<Autocomplete
Expand Down
15 changes: 15 additions & 0 deletions server/src/models/donor.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ const DonorSchema = new mongoose.Schema({
type: String,
required: false,
},
org_address: {
type: String,
required: false,
},
org_email: {
type: String,
required: false,
},
org_name: {
type: String,
required: false,
},
});

interface IDonor extends mongoose.Document {
Expand All @@ -50,6 +62,9 @@ interface IDonor extends mongoose.Document {
last_donation_date: Date;
type: string;
comments: string;
org_address: string;
org_email: string;
org_name: string;
}

const Donor = mongoose.model<IDonor>('Donor', DonorSchema);
Expand Down

0 comments on commit d899ea5

Please sign in to comment.