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

[account] [docs] Add custom user details example #4227

Merged
merged 69 commits into from
Oct 30, 2024

Conversation

bharatkashyap
Copy link
Member

@bharatkashyap bharatkashyap commented Oct 7, 2024

To Do

  • We will export a useSession() hook for user to be able to extend it
  • Add custom session account example
  • Add useSession docs pages

Screenshot 2024-10-13 at 4 32 35 PM

https://deploy-preview-4227--mui-toolpad-docs.netlify.app/toolpad/core/react-use-session/

@bharatkashyap bharatkashyap added docs Improvements or additions to the documentation enhancement This is not a bug, nor a new feature labels Oct 7, 2024
@bharatkashyap bharatkashyap changed the title Enh/account 4 [account] Add userDetailsContainer slot Oct 7, 2024
@bharatkashyap bharatkashyap changed the title [account] Add userDetailsContainer slot [account] ExportAccountUserDetails component Oct 7, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 7, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 18, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 18, 2024
@bharatkashyap bharatkashyap removed the request for review from Janpot October 18, 2024 19:47
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 18, 2024
Copy link
Member

@apedroferreira apedroferreira left a comment

Choose a reason for hiding this comment

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

Looks great, really easy to understand!
Added some small documentation suggestions.

const session = useSession();
```

If your session has additional data which you want to display in the account popover, you an create custom components for user information display with the session object:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If your session has additional data which you want to display in the account popover, you an create custom components for user information display with the session object:
If your session has additional data which you want to display in the account popover, you can create custom components for user information display with the session object:

}
```

The following example demonstrates this behaviour clearly:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The following example demonstrates this behaviour clearly:
The following example demonstrates this behavior:

"behavior" for American english as I guess that's the one we use?

The `session` can be created using any authentication provider of your choice. You can access the current value of the `SessionContext` inside Toolpad Core components by invoking the hook:

```js
const session = useSession();
Copy link
Member

Choose a reason for hiding this comment

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

Should we show where to import it from here too?

@aress31
Copy link

aress31 commented Oct 29, 2024

I believe that useSession should return both session and setSession. In many parts of an application, such as the SignInPage, a successful sign-in requires setting the session. Currently, this can only be done at the top level in the AppProvider, forcing the setter to be passed down multiple levels through the component hierarchy. Allowing this hook to both read and update the session directly would significantly expand its usability across various use cases.

@bharatkashyap
Copy link
Member Author

I believe that useSession should return both session and setSession. In many parts of an application, such as the SignInPage, a successful sign-in requires setting the session. Currently, this can only be done at the top level in the AppProvider, forcing the setter to be passed down multiple levels through the component hierarchy. Allowing this hook to both read and update the session directly would significantly expand its usability across various use cases.

I'll update the original issue you created with this and we can track this as a feature request to be discussed and potentially added (or not) to the roadmap - let me know if that's okay

@bharatkashyap bharatkashyap merged commit de4ac6c into mui:master Oct 30, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation enhancement This is not a bug, nor a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Customize user details section in <Account/>
3 participants