-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support userId in donation schema #373
base: develop
Are you sure you want to change the base?
Conversation
server/actions/donation.ts
Outdated
nonprofitId | ||
}: DonationType): Promise<void> { | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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