Skip to content

Fix:Opportunity statuses #332#333

Merged
need4deed merged 6 commits intoneed4deed-org:developfrom
lourooo:lourooo-fix-332-opportunity-statuses
Apr 28, 2026
Merged

Fix:Opportunity statuses #332#333
need4deed merged 6 commits intoneed4deed-org:developfrom
lourooo:lourooo-fix-332-opportunity-statuses

Conversation

@lourooo
Copy link
Copy Markdown
Contributor

@lourooo lourooo commented Apr 16, 2026

Fix: Opportunity statuses #332

Description

Add a status change modal for opportunities, similar to the volunteer engagement status. Since the backend does not yet support the new statuses, fake data is used for the 4 new ones, they update the UI only and do not send a request to the backend.

Related Issues

Closes #332

Changes

  • Created ChangeOpportunityStatusDialog, modal with radio buttons following the volunteer status pattern
  • Created useOpportunityStatusDialog, hook to manage modal state and API calls
  • Created OpportunityManualStatusType, enum with all 6 statuses (New, Searching, Cancelled by us, Cancelled by NGO, Matched - not needed, Matched - volunteer no show)
  • Updated OpportunityHeader to use the new dialog
  • Added color and icon mappings for the new statuses in statusMaps.ts
  • Added translations in EN and DE

Screenshots / Demos

image

Checklist

  • WITHIN THE SCOPE OF AN ISSUE; No unnecessary files included
  • Tests added/updated
  • Documentation updated
  • CI passes

@need4deed
Copy link
Copy Markdown
Contributor

need4deed commented Apr 16, 2026

@lourooo in the text change the explorations :
"The opportunity was not validated yet
The opportunity was validated it can be searched for
The opportunity was cancelled - no volunteer found
The opportunity was cancelled - by NGO
A volunteer was matched but at the last minute not needed
A volunteer was matched but did not show up"

Reminder: that there are other statuses that are automatic not manual so they will appear on the status but not the manual menu e.g. once somene is "matched" - matched

@lourooo
Copy link
Copy Markdown
Contributor Author

lourooo commented Apr 16, 2026

Updated

@Cy-fox
Copy link
Copy Markdown
Collaborator

Cy-fox commented Apr 17, 2026

Everything looks nice, he:

  • reuses useStatusDialog and ChangeStatusDialog from common/ consistent with the pattern used for volunteers.
  • Clean separation of concerns: hook / component / constants.

In my knowledge looks normal

@need4deed
Copy link
Copy Markdown
Contributor

check this two points

  1. OpportunityManualStatusType.NEW and SEARCHING missing from statusColorMap and statusIconMap : constants.ts defines these as "opp-new" and "opp-searching", but in statusMaps.ts the existing

OpportunityStatusType.NEW and OpportunityStatusType.SEARCHING handle the old SDK values. The new manual values opp-new / opp-searching are not in the maps, so the status badge will have no color and no
icon when those are selected.

  1. OpportunityHeader reads dialog.selected (manual type) but StatusRowField may expect the SDK type: the status displayed in the header is now always a OpportunityManualStatusType value. If

@lourooo
Copy link
Copy Markdown
Contributor Author

lourooo commented Apr 20, 2026

Updated

@nadavosa
Copy link
Copy Markdown
Collaborator

Before this gets merged, please run yarn lint and yarn typecheck locally and fix any errors. We've added a CI check (#359) that will block merging if these fail.

@lourooo
Copy link
Copy Markdown
Contributor Author

lourooo commented Apr 22, 2026

Everything is fine

@need4deed
Copy link
Copy Markdown
Contributor

@lourooo we had some changes from our side: we dont need all the new ones there (we will add it to a section so keep the code somewhere)

The selection should be:
New / Needs validation
Searching
Inactive

@lourooo
Copy link
Copy Markdown
Contributor Author

lourooo commented Apr 23, 2026

Okok

@lourooo
Copy link
Copy Markdown
Contributor Author

lourooo commented Apr 24, 2026

Updated!
image

Copy link
Copy Markdown
Collaborator

@nadavosa nadavosa left a comment

Choose a reason for hiding this comment

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

Review

No new BE endpoints needed — uses the existing useUpdateOpportunityStatus hook throughout. Good on that front.

The dialog approach is a clear improvement over the hardcoded single-step button. Two issues to fix before merging:


1. OpportunityStatusType.ACTIVE is not mapped in SDK_TO_MANUAL

export const SDK_TO_MANUAL: Partial<Record<OpportunityStatusType, OpportunityManualStatusType>> = {
  [OpportunityStatusType.NEW]: OpportunityManualStatusType.NEW,
  [OpportunityStatusType.SEARCHING]: OpportunityManualStatusType.SEARCHING,
  // ACTIVE and PAST are missing
};

toManualStatus falls back to OpportunityManualStatusType.NEW for anything not in the map — so an opportunity with ACTIVE status will display as "New / Needs validation" in the header. Either add ACTIVE as a manual status option or map it to the closest equivalent.


2. Type safety regression in statusColorMap / statusIconMap

Switching from typed object literals to Object.fromEntries() as unknown as Record<StatusValue, T> loses exhaustiveness checking. If a new StatusValue is added, TypeScript won't warn it is missing from these maps. The as unknown cast is a red flag here.

Keep the original typed Record<StatusValue, T> object literal and just add the OpportunityManualStatusType entries to it — that is all that is needed.


Also needs a rebase to resolve conflicts with develop before merging.

@nadavosa nadavosa force-pushed the lourooo-fix-332-opportunity-statuses branch from 5e0e5a9 to aa55e47 Compare April 25, 2026 11:11
@lourooo lourooo force-pushed the lourooo-fix-332-opportunity-statuses branch 2 times, most recently from 07ddf0d to bb27d81 Compare April 27, 2026 08:49
@lourooo
Copy link
Copy Markdown
Contributor Author

lourooo commented Apr 27, 2026

Updated

@nadavosa
Copy link
Copy Markdown
Collaborator

Once SDK issue need4deed-org/sdk#87 and BE migration need4deed-org/be#412 are merged, update this PR:

In `constants.ts`, change `MANUAL_TO_SDK`:
```ts
// Before (workaround):
[OpportunityManualStatusType.INACTIVE]: OpportunityStatusType.PAST,

// After:
[OpportunityManualStatusType.INACTIVE]: OpportunityStatusType.INACTIVE,
```

That's the only change needed — the modal, hook, and translations are already correct.

@lourooo lourooo force-pushed the lourooo-fix-332-opportunity-statuses branch from bb27d81 to fc420d0 Compare April 28, 2026 09:22
update need4deed-sdk to 0.0.78
@lourooo
Copy link
Copy Markdown
Contributor Author

lourooo commented Apr 28, 2026

Updated

Copy link
Copy Markdown
Collaborator

@nadavosa nadavosa left a comment

Choose a reason for hiding this comment

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

All three issues addressed:

  1. SDK_TO_MANUAL now covers ACTIVE (→ SEARCHING) and INACTIVE (→ INACTIVE) — no more fallback to NEW for active opportunities
  2. statusColorMap/statusIconMap refactored to typed spread approach — manualStatusColorMap/manualStatusIconMap use proper Record<OpportunityManualStatusType, ...> which preserves exhaustiveness checking
  3. SDK bumped to 0.0.78 which adds INACTIVE

One thing remaining before merge: the PR needs a rebase to resolve conflicts with develop.

@need4deed need4deed merged commit f6b4cad into need4deed-org:develop Apr 28, 2026
1 check 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.

Opportunity statuses

4 participants