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

Issues/KUI 1378 fetch data loader #369

Merged
merged 7 commits into from
Aug 30, 2024

Conversation

amirhossein-haerian
Copy link
Contributor

No description provided.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Looks good! But I found a bug and cleanup suggestion (remove of PlannedModules file).

Comment on lines 120 to 122
<Item title={translation.courseRoundInformation.round_time_slots}>
<PlannedModules courseCode={courseCode} courseRound={courseRound} selectedSemester={selectedSemester} />
<PlannedModules plannedModules={plannedModules} />
</Item>
Copy link

@ghost ghost Aug 29, 2024

Choose a reason for hiding this comment

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

Now when call to usePlannedModules is moved up in the tree we can remove PlannedModules.jsx completly and just use the generic html-prop to <Item> here instead, like this:

<Item title={translation.courseRoundInformation.round_target_group} html={plannedModules} />

Copy link

Choose a reason for hiding this comment

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

Remove this file. See comment on RoundInformationInfoGrid.jsx

() => ({
basePath,
courseCode,
semester,
Copy link

Choose a reason for hiding this comment

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

I found a bug, the semester prop in the params object is called selectedSemester and not semester, so semester is always undefined here.

Copy link

Choose a reason for hiding this comment

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

This still doesn't work for when I'm testing...

Copy link

Choose a reason for hiding this comment

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

Ah, it is still called semester in the planned modules api function. So it needs to be semester: selectedSemester, here.

Like this:

  const requestData = useMemo(
    () => ({
      basePath,
      courseCode,
      semester: selectedSemester,
      applicationCode,
    }),
    [basePath, courseCode, selectedSemester, applicationCode]
  )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are absolutely right, I fixed it now; thanks for mentioning this.

@@ -1,20 +1,26 @@
import { useEffect, useState } from 'react'
import { STATUS } from './api/status'

export const useApi = (apiToCall, initialApiParams, defaultValue, defaulValueIfNullResponse) => {
const [apiParams, setApiParams] = useState(initialApiParams)
export const useApi = (apiToCall, apiParams, defaultValue, defaulValueIfNullResponse) => {
Copy link

Choose a reason for hiding this comment

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

Really like your refactoring here ⭐️

@amirhossein-haerian
Copy link
Contributor Author

Thanks for your great comments, I applied the required changes based on them ⭐️

@amirhossein-haerian amirhossein-haerian merged commit ef2f3de into master Aug 30, 2024
3 checks passed
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.

1 participant