Skip to content

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

Merged
bharatkashyap merged 69 commits intomui:masterfrom
bharatkashyap:enh/account-4
Oct 30, 2024
Merged

[account] [docs] Add custom user details example#4227
bharatkashyap merged 69 commits intomui:masterfrom
bharatkashyap:enh/account-4

Conversation

@bharatkashyap
Copy link
Collaborator

@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. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or 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
@bharatkashyap bharatkashyap requested a review from Janpot October 18, 2024 18:04
@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
Collaborator

@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
Collaborator

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
Collaborator

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
Collaborator

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
Collaborator 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
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. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Customize user details section in <Account/>

3 participants