Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- Job interest column for sponsors to see more info on hacker

### Fixed

- Fixed search page not loading properly
- Fixed search queries not working
- Update saved hackers for sponsors to view without refreshing page

### Fixed

- Fixed search page not loading properly
Expand Down
30 changes: 21 additions & 9 deletions src/features/Search/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ class FilterComponent extends React.Component<IFilterProps, {}> {
}
private parseInitialValues(initFilters: ISearchParameter[]) {
const initVals = {
school: this.searchParam2List('school', initFilters),
gradYear: this.searchParam2List('graduationYear', initFilters),
degree: this.searchParam2List('degree', initFilters),
school: this.searchParam2List('application.general.school', initFilters),
gradYear: this.searchParam2List(
'application.general.graduationYear',
initFilters
),
degree: this.searchParam2List('application.general.degree', initFilters),
status: this.searchParam2List('status', initFilters),
skills: this.searchParam2List('application.skills', initFilters),
skills: this.searchParam2List(
'application.shortAnswer.skills',
initFilters
),
jobInterest: this.searchParam2List(
'application.general.jobInterest',
initFilters
Expand Down Expand Up @@ -154,19 +160,25 @@ class FilterComponent extends React.Component<IFilterProps, {}> {
* @param values Formik values
*/
private handleSubmit(values: FormikValues) {
const schoolSearchParam = this.list2SearchParam('school', values.school);
const schoolSearchParam = this.list2SearchParam(
'application.general.school',
values.school
);
const gradYearParam = this.list2SearchParam(
'graduationYear',
'application.general.graduationYear',
values.gradYear
);
const degreeParam = this.list2SearchParam('degree', values.degree);
const degreeParam = this.list2SearchParam(
'application.general.degree',
values.degree
);
const statusParam = this.list2SearchParam('status', values.status);
const skillsParam = this.list2SearchParam(
'application.skills',
'application.shortAnswer.skills',
values.skills
);
const jobInterestParam = this.list2SearchParam(
'application.jobInterest',
'application.general.jobInterest',
values.jobInterest
);
let search: ISearchParameter[] = [];
Expand Down
37 changes: 30 additions & 7 deletions src/features/Search/ResultsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,36 @@ const ResultsTable: React.StatelessComponent<IResultsTableProps> = (props) => {
accessor: 'hacker.accountId.firstName',
},
];

const adminColumns = [
const generalColumns = [
...volunteerColumns,
{
Header: 'Last Name',
accessor: 'hacker.accountId.lastName',
},
{
Header: 'School',
accessor: 'hacker.school',
accessor: 'hacker.application.general.school',
},
{
Header: 'Major',
accessor: 'hacker.major',
Header: 'Field of Study',
accessor: 'hacker.application.general.fieldOfStudy',
},
{
Header: 'Grad Year',
accessor: 'hacker.graduationYear',
accessor: 'hacker.application.general.graduationYear',
},
];

const adminColumns = [
...generalColumns,
{
Header: 'Status',
accessor: 'hacker.status',
},
{
Header: 'Job Interest',
accessor: 'hacker.application.general.jobInterest',
},
{
Header: 'Applicant Info',
Cell: ({ original }: any) => (
Expand All @@ -60,7 +67,23 @@ const ResultsTable: React.StatelessComponent<IResultsTableProps> = (props) => {
];

const sponsorColumns = [
...adminColumns,
...generalColumns,
{
Header: 'Job Interest',
accessor: 'hacker.application.general.jobInterest',
},
{
Header: 'Applicant Info',
Cell: ({ original }: any) => (
<div>
<SingleHackerModal
hacker={original.hacker}
allHackers={props.results.map((r) => r.hacker)}
userType={props.userType}
/>
</div>
),
},
{
Header: 'Save',
Cell: ({ original }: any) => (
Expand Down
39 changes: 23 additions & 16 deletions src/features/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ class SearchContainer extends React.Component<{}, ISearchState> {
const sponsor = (await Sponsor.getSelf()).data.data;
this.setState({ sponsor });
}

if (this.state.query.length > 0 || this.state.searchBar.length > 0) {
this.triggerSearch();
}
await this.triggerSearch();
}
private getSearchFromQuery(): ISearchParameter[] {
const search = getValueFromQuery('q');
Expand Down Expand Up @@ -260,32 +257,40 @@ class SearchContainer extends React.Component<{}, ISearchState> {
}

private filter() {
const { sponsor, viewSaved, results, searchBar } = this.state;

const { sponsor, viewSaved, results } = this.state;
const searchBar = this.state.searchBar.toLowerCase();
return results.filter(({ hacker }) => {
const { accountId } = hacker;
let foundAcct;
if (typeof accountId !== 'string') {
const account = accountId as IAccount;
const fullName = `${account.firstName} ${account.lastName}`;
const fullName = `${account.firstName} ${
account.lastName
}`.toLowerCase();
foundAcct =
fullName.includes(searchBar) ||
account.email.includes(searchBar) ||
account.email.toLowerCase().includes(searchBar) ||
account.phoneNumber.toString().includes(searchBar) ||
// Removed as shirt size is no longer a properity of account: account.shirtSize.includes(searchBar) ||
account.gender.includes(searchBar) ||
account.gender.toLowerCase().includes(searchBar) ||
(account._id && account._id.includes(searchBar));
} else {
foundAcct = accountId.includes(searchBar);
}
const foundHacker =
hacker.id.includes(searchBar) ||
hacker.application.general.fieldOfStudy.includes(searchBar) ||
hacker.application.general.school.includes(searchBar) ||
hacker.status.includes(searchBar) ||
hacker.application.general.degree.includes(searchBar) ||
hacker.application.general.fieldOfStudy.includes(searchBar) ||
hacker.application.general.graduationYear
.toString()
.includes(searchBar);
.includes(searchBar) ||
hacker.application.general.jobInterest.includes(searchBar) ||
hacker.status.includes(searchBar) ||
hacker.application.shortAnswer.question1.includes(searchBar) ||
hacker.application.shortAnswer.question2.includes(searchBar) ||
hacker.application.accommodation.shirtSize.includes(searchBar) ||
(hacker.application.shortAnswer.skills &&
hacker.application.shortAnswer.skills.toString().includes(searchBar));

const isSavedBySponsorIfToggled =
!viewSaved ||
Expand All @@ -295,10 +300,12 @@ class SearchContainer extends React.Component<{}, ISearchState> {
});
}

private toggleSaved = () => {
const { sponsor, viewSaved } = this.state;
private toggleSaved = async () => {
// Resets the sponsor if they made changes to their saved hackers
const sponsor = (await Sponsor.getSelf()).data.data;
const { viewSaved } = this.state;
if (sponsor) {
this.setState({ viewSaved: !viewSaved });
this.setState({ sponsor, viewSaved: !viewSaved });
}
};
}
Expand Down