generated from CS3219-AY2324S1/course-assessment-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/CS3219-AY2324S1/ay2324s1-…
…course-assessment-g17 into edit-user-profile * 'master' of https://github.com/CS3219-AY2324S1/ay2324s1-course-assessment-g17: fix: fix edit question again fix: handle initial data in multiselect refactor: change category multiselect to react-select refactor: convert complexity dropdown to chakra-react-select fix: complexity intersection fix: change timeout to 30s feat: add matching logic refactor: remove user context
- Loading branch information
Showing
14 changed files
with
288 additions
and
107 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
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 @@ | ||
export const store: { [key: string]: NodeJS.Timeout } = {}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,39 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { type OptionBase, Select } from 'chakra-react-select'; | ||
|
||
interface MultiSelectProps<T> { | ||
options: Array<Option<T>>; | ||
onChange: (selected: T[]) => void; | ||
initialOptions?: Array<Option<T>>; | ||
} | ||
|
||
interface Option<T> extends OptionBase { | ||
label: string; | ||
value: T; | ||
} | ||
|
||
const MultiSelect = <T,>({ options, onChange, initialOptions }: MultiSelectProps<T>): JSX.Element => { | ||
const [selectedOptions, setSelectedOptions] = useState<ReadonlyArray<Option<T>>>([]); | ||
const handleChange = (selectedOptions: ReadonlyArray<Option<T>>): void => { | ||
onChange(selectedOptions.map((option) => option.value)); | ||
setSelectedOptions(selectedOptions); | ||
}; | ||
|
||
useEffect(() => { | ||
if (initialOptions !== undefined) setSelectedOptions(initialOptions); | ||
}, [initialOptions]); | ||
|
||
return ( | ||
<Select | ||
isMulti | ||
name="complexities" | ||
options={options} | ||
placeholder="Select difficulty..." | ||
closeMenuOnSelect={false} | ||
value={selectedOptions} | ||
onChange={handleChange} | ||
/> | ||
); | ||
}; | ||
|
||
export default MultiSelect; |
Oops, something went wrong.