Skip to content

Commit

Permalink
Add comments to code
Browse files Browse the repository at this point in the history
  • Loading branch information
GlenDsza committed Jun 16, 2024
1 parent c5bc896 commit e78165f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/screens/FundCampaignPledge/PledgeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,10 @@ const PledgeModal: React.FC<InterfacePledgeModal> = ({
const startDate = dayjs(pledgeStartDate).format('YYYY-MM-DD');
const endDate = dayjs(pledgeEndDate).format('YYYY-MM-DD');

console.log('pledgeAmount', pledgeAmount);

const updatedFields: {
[key: string]: number | string | string[] | undefined;
} = {};
// checks if there are changes to the pledge and adds them to the updatedFields object
if (pledgeAmount !== pledge?.amount) {
updatedFields.amount = pledgeAmount;
}
Expand Down Expand Up @@ -134,6 +133,7 @@ const PledgeModal: React.FC<InterfacePledgeModal> = ({
[formState, pledge],
);

// Function to create a new pledge
const createPledgeHandler = useCallback(
async (e: ChangeEvent<HTMLFormElement>): Promise<void> => {
try {
Expand Down Expand Up @@ -190,6 +190,7 @@ const PledgeModal: React.FC<InterfacePledgeModal> = ({
}
className="p-3"
>
{/* A Multi-select dropdown enables admin to select more than one volunteer for participating in a pledge */}
<Form.Group className="d-flex mb-3 w-100">
<Autocomplete
multiple
Expand All @@ -203,6 +204,7 @@ const PledgeModal: React.FC<InterfacePledgeModal> = ({
getOptionLabel={(member: InterfacePledgeVolunteer): string =>
`${member.firstName} ${member.lastName}`
}
/*istanbul ignore next*/
onChange={(_, newVolunteers): void => {

Check warning on line 208 in src/screens/FundCampaignPledge/PledgeModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/screens/FundCampaignPledge/PledgeModal.tsx#L208

Added line #L208 was not covered by tests
/*istanbul ignore next*/
setFormState({
Expand All @@ -216,6 +218,7 @@ const PledgeModal: React.FC<InterfacePledgeModal> = ({
/>
</Form.Group>
<Form.Group className="d-flex gap-3 mx-auto mb-3">
{/* Date Calendar Component to select start date of an event */}
<DatePicker
format="DD/MM/YYYY"
label={tCommon('startDate')}
Expand All @@ -238,6 +241,7 @@ const PledgeModal: React.FC<InterfacePledgeModal> = ({
minDate={dayjs(pledgeStartDate)}
maxDate={dayjs(endDate)}
/>
{/* Date Calendar Component to select end Date of an event */}
<DatePicker
format="DD/MM/YYYY"
label={tCommon('endDate')}
Expand All @@ -256,6 +260,7 @@ const PledgeModal: React.FC<InterfacePledgeModal> = ({
/>
</Form.Group>
<Form.Group className="d-flex gap-3 mb-4">
{/* Dropdown to select the currency in which amount is to be pledged */}
<FormControl fullWidth>
<InputLabel id="demo-simple-select-label">
{t('currency')}
Expand All @@ -265,6 +270,7 @@ const PledgeModal: React.FC<InterfacePledgeModal> = ({
value={pledgeCurrency}
label={t('currency')}
data-testid="currencySelect"
/*istanbul ignore next*/
onChange={(e) => {

Check warning on line 274 in src/screens/FundCampaignPledge/PledgeModal.tsx

View check run for this annotation

Codecov / codecov/patch

src/screens/FundCampaignPledge/PledgeModal.tsx#L274

Added line #L274 was not covered by tests
/*istanbul ignore next*/
setFormState({
Expand All @@ -280,6 +286,7 @@ const PledgeModal: React.FC<InterfacePledgeModal> = ({
))}
</Select>
</FormControl>
{/* Input field to enter amount to be pledged */}
<FormControl fullWidth>
<TextField
label={t('amount')}
Expand All @@ -297,7 +304,7 @@ const PledgeModal: React.FC<InterfacePledgeModal> = ({
/>
</FormControl>
</Form.Group>

{/* Button to submit the pledge form */}
<Button
type="submit"
className={styles.greenregbtn}
Expand Down

0 comments on commit e78165f

Please sign in to comment.