Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor refactors #26

Merged
merged 13 commits into from
Sep 20, 2023
Merged

Some minor refactors #26

merged 13 commits into from
Sep 20, 2023

Conversation

hieunguyent12
Copy link
Contributor

I added a button to fetch courses on click, instead of having it fetch every time the user types something and also refactored how the courses are display

@RobertConde RobertConde self-requested a review September 11, 2023 01:59
{schedulesToShow.map((schedule: Schedule, i: number) => (
<div>
{schedulesToShow.map((schedule: Schedule, i) => (
<div key={i}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's OK to use index as a key here because schedulesToShow never changes (we are not deleting or inserting anything in the array).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup.

Nit: use s for index

{LIMITS.map(([num, str]) => (
<option value={num}>Generate ≤{str}</option>
{LIMITS.map(([num, str], idx) => (
<option value={num} key={idx}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same reason as above.

Good work finding these missing keys via the console.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's OK here because LIMITS is a constant so we don't have to worry about the content of the array being changed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Immutable so yup.

Nit: Use the value (num) for the key.

@RobertConde RobertConde self-requested a review September 11, 2023 02:42
Copy link
Collaborator

@RobertConde RobertConde left a comment

Choose a reason for hiding this comment

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

Really great work!
Make changes based on comments. Argue your position if you disagree.
I added a feature request in SectionPicker. You could add that to an issue (let me know if you can't create the issue) and assign yourself (make sure to label as "Enhancement").

I know there's a lot of comments and request for change this is fine work. I look forward to a revision.

Also, make sure to squash relevant commits together.

@RobertConde RobertConde self-assigned this Sep 11, 2023
app/src/components/SectionDisplay.tsx Show resolved Hide resolved
{schedulesToShow.map((schedule: Schedule, i: number) => (
<div>
{schedulesToShow.map((schedule: Schedule, i) => (
<div key={i}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup.

Nit: use s for index

{LIMITS.map(([num, str]) => (
<option value={num}>Generate ≤{str}</option>
{LIMITS.map(([num, str], idx) => (
<option value={num} key={idx}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Immutable so yup.

Nit: Use the value (num) for the key.

app/src/components/SectionPicker.tsx Outdated Show resolved Hide resolved
},
enabled: !!props.searchText, // Prevents query when searchText is empty
enabled: false,
// enabled: !!props.searchText, // Prevents query when searchText is empty
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove commented code

// isFetching
// ? props.soc instanceof SOC_API
// ? props.soc.searchCourses(searchBy, props.searchText)
// : []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove commented code

const { term, year } = SOC_Generic.decodeTermString(
t.CODE,
);
return (
<option value={t.CODE}>
<option value={t.CODE} key={idx}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use CODE

@hieunguyent12
Copy link
Contributor Author

I changed SectionDisplay to a functional component because using class component caused issues with the key prop not being unique for some reason. Functionality should remains the same.

Copy link
Collaborator

@RobertConde RobertConde left a comment

Choose a reason for hiding this comment

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

🥳

@RobertConde RobertConde merged commit 52f4a8b into ufosc:main Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants