Conversation
server/actions/donation.ts
Outdated
| await Mongo(); | ||
|
|
||
| const nonprofit = await Nonprofit.findOne({ _id: nonprofitId }); | ||
| const user = await Donation.findOne({ _id: userId }); // TODO: Don't allow front end to pass null resulting userId |
There was a problem hiding this comment.
Technically this should be User.findOne right? Also right now we haven't decided if all Donations require a user ID, so could you make necessary changes to the Mongoose schema and the types in utils.ts to support null user ID or make user ID optional?
There was a problem hiding this comment.
If a user ID is specified and there is no user with that ID, we should throw an error, just like on line 22 we throw an error if the nonprofit doesn't exist.
…serid in donation server action
|
Deploy preview for gen-soln ready! ✅ Preview Built with commit e3c3005. |
PC98
left a comment
There was a problem hiding this comment.
A couple of minor things, but tbh Matt it's okay if you don't do this now; we won't need this task for this semester's demo
server/actions/donation.ts
Outdated
| await Mongo(); | ||
|
|
||
| const nonprofit = await Nonprofit.findOne({ _id: nonprofitId }); | ||
| const user = await User.findOne({ _id: userId }); // TODO: Don't allow front end to pass null resulting userId |
There was a problem hiding this comment.
A couple of things:
can we do this and line 20 in parallel, using Promise.all?
can we modify line 27 to not throw the error if userId equals the empty string (as you have done in DonationPageForm.tsx), just temprarily? Because otherwise, donations will fail when DMS team is testing their UI.
added userId in donation schema. changed donation typing in types. modified method logDonation to take a userId as well. corrected misspelling of donation