Skip to content

Commit

Permalink
Fixing school dropdown (#498)
Browse files Browse the repository at this point in the history
* Fixing school dropdown

* Run Prettier

* Forgot to remove package

---------

Co-authored-by: kyleburgess2025 <[email protected]>
  • Loading branch information
kyleburgess2025 and kyleburgess2025 authored Aug 17, 2024
1 parent c07d92e commit 7baaacc
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions components/hacker/HackerDash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,19 @@ export default function HackerDash({ userApplicationStatus, setUserApplicationSt
);

// get school options
const [schoolOptions, setSchoolOptions] = useState([]);
const [schoolOptions, setSchoolOptions] = useState<DropdownItem[]>([]);
const [school, setSchool] = useState('');
const { data: schools } = useSWR(
'http://universities.hipolabs.com/search',
'https://raw.githubusercontent.com/MLH/mlh-policies/main/schools.csv',
async url => {
const res = await fetch(url, { method: 'GET' });
const jsonRes = await res.json();
const schoolList = jsonRes.map((school: any) => {
return { label: school.name, value: school.name };
const csvText = await res.text();
const schoolArr = csvText.split('\n').slice(1);

const schoolList = schoolArr.map((school: string) => {
return { label: school, value: school };
});

setSchoolOptions(schoolList);
return schoolList;
},
Expand Down Expand Up @@ -290,9 +293,9 @@ export default function HackerDash({ userApplicationStatus, setUserApplicationSt
options={schoolOptions}
onSearch={text => {
setSchoolOptions(
schools.filter((school: DropdownItem) =>
schools?.filter((school: DropdownItem) =>
school.label.toLowerCase().includes(text.toLowerCase())
)
) || []
);
}}
value={school}
Expand Down

0 comments on commit 7baaacc

Please sign in to comment.