Skip to content

Partner Tags - #323

Merged
ND68 merged 7 commits into
mainfrom
andy/310-partner-tags
Apr 11, 2026
Merged

ND68 merged 7 commits into
mainfrom
andy/310-partner-tags

Conversation

@idke64

@idke64 idke64 commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Description

Resolves ticket number: #310

Explain what your code changes:

Implemented new tagging system where admins can create, assign, and use new tags.

  • Added tags to schema
  • Changed EditAccount modal to be able to create and assign tags
  • Creating tickets and donor offers uses new tags to separate targets

List the steps you took to test your code:

Created tags as a client and made sure they worked correctly and appeared in the right places.

Checklist

  • The ticket is mentioned above
  • The changes fulfill the success criteria of the ticket
  • The changes were self-reviewed
  • A review was requested

@netlify

netlify Bot commented Apr 6, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for hope-for-haiti ready!

Name Link
🔨 Latest commit 21bdcac
🔍 Latest deploy log https://app.netlify.com/projects/hope-for-haiti/deploys/69d9e29ceec1870008d6b7c2
😎 Deploy Preview https://deploy-preview-323--hope-for-haiti.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@greptile-apps

greptile-apps Bot commented Apr 6, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR migrates the partner tagging system from a single tag: String? field to a proper many-to-many Tag model, adds a /api/tags endpoint for CRUD, and updates the EditModal to support multi-tag creation and assignment.

  • P0 — broken analytics tag filtering: All 7 raw SQL subqueries in lineItemService.ts reference \"_UserToTag\" but the actual join table created by the migration is \"_TagToUser\", with columns A=TagId and B=UserId. The column references are also inverted. Every analytics call that filters by excluded tags will throw a PostgreSQL relation \"_UserToTag\" does not exist error.
  • P2 — newly created tags not auto-selected: onCreateOption in EditModal adds the tag to the options list but doesn't update formData.tags, so users must manually select a tag they just created.

Confidence Score: 4/5

Not safe to merge — the raw SQL table name mismatch will cause all analytics tag-filter calls to fail at runtime.

One P0 bug (wrong join table name + swapped columns in 7 raw SQL queries) blocks merge. The rest of the migration — Prisma ORM queries, API endpoints, auth token plumbing, and frontend — looks correct and well-structured.

src/services/lineItemService.ts — all tag-filter subqueries reference the wrong table and swapped columns.

Important Files Changed

Filename Overview
src/services/lineItemService.ts All 7 raw SQL tag-filter subqueries reference the non-existent table "_UserToTag" (actual: "_TagToUser") with A/B columns swapped — every analytics call with tag filtering will throw a PostgreSQL runtime error.
prisma/schema.prisma Adds Tag model with unique name constraint and implicit many-to-many relation to User; also removes partnerSignerName and partnerSignatureUrl from SignOff.
src/services/userService.ts Updates tag handling to use the new many-to-many Tag model; adds getAllTags/createTag with correct upsert, fixes countPartners filter to use "none" semantics.
src/app/api/tags/route.ts New dedicated /api/tags endpoint with GET (userRead) and POST (userWrite) guarded by auth and Zod validation; POST returns 201.
src/components/AccountManagement/EditModal.tsx Replaces single-tag ConfiguredSelect with multi-tag CreatableConfiguredSelect; handleCreateTag adds tags to options state but does not auto-select the newly created tag.
src/components/CreatableConfiguredSelect.tsx New wrapper for react-select/creatable with project styling; uses hardcoded hex colors instead of Tailwind config values.
src/app/accountManagement/page.tsx Switches tags fetch to /api/tags, expands tag column to show a hover tooltip with multiple tag pills.
src/lib/userUtils.ts groupUsersByTagForSelect updated to handle multiple tags per user; searchByNameOrTag now safely handles undefined user data.
src/services/partnerService.ts Tag search updated to use the new many-to-many relation; partner data now returns tags array instead of tag string.
src/auth/index.ts Session/JWT types updated from tag?: string to tags?: { id, name }[]; tag data passed through correctly.

Sequence Diagram

sequenceDiagram
    participant Admin
    participant EditModal
    participant TagsAPI as /api/tags
    participant UserAPI as /api/users/[id]
    participant UserService
    participant DB

    Admin->>EditModal: Open edit for partner
    EditModal->>TagsAPI: GET /api/tags
    TagsAPI->>UserService: getAllTags()
    UserService->>DB: tag.findMany()
    DB-->>EditModal: TagOption[]

    Admin->>EditModal: Type new tag + Enter
    EditModal->>TagsAPI: POST /api/tags {name}
    TagsAPI->>UserService: createTag(name)
    UserService->>DB: tag.upsert()
    DB-->>EditModal: {id, name}
    Note over EditModal: adds to tagOptions,<br/>but does NOT auto-select

    Admin->>EditModal: Confirm
    EditModal->>UserAPI: PATCH /api/users/[id] {tags: [id,...]}
    UserAPI->>UserService: updateUser({tags})
    UserService->>DB: user.update({tags: {set: [{id},...]}}) 
    DB-->>Admin: Updated user
Loading

Reviews (2): Last reviewed commit: "small fixes" | Re-trigger Greptile

Comment thread src/services/userService.ts
Comment thread src/lib/userUtils.ts Outdated
Comment thread src/components/AccountManagement/EditModal.tsx Outdated
Comment thread src/components/AccountManagement/EditModal.tsx Outdated
Comment thread src/app/accountManagement/page.tsx Outdated
{item.tags.map((tag) => (
<span
key={tag.id}
className="px-2 py-0.5 bg-[#E6E6E6] text-[#333333] rounded-md text-xs"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Hardcoded hex colors instead of Tailwind config values

bg-[#E6E6E6] text-[#333333] bypass the project's color system. Replace with equivalent colors from the Tailwind config to stay consistent with the codebase conventions.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment thread src/app/api/tags/route.ts
@ND68

ND68 commented Apr 11, 2026

Copy link
Copy Markdown
Collaborator

@greptileai

Comment thread src/services/lineItemService.ts Outdated
@ND68
ND68 merged commit 7053bed into main Apr 11, 2026
5 checks passed
@ND68
ND68 deleted the andy/310-partner-tags branch April 11, 2026 05:59
@ND68

ND68 commented Apr 11, 2026

Copy link
Copy Markdown
Collaborator

made a few bug fixes and stylistic changes, but overall great work

@ND68 ND68 linked an issue Apr 11, 2026 that may be closed by this pull request
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.

Partner Tags

2 participants