-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from ucsb-cs156-s24/Jason-StaffIndexPage
Jason Added Staff Index Page (Redirected from a Course's Staff Button)
- Loading branch information
Showing
9 changed files
with
623 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react' | ||
import { useBackend } from 'main/utils/useBackend'; | ||
import BasicLayout from "main/layouts/BasicLayout/BasicLayout"; | ||
import StaffTable from 'main/components/Staff/StaffTable'; | ||
import { Button } from 'react-bootstrap'; | ||
import { useCurrentUser, hasRole} from 'main/utils/currentUser'; | ||
import { useParams } from "react-router-dom"; | ||
|
||
export default function CourseIndexPage() { | ||
|
||
const { data: currentUser } = useCurrentUser(); | ||
let { id } = useParams(); | ||
const addStaffButton = () => { | ||
|
||
return ( | ||
<Button | ||
variant="primary" | ||
href="/courses/addStaff" | ||
style={{ float: "right" }} | ||
> | ||
Add Staff Member | ||
</Button> | ||
) | ||
|
||
} | ||
|
||
const { data: staff, error: _error, status: _status } = | ||
useBackend( | ||
// Stryker disable next-line all : don't test internal caching of React Query | ||
[`/api/courses?id=${id}/staff`], | ||
// Stryker disable next-line all : GET is the default | ||
{ method: "GET", url: "/api/courses/getStaff", params: { courseId: parseInt(id) } }, | ||
[] | ||
); | ||
|
||
return ( | ||
<BasicLayout> | ||
<div className="pt-2"> | ||
{(hasRole(currentUser, "ROLE_ADMIN") || hasRole(currentUser, "ROLE_INSTRUCTOR")) && addStaffButton()} | ||
<h1>Staff</h1> | ||
<StaffTable staff={staff} currentUser={currentUser} /> | ||
|
||
</div> | ||
</BasicLayout> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import BasicLayout from "main/layouts/BasicLayout/BasicLayout"; | ||
|
||
export default function StaffCreatePage() { | ||
|
||
// Stryker disable all : placeholder for future implementation | ||
return ( | ||
<BasicLayout> | ||
<div className="pt-2"> | ||
<h1>Create page not yet implemented</h1> | ||
</div> | ||
</BasicLayout> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from 'react'; | ||
import { apiCurrentUserFixtures } from "fixtures/currentUserFixtures"; | ||
import { systemInfoFixtures } from "fixtures/systemInfoFixtures"; | ||
import { staffFixture } from "fixtures/staffFixture"; | ||
import { rest } from "msw"; | ||
|
||
import CoursesStaffPage from "main/pages/CoursesStaffPage"; | ||
|
||
export default { | ||
title: 'pages/Course/CoursesStaffPage', | ||
component: CoursesStaffPage | ||
}; | ||
|
||
const Template = () => <CoursesStaffPage storybook={true}/>; | ||
|
||
export const Empty = Template.bind({}); | ||
Empty.parameters = { | ||
msw: [ | ||
rest.get('/api/currentUser', (_req, res, ctx) => { | ||
return res( ctx.json(apiCurrentUserFixtures.adminUser)); | ||
}), | ||
rest.get('/api/systemInfo', (_req, res, ctx) => { | ||
return res(ctx.json(systemInfoFixtures.showingNeither)); | ||
}), | ||
rest.get('/api/courses/all', (_req, res, ctx) => { | ||
return res(ctx.json(staffFixture.threeStaff)); | ||
}), | ||
rest.delete('/api/courses', (req, res, ctx) => { | ||
window.alert("DELETE: " + JSON.stringify(req.url)); | ||
return res(ctx.status(200),ctx.json({})); | ||
}), | ||
] | ||
} | ||
|
||
export const ThreeItemsInstructorUser = Template.bind({}); | ||
|
||
ThreeItemsInstructorUser.parameters = { | ||
msw: [ | ||
rest.get('/api/currentUser', (_req, res, ctx) => { | ||
return res( ctx.json(apiCurrentUserFixtures.instructorUser)); | ||
}), | ||
rest.get('/api/systemInfo', (_req, res, ctx) => { | ||
return res(ctx.json(systemInfoFixtures.showingNeither)); | ||
}), | ||
rest.get('/api/courses/all', (_req, res, ctx) => { | ||
return res(ctx.json(staffFixture.threeStaff)); | ||
}), | ||
rest.delete('/api/courses', (req, res, ctx) => { | ||
window.alert("DELETE: " + JSON.stringify(req.url)); | ||
return res(ctx.status(200),ctx.json({})); | ||
}), | ||
], | ||
} | ||
|
||
export const ThreeItemsAdminUser = Template.bind({}); | ||
|
||
ThreeItemsAdminUser.parameters = { | ||
msw: [ | ||
rest.get('/api/currentUser', (_req, res, ctx) => { | ||
return res( ctx.json(apiCurrentUserFixtures.adminUser)); | ||
}), | ||
rest.get('/api/systemInfo', (_req, res, ctx) => { | ||
return res(ctx.json(systemInfoFixtures.showingNeither)); | ||
}), | ||
rest.get('/api/courses/all', (_req, res, ctx) => { | ||
return res(ctx.json(staffFixture.threeStaff)); | ||
}), | ||
rest.delete('/api/courses', (req, res, ctx) => { | ||
window.alert("DELETE: " + JSON.stringify(req.url)); | ||
return res(ctx.status(200),ctx.json({})); | ||
}), | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import { apiCurrentUserFixtures } from "fixtures/currentUserFixtures"; | ||
import { systemInfoFixtures } from "fixtures/systemInfoFixtures"; | ||
import { rest } from "msw"; | ||
|
||
import StaffCreatePage from 'main/pages/StaffCreatePage'; | ||
|
||
export default { | ||
title: 'pages/Staff/StaffCreatePage', | ||
component: StaffCreatePage | ||
}; | ||
|
||
const Template = () => <StaffCreatePage storybook={true} />; | ||
|
||
export const Default = Template.bind({}); | ||
Default.parameters = { | ||
msw: [ | ||
rest.get('/api/currentUser', (_req, res, ctx) => { | ||
return res(ctx.json(apiCurrentUserFixtures.userOnly)); | ||
}), | ||
rest.get('/api/systemInfo', (_req, res, ctx) => { | ||
return res(ctx.json(systemInfoFixtures.showingNeither)); | ||
}), | ||
rest.post('/api/helprequest/post', (req, res, ctx) => { | ||
window.alert("POST: " + JSON.stringify(req.url)); | ||
return res(ctx.status(200),ctx.json({})); | ||
}), | ||
] | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.