This repository has been archived by the owner on Jul 19, 2023. It is now read-only.
-
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 #7 from AJRedDevil/develop
Location
- Loading branch information
Showing
5 changed files
with
267 additions
and
3 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,52 @@ | ||
import React from 'react'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import Radio from '@material-ui/core/Radio'; | ||
import RadioGroup from '@material-ui/core/RadioGroup'; | ||
import FormControlLabel from '@material-ui/core/FormControlLabel'; | ||
import FormControl from '@material-ui/core/FormControl'; | ||
import FormLabel from '@material-ui/core/FormLabel'; | ||
|
||
export default function LocationRadio({value, handleChange}) { | ||
return ( | ||
<Paper className="location"> | ||
<div className="flex-align-md"> | ||
<FormControl component="fieldset"> | ||
<FormLabel component="legend">Location</FormLabel> | ||
<RadioGroup | ||
aria-label="position" | ||
name="location" | ||
value={value} | ||
onChange={handleChange} | ||
row | ||
color="default" | ||
> | ||
<FormControlLabel | ||
value="all" | ||
control={<Radio color="default" />} | ||
label="All" | ||
labelPlacement="start" | ||
/> | ||
<FormControlLabel | ||
value="us" | ||
control={<Radio color="default" />} | ||
label="U.S." | ||
labelPlacement="start" | ||
/> | ||
<FormControlLabel | ||
value="international" | ||
control={<Radio color="default" />} | ||
label="International" | ||
labelPlacement="start" | ||
/> | ||
<FormControlLabel | ||
value="remote" | ||
control={<Radio color="default" />} | ||
label="Remote" | ||
labelPlacement="start" | ||
/> | ||
</RadioGroup> | ||
</FormControl> | ||
</div> | ||
</Paper> | ||
); | ||
} |
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,138 @@ | ||
export const stateNames = [ | ||
'Alabama', | ||
'Alaska', | ||
'American Samoa', | ||
'Arizona', | ||
'Arkansas', | ||
'California', | ||
'Colorado', | ||
'Connecticut', | ||
'Delaware', | ||
'District of Columbia', | ||
'Federated States of Micronesia', | ||
'Florida', | ||
'Georgia', | ||
'Guam', | ||
'Hawaii', | ||
'Idaho', | ||
'Illinois', | ||
'Indiana', | ||
'Iowa', | ||
'Kansas', | ||
'Kentucky', | ||
'Louisiana', | ||
'Maine', | ||
'Marshall Islands', | ||
'Maryland', | ||
'Massachusetts', | ||
'Michigan', | ||
'Minnesota', | ||
'Mississippi', | ||
'Missouri', | ||
'Montana', | ||
'Nebraska', | ||
'Nevada', | ||
'New Hampshire', | ||
'New Jersey', | ||
'New Mexico', | ||
'New York', | ||
'North Carolina', | ||
'North Dakota', | ||
'Northern Mariana Islands', | ||
'Ohio', | ||
'Oklahoma', | ||
'Oregon', | ||
'Palau', | ||
'Pennsylvania', | ||
'Puerto Rico', | ||
'Rhode Island', | ||
'South Carolina', | ||
'South Dakota', | ||
'Tennessee', | ||
'Texas', | ||
'Utah', | ||
'Vermont', | ||
'Virgin Island', | ||
'Virginia', | ||
'Washington', | ||
'West Virginia', | ||
'Wisconsin', | ||
'Wyoming', | ||
]; | ||
|
||
export const stateAbbrevs = [ | ||
'AK', | ||
'AL', | ||
'AR', | ||
'AZ', | ||
'CA', | ||
'CO', | ||
'CT', | ||
'DC', | ||
'DE', | ||
'FL', | ||
'GA', | ||
'HI', | ||
'IA', | ||
'ID', | ||
'IL', | ||
'IN', | ||
'KS', | ||
'KY', | ||
'LA', | ||
'MA', | ||
'MD', | ||
'ME', | ||
'MI', | ||
'MN', | ||
'MO', | ||
'MS', | ||
'MT', | ||
'NC', | ||
'ND', | ||
'NE', | ||
'NH', | ||
'NJ', | ||
'NM', | ||
'NV', | ||
'NY', | ||
'OH', | ||
'OK', | ||
'OR', | ||
'PA', | ||
'RI', | ||
'SC', | ||
'SD', | ||
'TN', | ||
'TX', | ||
'UT', | ||
'VA', | ||
'VT', | ||
'WA', | ||
'WI', | ||
'WV', | ||
'WY', | ||
]; | ||
|
||
// common us cities | ||
export const USCityNames = [ | ||
'Austin', | ||
'San Francisco', | ||
'Los Angeles', | ||
'Denver', | ||
'Houston', | ||
'Portland', | ||
'Seattle', | ||
'Dallas', | ||
'Boston', | ||
'D.C.', | ||
'Baltimore', | ||
'Atlanta', | ||
'Chicago', | ||
'St. Louis', | ||
'St Louis', | ||
'Miami', | ||
'Orlando', | ||
'Nashville', | ||
'New Orleans', | ||
]; |
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,47 @@ | ||
import {stateNames, stateAbbrevs, USCityNames} from './constants'; | ||
|
||
const jobIsRemote = job => | ||
job.location.toLowerCase().includes('remote') || | ||
job.location.toLowerCase().includes('anywhere'); | ||
const jobIsInUs = job => { | ||
return ( | ||
stateNames.some(stateName => | ||
job.location.toLowerCase().includes(stateName.toLowerCase()) | ||
) || | ||
stateAbbrevs.some(stateAbbrev => { | ||
const abbrev = new RegExp(`\\b${stateAbbrev}\\b`, 'gi'); | ||
return abbrev.test(job.location); | ||
}) || | ||
USCityNames.some(cityName => { | ||
return job.location.toLowerCase().includes(cityName.toLowerCase()); | ||
}) | ||
); | ||
}; | ||
const jobIsNotInUS = job => { | ||
return ( | ||
stateNames.every( | ||
state => !job.location.toLowerCase().includes(state.toLowerCase()) | ||
) && | ||
stateAbbrevs.every(stateAbbrev => { | ||
const abbrev = new RegExp(`\\b${stateAbbrev}\\b`, 'gi'); | ||
return !abbrev.test(job.location); | ||
}) && | ||
USCityNames.every(cityName => { | ||
return !job.location.toLowerCase().includes(cityName.toLowerCase()); | ||
}) && | ||
!jobIsRemote(job) | ||
); | ||
}; | ||
|
||
export const filterJobsByLocation = (jobs, location) => { | ||
switch (location) { | ||
case 'us': | ||
return jobs.filter(jobIsInUs); | ||
case 'international': | ||
return jobs.filter(jobIsNotInUS); | ||
case 'remote': | ||
return jobs.filter(jobIsRemote); | ||
default: | ||
return jobs; | ||
} | ||
}; |