Skip to content

Commit

Permalink
Andy add sorting to admin resume table (#617)
Browse files Browse the repository at this point in the history
* Filters still not working

Admin Resume Table Sorting in progress

* Fixed prettier issues

* Fixed more prettier issues

* Removed unused bits of code and old comments

* Removed test data, begun default value changing

* Filters for graduation year works

* Removed onFilterDropdownVisibleChange

* Fixed year filter showing up multiple times

Needed to filter by resume year, not resume object

* Plugged the code back into the API

Removed mock resumes

* Fixed some linting errors

* Deleting my homework that somehow got in

* Adjusted resume filter logic to use sets

* Plugged UserResumeTable back into API
  • Loading branch information
WishingWell13 authored Apr 29, 2023
1 parent c258937 commit 294e6d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/admin/components/UserResumeTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ const UserResumeTable: React.FC<UserResumeTableProps> = (props) => {
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);

const updateYearFilters = () => {
const gradYears = resumes?.map((resume) => resume.user.graduationYear);
const uniqueYears = [...new Set(gradYears)];
const dropdownOptions = uniqueYears?.sort((a, b) => a - b);

setYearFilters(
// Resumes.indexOf(value) === index checks for first occurance
resumes
?.filter((value: UserResume, index: number) => resumes.indexOf(value) === index)
.sort((resume1, resume2) => resume1.user.graduationYear - resume2.user.graduationYear)
.map((element) => ({
text: `${element.user.graduationYear}`,
value: `${element.user.graduationYear}`,
})),
dropdownOptions.map((uniqueYear) => ({
text: `${uniqueYear}`,
value: `${uniqueYear}`,
})),
);
};

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "ES6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down

0 comments on commit 294e6d6

Please sign in to comment.