-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
History log for schools and teams
1 parent
952ad1a
commit 5db1739
Showing
27 changed files
with
545 additions
and
38 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,5 @@ | ||
Upgrade to Node LTS | ||
Add prettier | ||
Add husky | ||
Update eslint config and nsda-js-utils | ||
Set up CI to run server tests with mysql sidecar |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -58,3 +58,9 @@ | |
opacity: 1; | ||
visibility: visible; | ||
} | ||
|
||
.showhistory { | ||
font-size: 18px; | ||
margin-left: 10px; | ||
cursor: pointer; | ||
} |
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,70 @@ | ||
import React, { useEffect, useMemo, useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useParams } from 'react-router-dom'; | ||
|
||
import { loadSchoolHistory, loadTeamHistory } from '../helpers/api'; | ||
import Table from './Table'; | ||
import Loader from '../loader/Loader'; | ||
|
||
const HistoryTable = ({ type = 'school' }) => { | ||
const { caselist, school, team } = useParams(); | ||
const [fetching, setFetching] = useState(false); | ||
const [history, setHistory] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
try { | ||
setFetching(true); | ||
if (type === 'team') { | ||
setHistory(await loadTeamHistory(caselist, school, team)); | ||
} else { | ||
setHistory(await loadSchoolHistory(caselist, school)); | ||
} | ||
setFetching(false); | ||
} catch (err) { | ||
console.log(err); | ||
setHistory(err); | ||
setFetching(false); | ||
} | ||
}; | ||
fetchData(); | ||
}, [caselist, school, team]); | ||
|
||
const data = useMemo(() => history, [history]); | ||
const columns = [ | ||
{ | ||
Header: 'Description', | ||
width: 'auto', | ||
accessor: 'description', | ||
}, | ||
{ | ||
Header: 'Date (UTC)', | ||
width: 'auto', | ||
accessor: 'updated_at', | ||
}, | ||
{ | ||
Header: 'User', | ||
width: 'auto', | ||
accessor: 'updated_by', | ||
}, | ||
]; | ||
|
||
if (fetching) { return <Loader />; } | ||
|
||
return ( | ||
<div> | ||
<Table | ||
columns={columns} | ||
data={data} | ||
noDataText="No history found" | ||
loading={fetching} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
HistoryTable.propTypes = { | ||
type: PropTypes.string, | ||
}; | ||
|
||
export default HistoryTable; |
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,33 @@ | ||
import React from 'react'; | ||
import { assert } from 'chai'; | ||
import { vi } from 'vitest'; | ||
|
||
import { wrappedRender as render, screen, waitFor } from '../setupTests'; | ||
|
||
import HistoryTable from './HistoryTable'; | ||
|
||
vi.mock('react-router-dom', async () => { | ||
const actual = await vi.importActual('react-router-dom'); | ||
return { | ||
...actual, | ||
useParams: vi.fn().mockImplementation(() => ({ caselist: 'testcaselist', school: 'testschool', team: 'testteam' })), | ||
}; | ||
}); | ||
|
||
describe('HistoryTable', () => { | ||
it('Renders a history table for a school', async () => { | ||
render(<HistoryTable type="school" />); | ||
|
||
await waitFor(() => assert.isOk(screen.queryByText(/Test school history/), 'Description exists')); | ||
await waitFor(() => assert.isOk(screen.queryByText(/2023/), 'Date exists')); | ||
await waitFor(() => assert.isOk(screen.queryByText(/Test User/), 'User exists')); | ||
}); | ||
|
||
it('Renders a history table for a team', async () => { | ||
render(<HistoryTable type="team" />); | ||
|
||
await waitFor(() => assert.isOk(screen.queryByText(/Test team history/), 'Description exists')); | ||
await waitFor(() => assert.isOk(screen.queryByText(/2023/), 'Date exists')); | ||
await waitFor(() => assert.isOk(screen.queryByText(/Test User/), 'User exists')); | ||
}); | ||
}); |
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.