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

Refactor Select Coaching Session Component #34

Closed
wants to merge 14 commits into from
Closed

Conversation

qafui
Copy link
Collaborator

@qafui qafui commented Oct 2, 2024

Description

This PR adds the useSWR hook from the swr library as a wrapper around a global fetcher hook (useApiData). It allows any component to access the data it needs for rendering dynamic values from the API.

A dashboard component is refactored to use the new hook to fetch data for conditionally rendered select components and a button. The JoinCoachingSession component allows a user to select an organization, a coaching relationship and a session and join the session with a button click.

Todo

  • Separate previous from upcoming sessions with a SelectGroup
  • Merge and fix conflicts

Changes

  • Adds a hook for fetching data from the API
  • Adds a Dynamic select component that renders dropdowns with data fetched from the API
  • Renders 3 dynamic select components in a composite or ‘smart’ JoinCoachingSession component responsible for setting organization, relationship and session IDs in the state tree.

Screenshots / Videos Showing UI Changes (if applicable)

Screenshot 2024-10-03 at 3 12 08 PM

Testing Strategy

Login and attempt to join a session using the component illustrated in the image

Concerns

  • The rendering helper functions in the dynamic-api-select component should be separated into its own component.
  • PRs of this kind should be broken up into smaller features in future to improve code merge 😅

@jhodapp jhodapp added the enhancement Improves existing functionality or feature label Oct 2, 2024
@qafui qafui marked this pull request as ready for review October 3, 2024 19:51
@qafui qafui requested a review from jhodapp October 4, 2024 01:41
url: string,
method?: 'GET' | 'POST',
params?: Record<string, string>,
// body?: Record<string, any>
Copy link
Member

Choose a reason for hiding this comment

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

@qafui is this intentional to be commented out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. I realized that this hook is a little too generic. I suggest we split it into a few custom hooks (one for credentialed POST fetches and another for simple GET requests where we can use more Cache and revalidation config options to change the behavior of the useSWR hook. We would need that for taking notes and more live streaming behaviors.

@qafui qafui marked this pull request as draft October 11, 2024 06:15
@qafui qafui closed this Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves existing functionality or feature
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants