Skip to content

Partner Profile not Updating - #335

Merged
ND68 merged 4 commits into
mainfrom
andy/324-partner-profile-not-updating
Apr 13, 2026
Merged

ND68 merged 4 commits into
mainfrom
andy/324-partner-profile-not-updating

Conversation

@idke64

@idke64 idke64 commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Description

Resolves ticket number: #324

Explain what your code changes:
Problem was the PartnerDetails type required all fields to be filled out when updating so I added a partial PartnerDetails type with optional fields. Also modularized partnerDetails.ts.

List the steps you took to test your code:
Tested on partner account

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 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for hope-for-haiti ready!

Name Link
🔨 Latest commit 078f248
🔍 Latest deploy log https://app.netlify.com/projects/hope-for-haiti/deploys/69dd7bc44a662e000921c115
😎 Deploy Preview https://deploy-preview-335--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 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes partner profile updates by introducing a partnerDetailsUpdateSchema (all fields optional via .partial()) and a deepMerge helper that applies partial updates over existing stored data. The approach is conceptually sound, but the refactoring has two regressions worth addressing before merging.

  • secondaryTelephone unintentionally made required — removing .optional() from baseContactSchema makes step-2 form validation reject partners who don't supply a secondary phone, breaking a previously-optional field.
  • Non-atomic read-then-write in updatePartnerDetails — the SELECT + UPDATE pattern can lose concurrent updates; the second write silently overwrites the first.

Confidence Score: 4/5

Not safe to merge until the secondaryTelephone regression and race condition are addressed.

Two P1 findings: an unintentional schema regression making secondaryTelephone required (breaking step-2 form validation) and a non-atomic read-then-write that can silently lose concurrent updates. The core partial-update logic is otherwise correct.

src/schema/partnerDetails.ts (optional field regression, broken refine), src/services/partnerDetailsService.ts (race condition, unused import)

Important Files Changed

Filename Overview
src/schema/partnerDetails.ts Refactored into base + update schemas; secondaryTelephone was unintentionally made required, breaking step-2 form validation; sanitationFacilitiesLockableFromInside refine always passes due to wrong null-check.
src/services/partnerDetailsService.ts Adds deepMerge helper for partial updates — correct logic but non-atomic read-then-write introduces a race condition under concurrent requests; unused import.
src/app/api/partnerDetails/[userId]/route.ts Correctly swaps partnerDetailsSchema for partnerDetailsUpdateSchema in the form schema — straightforward and safe change.
src/types/api/partnerDetails.types.ts Updates UpdatePartnerDetailsData to use the new PartnerDetailsUpdate partial type — correct and intentional.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Route as POST /api/partnerDetails/[userId]
    participant Service as PartnerDetailsService
    participant DB as Database

    Client->>Route: POST formData (partial PartnerDetails)
    Route->>Route: Validate with partnerDetailsUpdateSchema (.partial())
    Route->>Service: updatePartnerDetails({ userId, partnerDetails })
    Service->>DB: getPartnerDetails (SELECT)
    DB-->>Service: existingDetails (or null)
    Service->>Service: deepMerge(existingDetails, partnerDetails)
    Service->>DB: db.user.update (mergedDetails)
    DB-->>Service: updatedUser
    Service-->>Route: PartnerDetails
    Route-->>Client: 200 JSON
Loading

Reviews (1): Last reviewed commit: "fixed partner profile not updating" | Re-trigger Greptile

Comment thread src/schema/partnerDetails.ts
Comment thread src/services/partnerDetailsService.ts
Comment thread src/schema/partnerDetails.ts
Comment thread src/services/partnerDetailsService.ts Outdated
ND68 and others added 3 commits April 13, 2026 19:19
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@ND68
ND68 merged commit 6c2e1dc into main Apr 13, 2026
5 checks passed
@ND68
ND68 deleted the andy/324-partner-profile-not-updating branch April 13, 2026 23:30
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