Skip to content

Admin Bugbash Fixes - #209

Open
Yurika-Kan wants to merge 40 commits into
mainfrom
yk/admin-bugbash
Open

Admin Bugbash Fixes#209
Yurika-Kan wants to merge 40 commits into
mainfrom
yk/admin-bugbash

Conversation

@Yurika-Kan

Copy link
Copy Markdown
Collaborator

📝 Description

  • Navbar clears the user only on unauthenticated, killing the load/refresh flicker; phone validation messages reworded.
  • Invalid ?donationId / ?orderId deep links show a "not found" error.
  • Donation Statistics totals fetch is independent of pagination, so "All Pantries" renders on every page.
  • Failed application fetches render an "Unable to Load Applications" error state.
  • Application Review "View Details" uses navigate() instead of href (SPA transition).
  • Cognito errors include the AWS reason and re-throw existing HttpExceptions.
  • Approve Food Manufacturers pagination arrows disable at first/last page.
  • Pantry assignee column checks for active volunteers before falling back to "No Volunteer".
  • User Management shows an "Admin" badge on admin rows.
  • Donation / Pantry / Manufacturer / Order Management show a "no results match filter" state.
  • Order Management table wrapped in overflowX="auto".
  • Removed dev-only "All Pages" nav link.
  • Donation details and delete modals hold the last donation in a ref while closing, fixing focus-trap errors.
  • Admin order table now refreshes auto after allocation edits.

Copilot AI lite review requested due to automatic review settings August 12, 2026 04:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR bundles a set of admin-facing UI/UX bug fixes across the frontend (empty/error states, pagination behavior, SPA navigation, table overflow, and modal stability) plus backend improvements to validation messages and Cognito error propagation, along with an auth endpoint audit document.

Changes:

  • Improve admin list pages: add “no matching results” / error states, fix pagination behaviors, and enhance navigation/labels.
  • Stabilize donation modals during close (avoid focus-trap/body-lock issues) and refresh admin orders after allocation edits.
  • Update backend phone validation messages and include underlying Cognito/AWS failure reasons in auth errors; add backend auth posture audit doc.

Reviewed changes

Copilot reviewed 19 out of 21 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
apps/frontend/src/containers/userManagement.tsx Adds an “Admin” badge for admin rows in the volunteer table.
apps/frontend/src/containers/approvePantries.tsx Adds fetch error state UI and switches “View Details” to SPA navigation.
apps/frontend/src/containers/approveFoodManufacturers.tsx Adds fetch error UI, “no matching applications” empty state, SPA navigation, and disables pagination arrows at bounds.
apps/frontend/src/containers/adminPantryManagement.tsx Adds “no pantries / no matching pantries” empty state and refines assignee display to only consider active volunteers.
apps/frontend/src/containers/adminOrderManagement.tsx Refactors order fetch into a reusable callback, adds deep-link “not found” error, refreshes after edits, and adds horizontal overflow for the table.
apps/frontend/src/containers/adminDonationStats.tsx Fetches total stats independent of pagination so “All Pantries” totals render on every page.
apps/frontend/src/containers/adminDonation.tsx Adds deep-link “donation not found” error, adds filtered empty state, and renders details modal in a way that supports stable closing.
apps/frontend/src/components/Navbar.tsx Avoids clearing current user during non-unauthenticated transitions; removes dev-only nav link; adjusts label text.
apps/frontend/src/components/forms/fmDeleteDonationModal.tsx Holds the last donation in a ref during close to prevent modal lock/focus issues.
apps/frontend/src/components/forms/donationDetailsModal.tsx Holds the last donation in a ref during close; updates header/details rendering accordingly.
apps/backend/src/users/dtos/userSchema.dto.ts Updates phone validation message wording.
apps/backend/src/users/dtos/update-user-info.dto.ts Updates phone validation message wording.
apps/backend/src/pantries/dtos/update-pantry-application.dto.ts Updates secondary contact phone validation message wording.
apps/backend/src/pantries/dtos/pantry-application.dto.ts Updates phone and secondary contact phone validation message wording.
apps/backend/src/foodManufacturers/dtos/update-manufacturer-application.dto.ts Updates secondary contact phone validation message wording.
apps/backend/src/foodManufacturers/dtos/manufacturer-application.dto.ts Updates phone and secondary contact phone validation message wording.
apps/backend/src/auth/dtos/sign-up.dto.ts Updates phone validation message wording.
apps/backend/src/auth/auth.service.ts Re-throws existing HttpExceptions and appends underlying error “reason” to internal server errors.
apps/backend/src/auth/AUTH_AUDIT.md Adds a living inventory of backend routes and their auth/guard posture.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/frontend/src/components/forms/donationDetailsModal.tsx Outdated
Comment thread apps/frontend/src/containers/approvePantries.tsx
Comment thread apps/frontend/src/containers/approveFoodManufacturers.tsx
Comment thread apps/frontend/src/containers/adminPantryManagement.tsx Outdated
Comment thread apps/backend/src/pantries/dtos/update-pantry-application.dto.ts
Comment thread apps/backend/src/pantries/dtos/pantry-application.dto.ts

