orders groups - BevvyTech/BrewskiDocs GitHub Wiki

Groups – Directory (/groups)

Purpose

  • Give brewery teams a home for managing group memberships without diving into raw API tools.
  • Surface pending invitations, active groups, and visibility status so owners/admins can act quickly.
  • Appears under the top-level Groups menu (moved from the Orders section) when the admin.group-deliveries feature flag is enabled.

Data & Dependencies

  • Loads groups via groupsService.list(teamId, token); the response includes membership status, counts, and content version summaries.
  • Region choices are fetched via GET /public/regions, which returns the curated UK top-level regions mirrored from the Shop catalogue.
  • The invite dialog pulls existing breweries via GET /groups/:groupId/eligible-teams, filtering out members or pending invites so owners only pick from eligible teams.
  • Actions call groupsService.acceptMembership, groupsService.declineMembership, and groupsService.leave depending on the row.
  • Creating a group uses groupsService.create and navigates users straight to the new detail page.
  • Shop visibility chips pick translation keys directly from the summary (orders-groups-shop-visible, orders-groups-shop-hidden, or orders-groups-shop-retired) based on group.shopVisible and group.status.

Key Interactions

  • Start a group opens the modal for name/region/description and creates the group under the active team.
  • Invite dialog now offers two tabs: search existing breweries (autocomplete) or send an email invitation when the brewery is off-platform.
  • Invited rows expose inline Accept / Decline buttons (with per-row spinners) so teams can respond immediately.
  • Active memberships navigate to the detail view when the row or group name is clicked, and expose Leave (confirmation dialog) in the overflow menu.
  • Status chips show Shop exposure (Live in Shop vs Hidden) and pending approval states for content updates.
  • Shop status can be toggled inline via a dropdown chip that switches between Hidden and Public, applying immediately for owner/admin members.
  • Empty state encourages creating the first group; table refreshes automatically after mutations and can be manual via Refresh once more server-side hooks are in place.
  • The full-width pagination footer mirrors the rest of Admin: the 10/25/50/100 selector writes to brewski.pagination.pageSize, chevron buttons flank the page-jump dropdown, and the summary text (“Showing X–Y of Z / Page X of Y”) stays in sync with the API metadata for both team and system directories.

Badge Sync

  • Menu badges are orchestrated by menuBadgeManager (Admin/src/lib/menu-badge-manager.ts), which runs the registered badge scripts on page load and every 10 seconds.
  • The groups badge script (Admin/src/menu-badge-scripts/groups.ts) fetches invite counts and shipping requests via groupsService.notifications.
  • Accepting, declining, or leaving a group triggers triggerMenuBadgeRefresh() so the navigation badge count drops immediately after membership actions.
⚠️ **GitHub.com Fallback** ⚠️