feat: add useCurrentUserInfo hook#1417
Conversation
services/user/src/UserProvider.tsx
Outdated
| import React, { useContext } from 'react' | ||
| import { CurrentUser } from './types' | ||
|
|
||
| const defaultUser: CurrentUser = { |
There was a problem hiding this comment.
conceptually, shouldn't the default user be undefined? or at least an empty object?
There was a problem hiding this comment.
and then I think the type for this should CurrentUser | undefined and the consumers responsible of handling it safely - let me know what you think
There was a problem hiding this comment.
That makes sense. I agree that the default should be undefined conceptually, and consumers should handle that case explicitly. I’ll change the type to CurrentUser | undefined and update the default accordingly
services/user/README.md
Outdated
| @@ -0,0 +1,11 @@ | |||
| # DHIS2 App Data Service | |||
There was a problem hiding this comment.
typo in title - "User Service" not Data
There was a problem hiding this comment.
Good catch, I will fix that.
runtime/src/Provider.tsx
Outdated
| type ProviderInput = { | ||
| config: Config | ||
| userInfo: CurrentUser | ||
| userInfo?: CurrentUser |
There was a problem hiding this comment.
small nit: I think it's more accurate to have the type as CurrentUser | undefined, right? - as in userInfo will always be there, but might be undefined?
There was a problem hiding this comment.
I agree, CurrentUser | undefined is more accurate here. I’ll update it
|
@tibendadavis could you run |
2774e0a to
42d43b3
Compare
|
@tibendadavis there is a problem with the build on master (unrelated to your PR) - I am trying to fix it befoe merging yours. I will keep you updated. |
|
@kabaros Thanks for the update, appreciate it. Let me know if you need anything from my side. |
3ffeee9 to
69f1af3
Compare
and replace CurrentUserState with CurrentUser type
…ression/description (dhis2#1420)
6e71b0c to
efd3500
Compare
…Provider component
* use content type text/plain for mutations to validationRules/expression/description ([dhis2#1420](dhis2#1420)) ([da955b3](dhis2@da955b3))
ab033c8 to
15c0b8f
Compare
|
|
@tibendadavis I had to revert the references to the new service in this commit as it was referencing a new service that wasn't published yet - now once it is merged and published on CI, can you please create another PR off master to re-add the changes there and enable the new service provider? |
|
🎉 This PR is included in version 3.14.8 🎉 The release is available on:
Your semantic-release bot 📦🚀 |



Implements LIBS-528
Key features
useCurrentUserInfohook andUserProviderto provide authenticated DHIS2 user info throughout the app.Description
This PR introduces a new hook,
useCurrentUserInfo, to provide the currently authenticated DHIS2 user's information throughout the app.It also adds a
UserProviderto fetch or use pre-provided user info, integrated with the existingConfigProviderandDataProvider.Includes tests and documentation following the existing App Runtime structure.
Checklist
CurrentUserState)Known issues
Screenshots