@dburkhart07 dburkhart07 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

one other thing: is the test.ico actually needed here?

Comment thread apps/backend/src/auth/AUTH_AUDIT.md Outdated
Comment thread apps/backend/src/auth/dtos/sign-up.dto.ts Outdated
Comment thread apps/backend/src/pantries/dtos/pantry-application.dto.ts
Comment thread apps/frontend/src/components/Navbar.tsx
Comment thread apps/frontend/src/containers/adminOrderManagement.tsx
Comment thread apps/frontend/src/containers/adminPantryManagement.tsx Outdated
Comment thread apps/frontend/src/containers/approveFoodManufacturers.tsx Outdated
Comment thread apps/frontend/src/containers/userManagement.tsx
Prevents "Donation #undefined" header flash during modal close animation.
Yurika-Kan and others added 2 commits August 14, 2026 18:11
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Yurika-Kan <148014074+Yurika-Kan@users.noreply.github.com>
Yurika-Kan and others added 3 commits August 14, 2026 18:19
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Yurika-Kan
Yurika-Kan requested a review from dburkhart07 August 14, 2026 23:50

@dburkhart07 dburkhart07 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

see a few slack questions in addition to this.

Comment thread apps/frontend/src/app.tsx
{
index: true,
element: <Homepage />,
element: <Navigate to={ROUTES.LOGIN} replace />,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We now have an issue that, if the user is already logged in, and is supposed to be brought straight to the profile page (one that depends entirely on backend data, unlike the homepage we used to have), itll take 30 seconds for the backend to startup before the user can actually see details on it (right now it just says No Profile Found until then). Im not sure if there is a workaround for this (or maybe its not a big deal since in theory the backend will be permanently running when its in production), but wanted to ask.

Comment thread apps/frontend/src/app.tsx
Comment thread apps/backend/src/auth/dtos/sign-up.dto.ts
Comment thread apps/frontend/src/components/forms/donationDetailsModal.tsx
@@ -35,8 +35,10 @@ const NewVolunteerModal: React.FC<NewVolunteerModalProps> = ({
const [isOpen, setIsOpen] = useState(false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Found a new bug, where the alert state gets stale.

To reproduce:

  1. Open the "Add New User" modal.
  2. Enter a faulty name/email/phone number.
  3. Close the modal.
  4. Open the modal again, and the error message appears without filling in any fields.

Yurika-Kan and others added 6 commits August 23, 2026 13:58
Drops password/phone (never used by admin-created users) and adds role
directly to the DTO instead of an ad-hoc Omit<> intersection type.
…n cold backend

Previously a single failed getMe() call (e.g. backend still starting up)
permanently showed "Profile not found", with no recovery short of a
manual refresh. Now retries every 3s while the backend is unreachable
(no HTTP response), only giving up on a real auth error response.
Closing via backdrop click or the X button left isEditing stuck true,
so reopening the modal showed the edit form instead of the details
view. Only the Cancel button reset it before. Now onOpenChange resets
isEditing whenever the dialog closes, matching Cancel's behavior.
Requested in review for readability now that public/protected routes
are interleaved without the old homepage route as a visual anchor.
Standardizes filter UX by adding search-to-filter inputs to
adminDonation, approveFoodManufacturers, and approvePantries, matching
the existing pattern in pantry/manufacturer management pages.
…ntity

Backend rejects edit/delete once a donation has reserved items even
while status is still AVAILABLE; mirror that in the details modal.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Yurika-Kan

Copy link
Copy Markdown
Collaborator Author
  • Retry profile fetch: cold backend no longer sticks "not found" forever, retries first.
  • Trim SignUpDto: adminCreateUser only uses fields it needs now.
  • Reset isEditing: donation details modal clears edit state on close.
  • Protected routes marker: comment in app.tsx flags where protected routes start.
  • Search in filter dropdowns: manufacturer/pantry filters get search box (adminDonation, approveFoodManufacturers, approvePantries).
  • Hide edit/delete on reserved donations: donationDetailsModal hides edit/delete when items have reserved quantity.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 43 out of 44 changed files in this pull request and generated 3 comments.

Suppressed comments (1)

apps/backend/src/foodManufacturers/dtos/update-manufacturer-application.dto.ts:41

  • The updated validation copy here uses "Secondary phone contact…", but other updated DTOs in this PR use the shorter "Secondary phone…" phrasing. For consistency (and clearer UX), align this message with the others (e.g., "Secondary phone must be a valid US phone number.").
  @IsOptional()
  @IsString()
  @IsPhoneNumber('US', {
    message: 'Secondary phone contact must be a valid US phone number.',
  })

Comment thread apps/frontend/src/containers/profilePage.tsx Outdated
Comment on lines 301 to 309
<OrderDetailsModal
orderId={selectedOrderId}
isOpen={selectedOrderId !== null}
onClose={() => {
setSelectedOrderId(null);
navigate(ROUTES.ADMIN_ORDER_MANAGEMENT, { replace: true });
}}
onSuccess={fetchOrders}
/>
Comment thread apps/frontend/src/components/pagination.tsx
Yurika-Kan and others added 4 commits August 23, 2026 16:16
Alert state persisted across modal reopens since only isOpen was reset. clearAlert now runs on every close path (X, Cancel, backdrop, success/fail).
Long badge labels (e.g. "Food Manufacturer") could overflow past the
card's right edge on narrow cards since the header row never wrapped.
… disappears

selectedManufacturers never got reconciled against manufacturerOptions after
a refetch, so deleting a manufacturer's last donation left its name stuck in
the filter state with no visible checkbox to uncheck it, permanently showing
"No donations match the selected filter." Also reset the filter's search
text on close so it doesn't show a stale query with no results.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Yurika-Kan

Copy link
Copy Markdown
Collaborator Author
  • stale manufacturer filter stuck showing "No donations match filter" after last matching donation deleted
  • Filter selection now prunes itself against live options on every refetch
  • Search box text now clears when filter dropdown closes

…ut safely

Address Copilot review comments: fetchOrders was resetting currentPages
to 1 on every call, bouncing admin back to page 1 after saving edits
in the order details modal. Also type retryTimeout as possibly
undefined to match how it's actually assigned.
The accepted Copilot autofix (cc953a8) left the closing tag missing
its '>', a JSX syntax error that would fail the build.

@dburkhart07 dburkhart07 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Admin and Volunteer Food Request Management Filter still needs the search added to it, but aside from this looks great!!!

@jiang-h-y jiang-h-y left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lgtm! tested that the bugs we surfaced can no longer be reproduced

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.

5 participants