Skip to content

#29 Add /admin/cycles/[id] Cycle-Scoped Admin Dashboard#39

Merged
b-at-neu merged 9 commits into
devfrom
copilot/create-cycle-view-route
Feb 23, 2026
Merged

#29 Add /admin/cycles/[id] Cycle-Scoped Admin Dashboard#39
b-at-neu merged 9 commits into
devfrom
copilot/create-cycle-view-route

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 23, 2026

  • Add getCycleById to lib/data/cycles.ts
  • Add getApplicationsWithNominationCountsByCycleId and getApplicationWithNominationsByCycleId to lib/data/applications.ts
  • Add getNominationsByCycleId to lib/data/nominations.ts
  • Add getEndorsementsByCycleId to lib/data/endorsements.ts
  • Add getSettingsByCycleId to lib/data/settings.ts
  • Install @radix-ui/react-tabs and create shadcn Tabs component
  • Add readOnly prop to SettingsForm
  • Create app/admin/cycles/[id]/page.tsx server component
  • Create app/admin/cycles/[id]/cycle-dashboard.tsx client component
  • Create app/admin/cycles/[id]/endorsements-view.tsx
  • Fix: pass getApplicationDetails as bound server action instead of inline closure
  • Remove "Set as Active" button from cycle detail page
  • Settings always read-only on cycle detail page
  • Hide Settings tab if settings don't exist for the cycle
  • Make TabsList full width; equal tab spacing via flex-1 on TabsTrigger
  • Hide "View" button for active cycle in cycles-manager table
  • Remove revalidatePath('/admin/cycles') from setActiveCycle action
  • Remove green hover highlight from tab triggers
  • Remove green row highlight (bg-success/10) from cycles archive table
Original prompt

This section details on the original issue you should resolve

<issue_title>Viewing Specific Cycle</issue_title>
<issue_description>#### Context
When viewing past cycles, admins need to see all data for that cycle. Admin dashboard already exists with applications, nominations, endorsements, and settings tabs.

Goal

Create route /cycles/[id] that shows admin dashboard scoped to specific cycle.

Features

Route: /cycles/[id]

Page Layout:

  • Header showing cycle name and active/inactive badge
  • "Back to Cycle Archive" link
  • If inactive: "Set as Active" button in header
  • Same admin dashboard tabs as main admin page:
    • Applications (filtered to this cycle)
    • Nominations (filtered to this cycle)
    • Endorsements (filtered to this cycle)
    • Settings (for this cycle)

Data Scoping:

  • All queries filtered by cycleId from URL
  • Applications: where: { cycleId }
  • Nominations: where: { cycleId }
  • Endorsements: where: { cycleId }
  • Settings: where: { cycleId }

Read-Only for Inactive:

  • If cycle is inactive (isActive = false):
    • Settings page is read-only (display only, no edit buttons)
    • Banner: "This is an inactive cycle. Settings cannot be modified."
  • If cycle is active:
    • Settings page is editable (same as main admin dashboard)

Set Active Button:

  • In header for inactive cycles
  • Clicking shows same confirmation as archive page
  • On confirm: Updates isActive flags and redirects to same page

Acceptance Criteria

  • Route /cycles/[id] displays admin dashboard for that cycle
  • All tabs show data filtered by cycle
  • Header shows cycle name and status badge
  • Inactive cycles have read-only settings with banner
  • Active cycle has editable settings
  • "Set as Active" button works for inactive cycles
  • Can navigate between different cycle views</issue_description>

<agent_instructions>ticket #29
</agent_instructions>

Comments on the Issue (you are @copilot in this section)

  • Fixes b-at-neu/senate-path#29

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
senate-path Ready Ready Preview, Comment Feb 23, 2026 9:09pm

Co-authored-by: b-at-neu <144247685+b-at-neu@users.noreply.github.com>
Copilot AI changed the title [WIP] Add route to view specific cycle in admin dashboard #29 Add /admin/cycles/[id] Cycle-Scoped Admin Dashboard Feb 23, 2026
Copilot AI requested a review from b-at-neu February 23, 2026 04:31
@b-at-neu
Copy link
Copy Markdown
Collaborator

@copilot

