Skip to content
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

Perform API changes and import clean-up #34

Merged
merged 5 commits into from
Oct 18, 2023

Conversation

NathanWEdwards
Copy link
Collaborator

@NathanWEdwards NathanWEdwards commented Sep 30, 2023

This request proposes the following changes:

API

  • firebase.ts
    • Add methods for the admin claim
    • getAccountType() returns a string as a promise and rejects its promise if it fails to get an account's account type
    • getUserId() returns a string as a promise and rejects its promise if it fails to return a Firebase user's user id from Auth
    • isAdmin() returns a boolean as a promise and rejects its promise if it fails. This method will reject its promise if no claims are present after the Auth-state has settled
    • isDonor() returns a boolean as a promise and rejects its promise if it fails. This method will reject its promise if no claims are present after the Auth-state has settled
    • isVerified() returns a boolean as a promise and rejects its promise if it fails. This method will reject its promise if no claims are present after the Auth-state has settled
    • Methods should wait for the Firebase Auth-state to settle before calling its methods
    • Refactor lines of code to perform nullish coalescing and optional chaining where appropriate
    • Remove references to the un-verified claim
    • firebase-admin.ts
    • Add getDonations() which returns all donation documents
    • Clean up imports
    • setClaimsForNewUser(..) should only add the donor claim
    • addEvent(..) add events to the Events collection
    • setClaimForAdmin(...) should add or remove admin privileges to a user
  • firebase-events.ts
    • Add converter
  • firebase-donations.ts
    • activeDonations(...) should log an event if a user id is undefined
    • addDonation() adds an event if an exception is thrown while adding a new donation
  • firebase-images.ts
    • Should await for the availability of an user's id
    • uploadImages() returns a string[] as a promise and rejects the promise if it fails
      getImage returns an Image as a promise and rejects the promise if it fails
  • firebase-organizations.ts
    • Add Firestore converter
    • Add getOrganizations()
    • Add setOrganization(...)
  • firebase-storage.ts
    • Add Firestore converter
    • Add addStorage(...)
    • Add getAllStorage()
  • firebase-users.ts
    • Make changes to imports
    • addNote() adds a note to a user. This method will add an event if adding a note fails due to an exception being thrown
    • Add getAllUserAccounts() returns account information as a promise and rejects the promise if it fails. This method will reject its promise when the supplied userId doesn't return all necessary documents from Firebase for populating account information
    • _getUserAccount() A non-exported method in firebase-users returns a user's account information as a promise and rejects the promise if it fails. This method will reject its promise when an invalid Auth-state is present after the Auth-state has settled
    • getAllUserAccounts() returns a list of user accounts. If retrieving a user's account information fails, no entry for that user is added to the list
    • setUserAccount() body is surrounded in a try/catch and fails to set a user if a user id is not provided
    • Make changes to internal methods for retrieving account information
    • Add addNote(...) to add a note on a user account
    • Refactor addUsers.js and listUsers.js within firebase-users.ts. Adding users are managed by calls to Firebase Auth. Retrieving users are handled with calls to Firebase Auth and Firestore.

Components

  • Browse
    • Resolve imports with the root alias
  • DonationCard
    • Import shared style for all card types Card.module.css (AccountCard.module.css should simply be renamed to Card.module.css)
  • Header
    • Resolve imports with the root alias
  • ProtectedRoute
    • Define ProtectedRoute as a client component. This addition would enable a ProtectedRoute to be declared within a server component

Models

  • Event
    • Add class/collection that will store user initiated events and system events. Events may also be used for standardizing notes sub-collections present in other top-level collections.
  • Organization
    • Make changes to imports
  • Storage
    • Make changes to imports
  • User
    • Make changes to imports

Pages

  • Account and Account Edit pages
    • Add catch to getAccountType() call
    • Surround getUserAccount() call in try/catch
  • Join (the user creation) page
    • Make changes to imports
  • Login page
    • Make changes to imports
  • Site landing page
    • Make changes to imports
    • Update the unit test file to resolve an import with the root alias

Types

  • Add the placeholder Note type
  • Add the placeholder OrganizationForm type
  • Add the placeholder Storage type

@NathanWEdwards NathanWEdwards added the bug Something isn't working label Sep 30, 2023
@NathanWEdwards NathanWEdwards self-assigned this Sep 30, 2023
@bryanparmelee
Copy link
Collaborator

Thanks, @NathanWEdwards. Quick note on this: looking at Wendy's latest input, it sounds like we might want to keep the default un-verified claim for new users if its not too much of a pain. Might not be mission critical, but sounds like she does do some basic vetting so it could be useful to assume all new users are unverified until she can confirm they are a part of the organizations they've affiliated themselves with.

NathanWEdwards added a commit to NathanWEdwards/baby-equipment-exchange that referenced this pull request Oct 4, 2023
…e promises made from the API if they are rejected. (codeforbtv#34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants