diff --git a/frontend/src/pages/DegreeWizard/DegreeStep/DegreeStep.tsx b/frontend/src/pages/DegreeWizard/DegreeStep/DegreeStep.tsx index d7c4e731f..a0b283deb 100644 --- a/frontend/src/pages/DegreeWizard/DegreeStep/DegreeStep.tsx +++ b/frontend/src/pages/DegreeWizard/DegreeStep/DegreeStep.tsx @@ -23,9 +23,10 @@ const DegreeStep = ({ incrementStep, setDegreeInfo }: Props) => { queryKey: ['programs'], queryFn: fetchAllDegrees, select: (data) => - Object.keys(data.programs).map((code) => { - return { label: `${code} ${data.programs[code]}`, value: `${code} ${data.programs[code]}` }; - }) + Object.keys(data.programs).map((code) => ({ + label: `${code} ${data.programs[code]}`, + value: `${code} ${data.programs[code]}` + })) }); const allDegrees = allDegreesQuery.data ?? []; @@ -50,15 +51,15 @@ const DegreeStep = ({ incrementStep, setDegreeInfo }: Props) => { return; } - let fuzzedDegrees = allDegrees.map((item) => { - return { - score: fuzzy(newInput, item.label), - ...item - }; - }); - // score is a number between 0 and 1 where 1 is a perfect match - fuzzedDegrees = fuzzedDegrees.filter((pair) => pair.score > 0.5); + const fuzzedDegrees = allDegrees + .map((item) => { + return { + score: fuzzy(newInput, item.label), + ...item + }; + }) + .filter((pair) => pair.score > 0.5); // Shorter name with greater or equal score means better match fuzzedDegrees.sort((a, b) => { diff --git a/frontend/src/pages/DegreeWizard/SpecialisationStep/SpecialisationStep.tsx b/frontend/src/pages/DegreeWizard/SpecialisationStep/SpecialisationStep.tsx index c67c8d535..d4d8117de 100644 --- a/frontend/src/pages/DegreeWizard/SpecialisationStep/SpecialisationStep.tsx +++ b/frontend/src/pages/DegreeWizard/SpecialisationStep/SpecialisationStep.tsx @@ -53,26 +53,26 @@ const SpecialisationStep = ({ }); const options = specsQuery.data; - const selectGroups: - | { - label: string; - note: string | undefined; - children: { label: string; value: string }[]; - }[] - | undefined = options - ? Object.keys(options).map((program) => { - const group = { - label: `${type.replace(/^\w/, (c) => c.toUpperCase())} for ${program}`, - note: options[program].notes, - children: Object.keys(options[program].specs) - .sort() - .map((spec) => ({ - label: `${spec} ${options[program].specs[spec]}`, - value: spec - })) - }; - return group; - }) + type SelectGroup = { + label: string; + note: string | undefined; + children: { + label: string; + value: string; + }[]; + }; + + const selectGroups: SelectGroup[] | undefined = options + ? Object.keys(options).map((program) => ({ + label: `${type.replace(/^\w/, (c) => c.toUpperCase())} for ${program}`, + note: options[program].notes, + children: Object.keys(options[program].specs) + .sort() + .map((spec) => ({ + label: `${spec} ${options[program].specs[spec]}`, + value: spec + })) + })) : undefined; // check if step is optional and can be skipped @@ -132,9 +132,6 @@ const SpecialisationStep = ({ allowClear placeholder={`Select ${type.substring(0, type.length - 1)}s`} defaultValue={[]} - // value={degreeInfo.specs.filter((spec) => - // group.children.some((child) => child.value === spec) - // )} options={group.children} onSelect={(value) => handleAddSpecialisation(value)} onDeselect={(value) => handleRemoveSpecialisation(value)}