Skip to content

Feat/drgreen affiliate capture - #288

Merged
AutomatosAI merged 3 commits into
mainfrom
feat/drgreen-affiliate-capture
Oct 5, 2026
Merged

AutomatosAI merged 3 commits into
mainfrom
feat/drgreen-affiliate-capture

Conversation

@AutomatosAI

Copy link
Copy Markdown
Owner

No description provided.

…okie (BS-A01)

Middleware adds a 30-day HttpOnly SameSite=Lax first-party cookie to
storefront page responses when ?ref= matches Dr Green's code format
(upper-cased; malformed values set nothing). /register keeps its query
string on the redirect to /consultation. bs_ref is listed as an essential
storefront cookie in lib/cookie-utils.ts. PRD copied to tasks/.
…ode (BS-A02)

The consultation and ID-upload forms gain an optional 'Referral code
(optional)' input pre-filled server-side from ?ref= or the bs_ref cookie,
validated inline. The submit route resolves affiliateCodeSource ('link'
when the submitted code is the remembered one, else 'typed'), forwards
affiliateCode + affiliateCodeSource through buildKycClientPayload and
createSaIdClient only when present, and clears bs_ref on success. A
malformed code is dropped, never a 400 for the registration.

The Dr Green error classifier is lifted out of the route unchanged
(lib/drgreen/registration-error.ts) to stay under the 800-line cap.
… admin (BS-A03)

users gains nullable affiliateCode + affiliateCodeSource (idempotent
migration 20261005000000_affiliate_code_on_users, applied by migrate
deploy on boot). The consultation route writes them alongside
drGreenClientId once the client is created with that code. The tenant
customers table shows a read-only Referral column and the CSV gains
Referral code / Referral source. GDPR erasure nulls both.
@AutomatosAI
AutomatosAI merged commit 7b9620d into main Oct 5, 2026
5 of 7 checks passed
@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 37fffc0c-24e4-424d-8d8c-cff37b4773c6
📥 Commits

Reviewing files that changed from the base of the PR and between 79e0b09 and 8524ceb.

📒 Files selected for processing (28)
  • nextjs_space/app/api/consultation/submit/route.ts
  • nextjs_space/app/store/[slug]/consultation/page.tsx
  • nextjs_space/app/store/[slug]/register/page.tsx
  • nextjs_space/app/tenant-admin/customers/customers-table.tsx
  • nextjs_space/app/tenant-admin/customers/page.tsx
  • nextjs_space/components/consultation/consultation-form-types.ts
  • nextjs_space/components/consultation/consultation-form.tsx
  • nextjs_space/components/consultation/id-upload-form.tsx
  • nextjs_space/components/consultation/steps/contact-details-step.tsx
  • nextjs_space/lib/affiliate/affiliate-code-schema.ts
  • nextjs_space/lib/affiliate/affiliate-code.ts
  • nextjs_space/lib/affiliate/referral-cookie.ts
  • nextjs_space/lib/cookie-utils.ts
  • nextjs_space/lib/drgreen-identity.ts
  • nextjs_space/lib/drgreen/kyc-client-payload.ts
  • nextjs_space/lib/drgreen/registration-error.ts
  • nextjs_space/lib/gdpr/erasure.ts
  • nextjs_space/middleware.ts
  • nextjs_space/prisma/migrations/20261005000000_affiliate_code_on_users/migration.sql
  • nextjs_space/prisma/schema.prisma
  • nextjs_space/tests/unit/affiliate-attribution.test.ts
  • nextjs_space/tests/unit/affiliate-referral-cookie.test.ts
  • nextjs_space/tests/unit/consultation-submit-affiliate.test.ts
  • nextjs_space/tests/unit/drgreen-registration-error.test.ts
  • nextjs_space/tests/unit/drgreen-sa-client.test.ts
  • nextjs_space/tests/unit/gdpr-erasure.test.ts
  • nextjs_space/tests/unit/kyc-client-payload.test.ts
  • tasks/prd-drgreen-affiliate-codes.md
 _______________________________
< When in doubt, review it out. >
 -------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

2 participants