Skip to content

Tiffany/307 partner and staff signoff - #314

Merged
ND68 merged 6 commits into
mainfrom
tiffany/307-partner-and-staff-signoff
Apr 2, 2026
Merged

ND68 merged 6 commits into
mainfrom
tiffany/307-partner-and-staff-signoff

Conversation

@tifpham021

@tifpham021 tifpham021 commented Mar 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Resolves ticket number: #307

Explain what your code changes: Partners are now able to add their names and signatures during the signoffs process and when the signature is hovered over, we can see how it looks like.

List the steps you took to test your code:

  • Created data within Prisma Studio
  • Tested to see that when admin is signing off on shipment items, partner is able to add their name and signature
  • Looked at Sign Offs page and was able to see the partner's name and signature (and be able to hover over it)
  • Checked to see that partner's data was saved in Prisma Studio

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 Mar 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for hope-for-haiti ready!

Name Link
🔨 Latest commit 0fcde99
🔍 Latest deploy log https://app.netlify.com/projects/hope-for-haiti/deploys/69cdf05914c1840008549951
😎 Deploy Preview https://deploy-preview-314--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 Mar 29, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extends the sign-off workflow so that a partner representative can provide their name and signature alongside the staff member's signature. It adds two nullable columns (partnerSignerName, partnerSignatureUrl) to the SignOff model, wires them through the service, API, and UI layers, and updates the sign-off display in SignOffsTable and ShipmentsLineItemChipGroup to show separate staff/partner rows with hoverable signature previews.

Key changes:

  • Schema + migration: two nullable fields added to SignOff; existing records are unaffected.
  • signOffService: introduces a shared uploadSignatureIfNeeded helper and properly maps field names in updateSignOff, resolving the previously flagged Prisma unknown-arg crash.
  • SignOffModal: now collects partner signer name and both signatures before submission; hardcoded hex colours replaced with Tailwind config tokens; layout improved for smaller screens.
  • SignatureImageTooltip: refactored to accept a caller-supplied tooltipId, allowing both staff and partner tooltip instances to coexist on the same page.
  • NotificationHandler: two unrelated but valid fixes bundled in — corrects the event cleanup name ("message.new") and eliminates a stale-closure bug when checking the active support tab.

Areas for improvement:

  • partnerSignerName: z.string() in createSignOffSchema should be .min(1) to match the client-side .trim() guard (direct API callers could persist an empty name).
  • The IIFE pattern {(() => { ... })()} used in SignOffsTable and ShipmentsLineItemChipGroup to define local variables inside .map() should be replaced with plain variable declarations in the arrow function body.

Score: 84 / 100

Confidence Score: 5/5

Safe to merge — the only outstanding findings are P2 style suggestions with no runtime impact.

The previously reported P1 Prisma crash (staffUserId spread) has been fixed. All remaining findings are non-blocking: a missing .min(1) on the API schema (client already validates) and an IIFE anti-pattern in two JSX map callbacks. No data-loss, security, or correctness issues were found.

src/app/api/signOffs/route.ts (missing .min(1) on partnerSignerName); src/components/SignOffsTable.tsx and src/components/chips/ShipmentsLineItemChipGroup.tsx (IIFE pattern).

Important Files Changed

