Skip to content

Conversation

@VidurShah
Copy link
Collaborator

Staff should only be able to view data, with the exception of checking the "is registered" checkbox on the student table

Changes:

  • Added role-based type definitions - Extended NextAuth Session, User, and JWT interfaces with [role?: "admin" | "staff"] field in next-auth.d.ts
  • Created temporary role management system - Built [RoleProvider] context in src/contexts/RoleContext.tsx and integrated it into the app providers as a placeholder until NextAuth authentication is implemented
  • Made TableTemplate permission-aware - Added [showActions] and [showCreateButton] props to TableTemplate.tsx to conditionally render edit/delete buttons and create buttons
  • Updated all table components - Modified StudentTable, AccountTable, PartyTable, and LocationTable to use the [useRole()]) hook and pass role-based permission props [showActions={role === "admin"}] to TableTemplate
  • Added role toggle debug button - Enhanced staff page navbar with current role display and a toggle button to switch between "admin" and "staff" roles for testing purposes
  • Preserved staff checkbox permission - Staff users can still check the "Is Registered" checkbox on the student table while all other edit/delete/create actions are admin-only

Closes #162

@github-actions
Copy link

Test Results Summary

302 tests  ±0   302 ✅ ±0   11s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit cbb2ed3. ± Comparison against base commit c972c7c.

Copy link
Collaborator

@naasanov naasanov left a comment

Choose a reason for hiding this comment

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

Some small things

const { openSidebar, closeSidebar } = useSidebar();
const [editingStudent, setEditingStudent] = useState<StudentDto | null>(null);
const [submissionError, setSubmissionError] = useState<string | null>(null);
const { role } = useRole();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could move this into TableTemplate to avoid duplicated logic between tables?

const [sidebarMode, setSidebarMode] = useState<"create" | "edit">("create");
const [editingAccount, setEditingAccount] = useState<AccountDto | null>(null);
const [submissionError, setSubmissionError] = useState<string | null>(null);
const { role } = useRole();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Forgot to mention in the original ticket, but we also need to make sure staff cannot see the accounts table. The impl for this would probably be in frontend/src/app/staff/page.tsx with the Tabs component

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.

Reduce Staff Permissions

3 participants