Skip to content

AdminPage's Open-Source Week create/delete handlers surface errors in the wrong page section #889

Description

@Jagadeeshftw

Description

src/features/admin/pages/AdminPage.tsx renders exactly one error banner on the page, positioned inside the Ecosystems section, right below the "Add New Ecosystem" button:

{/* Inline error (avoid ugly alerts) */}
{errorMessage && (
  <div className={`mb-4 rounded-[16px] border px-4 py-3 text-[13px] ...`}>
    {errorMessage}
  </div>
)}

errorMessage (and setErrorMessage) is a single piece of state declared once near the top of the component. It is correctly used by the ecosystems create/edit/delete handlers, but it is also reused by the completely unrelated Open-Source Week event handlers:

const handleDeleteOswConfirmed = async () => {
  ...
  } catch (e) {
    setErrorMessage(e instanceof Error ? e.message : 'Failed to delete event.')
  } finally {
    setOswDeletingId(null)
  }
}

const handleCreateOsw = async (e: React.FormEvent) => {
  ...
  try {
    setErrorMessage(null)
    ...
    await createOpenSourceWeekEvent({ ... })
    ...
  } catch (err) {
    setErrorMessage(err instanceof Error ? err.message : 'Failed to create event.')
  } finally {
    setIsSubmitting(false)
  }
}

The "Add Open-Source Week Event" modal (showAddOswModal, rendered far below in the JSX) has no error display of its own — only per-field validation errors (oswErrors). So when createOpenSourceWeekEvent fails while that modal is open, the resulting error is written into errorMessage and rendered in the Ecosystems section's banner, which sits behind/above the still-open modal and is not visible to the admin filling out the form. The admin sees the modal just stop submitting with no visible explanation, while an unrelated error banner silently appears in a different section of the page they can't currently see. The same happens for OSW event deletion failures.

Requirements

  • Give the Open-Source Week section (including its create/delete flows) its own error state, independent from the Ecosystems section's errorMessage.
  • Surface OSW create/delete errors inside (or immediately adjacent to) the relevant modal/section so they're visible at the moment they occur.

Suggested execution

  1. Fork the repo and create a branch: git checkout -b fix/adminpage-osw-error-state-isolation
  2. Add a dedicated oswErrorMessage/setOswErrorMessage state, separate from the ecosystems' errorMessage.
  3. Update handleCreateOsw and handleDeleteOswConfirmed to use the new state instead of errorMessage.
  4. Render the OSW error inline inside the "Add Open-Source Week Event" modal (for create failures) and near the OSW events list (for delete failures).
  5. Add a test asserting a failed OSW event creation surfaces an error inside the open modal, not in the ecosystems section.

Example commit message

fix: isolate Open-Source Week error state from the ecosystems errorMessage

Acceptance criteria

  • OSW create/delete failures no longer write into the ecosystems section's errorMessage.
  • A failed OSW event creation shows a visible error inside the still-open creation modal.
  • A test covers the create-failure-while-modal-open scenario.

Security notes

None; this is a UX-correctness issue — an admin could otherwise repeatedly retry a failing action believing nothing happened, with no compounding security effect.

Guidelines

  • Minimum 95% test coverage
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issuebugSomething isn't workingfrontendFrontend / UI work

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions