Skip to content

Commit

Permalink
fix: only show upcoming donations in donor dashboard (#159) (#160)
Browse files Browse the repository at this point in the history
* only show upcoming donations in donor dashboard

* fix tests
  • Loading branch information
Shehryar21 authored Mar 3, 2022
1 parent 2979afa commit 8eceaf3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ describe("pg schedulingService", () => {
donorId.toString(),
0,
);
const currentDate = new Date();
expect(res).toMatchObject(
testSchedules.filter((schedule) => schedule.donorId === donorId),
testSchedules.filter(
(schedule) =>
schedule.donorId === donorId && schedule.startTime >= currentDate,
),
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class SchedulingService implements ISchedulingService {
let schedulingDtos: Array<SchedulingDTO> = [];
let schedulings: Array<Scheduling>;
try {
const currentStartDate = new Date();
if (weekLimit !== 0) {
const currentStartDate = new Date();
const nextDate = new Date();
nextDate.setDate(nextDate.getDate() + weekLimit * 7);
schedulings = await Scheduling.findAll({
Expand All @@ -111,6 +111,9 @@ class SchedulingService implements ISchedulingService {
schedulings = await Scheduling.findAll({
where: {
donor_id: Number(donorId),
start_time: {
[Op.gte]: currentStartDate,
},
},
order: [["start_time", "ASC"]],
});
Expand Down

0 comments on commit 8eceaf3

Please sign in to comment.