50 | export async function getSettingsByCycleId(cycleId: string): Promise<Settings | null> {
| ^^^^^^^^^^^^^^^^^^^^
51 | return db.settings.findUnique({
52 | where: { cycleId },
53 | });

Co-authored-by: b-at-neu <144247685+b-at-neu@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Feb 23, 2026

@copilot

50 | export async function getSettingsByCycleId(cycleId: string): Promise<Settings | null> {
| ^^^^^^^^^^^^^^^^^^^^
...

Fixed in 02d4c25 — the duplicate getSettingsByCycleId declaration (at line 50) was introduced during the merge and has been removed. Only the first declaration at line 21 remains.

@b-at-neu
Copy link
Copy Markdown
Collaborator

@copilot Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it.
{cycle: ..., applications: [], getApplicationDetails: function getApplicationDetails, nominations: ..., endorsements: ..., settings: ...}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at stringify () {
digest: '560677928'
}

Co-authored-by: b-at-neu <144247685+b-at-neu@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Feb 23, 2026

@copilot Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it...

Fixed in 3973829. The inline arrow function (appId) => getApplicationWithNominationsByCycleId(appId, id) can't be serialized by Next.js. Swapped the parameter order in getApplicationWithNominationsByCycleId to (cycleId, id) and now pass it as a bound server action: getApplicationWithNominationsByCycleId.bind(null, id).

Copy link
Copy Markdown
Collaborator

@b-at-neu b-at-neu left a comment

Choose a reason for hiding this comment

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

@copilot can you not have a view button for the active cycle? The settings should always be readonly on this page

},
};

const defaultSettings: Settings = settings ?? {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if the settings don't exist, don't show the tab

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 60748b9 — the Settings tab (and its content) are now conditionally rendered only when settings !== null.

</div>
</div>

{showSetActiveModal && (
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don't have a set active button on this page

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed in 60748b9.

)}

{/* Tabs */}
<Tabs defaultValue="applications">
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

make this tab bar full width

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated in 60748b9TabsList now has w-full class.

}

export default async function CyclePage({ params }: CyclePageProps) {
const supabase = await createClient();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

use global client

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if it already exists

Comment thread lib/actions/cycles.ts Outdated
});

revalidatePath('/admin');
revalidatePath('/admin/cycles');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove this line

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed in 60748b9.

…ings, full-width tabs, hide settings tab if null, remove view button for active cycle

Co-authored-by: b-at-neu <144247685+b-at-neu@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Feb 23, 2026

@copilot can you not have a view button for the active cycle? The settings should always be readonly on this page

Done in 60748b9 — the "View" button in the cycles table is now hidden for active cycles, and settings on the cycle detail page are always read-only regardless of cycle status.

Copilot AI requested a review from b-at-neu February 23, 2026 07:11
@b-at-neu
Copy link
Copy Markdown
Collaborator

@copilot can you make each tab have equal spacing? Also can you not remove the green highlight on hover?

…hlight

Co-authored-by: b-at-neu <144247685+b-at-neu@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 23, 2026

Deployment failed with the following error:

Resource is limited - try again in 13 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/b-at-neus-projects?upgradeToPro=build-rate-limit

Copy link
Copy Markdown
Author

Copilot AI commented Feb 23, 2026

@copilot can you make each tab have equal spacing? Also can you not remove the green highlight on hover?

Done in 7cfbf98 — added flex-1 to TabsTrigger so all tabs share equal width, and added hover:bg-success/15 hover:text-success for the green hover highlight.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 23, 2026

Deployment failed with the following error:

Resource is limited - try again in 1 hour (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/b-at-neus-projects?upgradeToPro=build-rate-limit

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 23, 2026

Deployment failed with the following error:

Resource is limited - try again in 15 minutes (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/b-at-neus-projects?upgradeToPro=build-rate-limit

@b-at-neu
Copy link
Copy Markdown
Collaborator

@copilot get rid of the highlight on the tabs. I want to edit the hover on the table of cycles. Lets just get rid of the green highlight entirely

Co-authored-by: b-at-neu <144247685+b-at-neu@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Feb 23, 2026

@copilot get rid of the highlight on the tabs. I want to edit the hover on the table of cycles. Lets just get rid of the green highlight entirely

Done in 5fb020e — removed hover:bg-success/15 hover:text-success from the tab triggers.

@b-at-neu
Copy link
Copy Markdown
Collaborator

@copilot remove the green highlight from the /admin/cycles page

Co-authored-by: b-at-neu <144247685+b-at-neu@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Feb 23, 2026

@copilot remove the green highlight from the /admin/cycles page

Done in 24885b7 — removed the bg-success/10 class from the active cycle's table row in cycles-manager.tsx.

@b-at-neu b-at-neu marked this pull request as ready for review February 23, 2026 21:22
@b-at-neu b-at-neu merged commit 811a613 into dev Feb 23, 2026
2 checks passed
@b-at-neu b-at-neu deleted the copilot/create-cycle-view-route branch February 23, 2026 21:22
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.

Viewing Specific Cycle

2 participants