Filename Overview
src/services/signOffService.ts Refactored to use a shared uploadSignatureIfNeeded helper; updateSignOff now explicitly maps fields instead of spreading, fixing the previously flagged Prisma runtime error. Partner signature upload and storage are correctly handled.
src/app/api/signOffs/route.ts Added partnerSignerName and partnerSignatureUrl as required fields to createSignOffSchema; both accept empty strings (z.string() without .min(1)), which is weaker than the client-side .trim() guard.
src/app/api/signOffs/[signOffId]/route.ts PATCH schema extended with optional partnerSignerName, partnerSignatureUrl, and staffUserId; staffUserId is now properly handled by the service layer rather than being spread into Prisma.
src/components/SignOffModal.tsx Modal expanded to collect partner signer name and two separate signatures (staff + partner); hardcoded colours replaced with Tailwind config tokens; overflow and scrolling improved for smaller viewports.
src/components/SignOffsTable.tsx Displays both staff and partner sign-off rows with separate tooltip IDs; uses IIFE anti-pattern inside .map() to define local variables — should be refactored to plain variable declarations or a helper component.
src/components/chips/ShipmentsLineItemChipGroup.tsx Same IIFE pattern used to split staff/partner signature rows; logic otherwise mirrors SignOffsTable.tsx correctly.
src/components/SignatureImageTooltip.tsx Refactored to accept a caller-supplied tooltipId string instead of deriving it from signOffId, enabling both staff and partner tooltip instances to coexist on the same page.
src/components/NotificationHandler.tsx Fixes a stale-closure bug by caching activeTab in a ref for use inside event callbacks; also corrects the cleanup event name from "notification.message_new" to "message.new" to properly deregister the listener.
src/services/shippingStatusService.ts Extended to generate a pre-signed read URL for partnerSignatureUrl and include partnerSignerName in the returned sign-off object.
prisma/schema.prisma Added nullable partnerSignerName and partnerSignatureUrl fields to SignOff model; both are optional to remain backwards-compatible with existing records.
src/components/dashboard/PartnerDistributionTable.tsx Updated SignatureImageTooltip usage to pass explicit tooltipId instead of signOffId; no functional change to this component.
src/types/api/signOff.types.ts Added partnerSignerName (required in CreateSignOffData, optional/nullable in SignOffDetails) and optional partnerSignatureUrl and signatureUrl to SignOffDetails.

Sequence Diagram

sequenceDiagram
    participant Admin as Admin (Browser)
    participant Modal as SignOffModal
    participant API as POST /api/signOffs
    participant Service as SignOffService
    participant Azure as Azure Storage
    participant DB as Prisma / DB

    Admin->>Modal: Open sign-off modal
    Modal->>Modal: Collect staffName (auto), partnerSignerName (input)
    Modal->>Modal: Capture staff signature (canvas)
    Modal->>Modal: Capture partner signature (canvas)
    Admin->>Modal: Click Submit
    Modal->>Modal: Validate partnerSignerName.trim() & both canvases non-empty
    Modal->>API: POST FormData (staffName, partnerName, partnerSignerName, signatureUrl, partnerSignatureUrl, allocations)
    API->>API: Zod parse createSignOffSchema
    API->>Service: createSignOff(data)
    Service->>Azure: uploadSignature(staffSignatureDataUrl, staffUserId)
    Azure-->>Service: staffSignatureUrl (blob URL)
    Service->>Azure: uploadSignature(partnerSignatureDataUrl, staffUserId)
    Azure-->>Service: partnerSignatureUrl (blob URL)
    Service->>DB: signOff.create({ staffMemberName, partnerName, partnerSignerName, signatureUrl, partnerSignatureUrl, ... })
    DB-->>Service: SignOff record
    Service-->>API: SignOff record
    API-->>Modal: 200 OK
    Modal-->>Admin: onSuccess() — modal closes, table refreshes
Loading

Reviews (2): Last reviewed commit: "fixed patching issue" | Re-trigger Greptile

Comment thread src/services/signOffService.ts Outdated
Comment thread src/components/SignOffModal.tsx
Comment thread src/components/SignOffModal.tsx Outdated
@tifpham021

Copy link
Copy Markdown
Contributor Author

@greptileai

@ND68 ND68 linked an issue Mar 30, 2026 that may be closed by this pull request
@ND68

ND68 commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

thanks for putting all the validation checks in, code looks great. I just added a column so that partners can see their own signatures too

@ND68
ND68 merged commit 2da9f8b into main Apr 2, 2026
5 checks passed
@ND68
ND68 deleted the tiffany/307-partner-and-staff-signoff branch April 2, 2026 04:33
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 and Staff Sign Off

2 participants