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

24 referral submission #27

Merged
merged 4 commits into from
Mar 1, 2025
Merged

24 referral submission #27

merged 4 commits into from
Mar 1, 2025

Conversation

suesuee
Copy link
Collaborator

@suesuee suesuee commented Feb 25, 2025

Developer: Camila and Sue

Closes #24

Pull Request Summary

This PR implements the submission logic for the ReferralForm component, making sure the member data is retrieved from the URL and submitted to the backend. It extracts referral details from the query parameters and processes user input to create a new referral instance in the database.

Modifications

  1. src/components/ReferralForm/ReferralForm.tsx
  • Extracts referrer data (name, email, referral code) from the URL using useSearchParams.
  • Updates hidden fields dynamically as the URL changes.
  • Implements error handling to ensure prospect fields (email, first name, last name) are filled before submission.
  • Formats and sends a POST request to /api/referral with the structured referral data.
  • Includes logging for debugging.
  1. src/app/api/referral/route.ts
  • Receives and processes referral data submitted from the frontend.
  • Ensures all required fields (member details, referral code, and at least one prospect) are present.
  • Uses Prisma transactions to store multiple prospect referrals in the database.
  • Includes logging for debugging.

Testing Considerations

  • Verified that the referrer data is correctly extracted from the URL.
  • Ensured the form does not submit if required fields are missing (error messages appear).
  • Confirmed that the correct payload is sent to /api/referral via the network request in DevTools.
  • Checked that multiple prospects can be added and submitted in the same request.
  • Ensured that successful submissions create referral records in the database.

Pull Request Checklist

  • Code is neat, readable, and works
  • Comments are appropriate
  • The commit messages follows our guidelines
  • The developer name is specified
  • The summary is completed
  • Assign reviewers

Screenshots/Screencast

The URL used: http://localhost:3000/?nm=John%20Michael%20Doe&[email protected]&ref=ABC123

If the referrer enters two prospects in the same form
image
If the referrer miss any of the prospect's fields
image

@suesuee suesuee requested review from IvanA673 and achan214 February 25, 2025 23:15
Copy link
Collaborator

@IvanA673 IvanA673 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You both did an amazing job on this issue! Thanks for your work and thorough testing.

@IvanA673 IvanA673 merged commit b98973e into develop Mar 1, 2025
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement ReferralForm Submission
3 participants