Skip to content

Commit

Permalink
add current year to reports, add sengrid
Browse files Browse the repository at this point in the history
  • Loading branch information
Pulkith committed Jul 16, 2024
1 parent 090bf95 commit 530d061
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "client",
"version": "1.0.0",
"scripts": {
"start": "node index.js",
"start": "react-scripts start",
"client": "yarn start",
"clean": "rm -rf node_modules",
"dev": "echo \"Please cd into the root directory to run dev \" && exit 1",
Expand Down
31 changes: 22 additions & 9 deletions client/src/Reports/ReportsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,12 @@ function ReportsPage() {
setErrorMessage(false);
const now = dayjs();
const lastFiscalYrReportData = getReportForDateRange(
dayjs().startOf('year').subtract(1, 'year'),
dayjs().startOf('year'),
dayjs().month(6).startOf('month'),
now,
);
const lastCalYrReportData = getReportForDateRange(
dayjs().startOf('year').subtract(1, 'year'),
dayjs().endOf('year').subtract(1, 'year'),
dayjs().startOf('year'),
now,
);
const last90DaysReportData = getReportForDateRange(
now.subtract(90, 'days'),
Expand Down Expand Up @@ -454,11 +454,24 @@ function ReportsPage() {
return donationDate.isAfter(reportDate.subtract(90, 'days'));
}
if (alignment === 'last_calendar') {
return donationDate.isAfter(reportDate.subtract(1, 'year'));
return donationDate.isSame(reportDate, 'year');
}

if (alignment === 'last_fiscal') {
return donationDate.isAfter(
reportDate.subtract(1, 'year').startOf('year'),
const fiscalYearStart =
reportDate.month() >= 6
? reportDate.startOf('year').month(6).startOf('month') // July 1st of the same year
: reportDate
.startOf('year')
.subtract(1, 'year')
.month(6)
.startOf('month'); // July 1st of the previous year

const fiscalYearEnd = fiscalYearStart.add(1, 'year');

return (
donationDate.isAfter(fiscalYearStart) &&
donationDate.isBefore(fiscalYearEnd)
);
}
return false;
Expand Down Expand Up @@ -856,10 +869,10 @@ function ReportsPage() {
All Time
</ToggleButton>
<ToggleButton value="last_fiscal" aria-label="lastFiscalYr">
Last Fiscal Yr
Current Fiscal Yr
</ToggleButton>
<ToggleButton value="last_calendar" aria-label="lastCalYr">
Last Cal Yr
Current Cal Yr
</ToggleButton>
<ToggleButton value="last_90" aria-label="last90Days">
Last 90 Days
Expand Down
8 changes: 4 additions & 4 deletions server/src/services/mail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import 'dotenv/config';
import SGmail, { MailDataRequired } from '@sendgrid/mail';

const appName = 'Boilerplate'; // Replace with a relevant project name
const appName = 'West Park Cultural Donation Management System'; // Replace with a relevant project name
const senderName = 'Hack4Impact UPenn'; // Replace with a relevant project sender
const baseUrl = 'http://localhost:3000'; // TODO: figure out better place to put this

// const baseUrl = 'http://localhost:3000'; // TODO: figure out better place to put this
const baseUrl = 'https://west-park-cultural-0d318cb0ac65.herokuapp.com/';
// eslint-disable-next-line no-useless-concat
SGmail.setApiKey(`${process.env.SENDGRID_API_KEY}`);

Expand All @@ -27,7 +27,7 @@ const emailResetPasswordLink = async (email: string, token: string) => {
to: email,
subject: 'Link to Reset Password',
html:
`<p>You are receiving this because you (or someone else) have requested ` +
`<p>You are receiving this because you requested ` +
`the reset of your account password for ${appName}. Please visit this ` +
`<a href=${resetLink}>link</a> ` +
`within an hour of receiving this email to successfully reset your password </p>` +
Expand Down

0 comments on commit 530d061

Please sign in to comment.