Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const InstructorField = memo(() => {
textFieldProps={{
type: 'search',
value: instructor,
onChange: (event) => setInstructor(event.target.value),
onChange: (event) => setInstructor(event.target.value.replace(/[0-9]/g, '')),
placeholder: 'Last name only',
fullWidth: true,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ export const UnitsField = memo(() => {
label="Units"
textFieldProps={{
value: units,
onChange: (event) => setUnits(event.target.value),
onChange: (event) => {
const upper = event.target.value.toUpperCase();

if (upper.startsWith('VAR')) {
setUnits('VAR');
} else if ('VAR'.startsWith(upper)) {
setUnits(upper);
} else {
const cleaned = upper.replace(/[^0-9.]/g, '');
const finalValue = cleaned.replace(/(\..*?)\./g, '$1');
setUnits(finalValue);
Comment on lines +13 to +23

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intended that typing a number or dot resets the VAR progress? For example typing V, A, 1 shows V, VA, 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah theres no use case where anyone would type VAR + "some number", right? Because VAR is the abbreviation for variable unit courses, where students pick how many units their course is worth at enrollment. Theres no use case where someone would deliberately search for example VAR1 or something related because either you search a number or you search VAR on its own.

At least this was my thought process correct me if im wrong

}
},
Comment on lines +13 to +25

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to preserve decimal points here as well, there are cases where a course's units can include a decimal point

Image

type: 'search',
placeholder: 'ex. 4 or VAR',
fullWidth: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const SectionCodeField = memo(() => {
const [sectionCode, setSectionCode] = useCourseSearchParam('sectionCode');

const handleChange = (event: ChangeEvent<{ value: string }>) => {
setSectionCode(event.target.value);
setSectionCode(event.target.value.replace(/[^0-9,-]/g, ''));
};

return (
Expand Down
Loading