@open-kingdom/shared-frontend-feature-user-management 0.0.2-14 → 0.0.2-16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +293 -167
- package/dist/lib/components/invitations/InvitationList.component.d.ts +2 -0
- package/dist/lib/components/invitations/InvitationList.component.d.ts.map +1 -0
- package/dist/lib/components/invitations/index.d.ts +1 -0
- package/dist/lib/components/invitations/index.d.ts.map +1 -1
- package/dist/lib/components/shared/StatusBadge.component.d.ts +7 -0
- package/dist/lib/components/shared/StatusBadge.component.d.ts.map +1 -0
- package/dist/lib/components/users/UserList.component.d.ts.map +1 -1
- package/dist/lib/styles.d.ts +1 -0
- package/dist/lib/styles.d.ts.map +1 -1
- package/dist/lib/types.d.ts +10 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +6 -1
- package/.babelrc +0 -12
- package/jest.config.cts +0 -14
- package/src/index.ts +0 -4
- package/src/lib/components/invitations/AcceptInvitation.component.spec.tsx +0 -154
- package/src/lib/components/invitations/AcceptInvitation.component.tsx +0 -197
- package/src/lib/components/invitations/InviteUserModal.component.spec.tsx +0 -79
- package/src/lib/components/invitations/InviteUserModal.component.tsx +0 -121
- package/src/lib/components/invitations/index.ts +0 -2
- package/src/lib/components/shared/ConfirmDialog.component.spec.tsx +0 -45
- package/src/lib/components/shared/ConfirmDialog.component.tsx +0 -58
- package/src/lib/components/shared/FormField.component.spec.tsx +0 -50
- package/src/lib/components/shared/FormField.component.tsx +0 -34
- package/src/lib/components/shared/ModalOverlay.component.spec.tsx +0 -81
- package/src/lib/components/shared/ModalOverlay.component.tsx +0 -45
- package/src/lib/components/shared/RoleBadge.component.spec.tsx +0 -20
- package/src/lib/components/shared/RoleBadge.component.tsx +0 -25
- package/src/lib/components/shared/StatusCard.component.spec.tsx +0 -44
- package/src/lib/components/shared/StatusCard.component.tsx +0 -47
- package/src/lib/components/users/UserList.component.spec.tsx +0 -216
- package/src/lib/components/users/UserList.component.tsx +0 -153
- package/src/lib/styles.ts +0 -19
- package/src/lib/types.ts +0 -9
- package/tsconfig.json +0 -13
- package/tsconfig.lib.json +0 -47
- package/tsconfig.spec.json +0 -27
- package/vite.config.mts +0 -58
package/README.md
CHANGED
|
@@ -1,7 +1,139 @@
|
|
|
1
|
-
# @open-kingdom/feature-user-management
|
|
1
|
+
# @open-kingdom/shared-frontend-feature-user-management
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React UI feature library for user and invitation management, providing admin-facing pages and components for viewing users in a data grid, inviting new users, managing the invitation list, cancelling invitations, accepting invitations, and role display.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Exports
|
|
8
|
+
|
|
9
|
+
| Export | Type | Description |
|
|
10
|
+
| ------------------ | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
11
|
+
| `UserList` | `React.FC<UserListProps>` | Admin user table with invite and delete actions, rendered in a `DataGrid` |
|
|
12
|
+
| `AcceptInvitation` | `React.FC` | Page component for accepting an invitation via token (used at public invitation URL) |
|
|
13
|
+
| `InvitationList` | `React.FC` | Admin list of pending/expired invitations with cancel action |
|
|
14
|
+
| `StatusCard` | `React.FC<StatusCardProps>` | Shared status display card (success/error states) |
|
|
15
|
+
| `User` | `interface` | `{ id: number; email: string; firstName: string \| null; lastName: string \| null; role: Role }` |
|
|
16
|
+
| `Role` | `type` | `'guest' \| 'user' \| 'admin'` |
|
|
17
|
+
| `Invitation` | `interface` | `{ id: number; email: string; tokenExpiry: number; invitedBy: number; invitedAt: number; role: Role; status: InvitationStatus }` |
|
|
18
|
+
| `InvitationStatus` | `type` | `'pending' \| 'accepted' \| 'expired'` |
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Type Definitions
|
|
23
|
+
|
|
24
|
+
### `User`
|
|
25
|
+
|
|
26
|
+
| Property | Type | Required | Description |
|
|
27
|
+
| ----------- | ---------------- | -------- | --------------------------------------- |
|
|
28
|
+
| `id` | `number` | Yes | Unique user identifier |
|
|
29
|
+
| `email` | `string` | Yes | User's email address |
|
|
30
|
+
| `firstName` | `string \| null` | Yes | User's first name, or `null` if not set |
|
|
31
|
+
| `lastName` | `string \| null` | Yes | User's last name, or `null` if not set |
|
|
32
|
+
| `role` | `Role` | Yes | The user's assigned role |
|
|
33
|
+
|
|
34
|
+
`Role` is one of `'guest'`, `'user'`, or `'admin'`.
|
|
35
|
+
|
|
36
|
+
### `Invitation`
|
|
37
|
+
|
|
38
|
+
| Property | Type | Required | Description |
|
|
39
|
+
| ------------- | ------------------ | -------- | ------------------------------------------------------------ |
|
|
40
|
+
| `id` | `number` | Yes | Unique invitation identifier |
|
|
41
|
+
| `email` | `string` | Yes | Email address the invitation was sent to |
|
|
42
|
+
| `tokenExpiry` | `number` | Yes | Unix millisecond timestamp when the invitation token expires |
|
|
43
|
+
| `invitedBy` | `number` | Yes | `User.id` of the admin who sent the invitation |
|
|
44
|
+
| `invitedAt` | `number` | Yes | Unix millisecond timestamp when the invitation was created |
|
|
45
|
+
| `role` | `Role` | Yes | Role that will be assigned upon acceptance |
|
|
46
|
+
| `status` | `InvitationStatus` | Yes | Current state of the invitation |
|
|
47
|
+
|
|
48
|
+
`InvitationStatus` is one of `'pending'`, `'accepted'`, or `'expired'`.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Component Props
|
|
53
|
+
|
|
54
|
+
### `UserList`
|
|
55
|
+
|
|
56
|
+
| Property | Type | Required | Default | Description |
|
|
57
|
+
| --------------- | -------- | -------- | ------- | --------------------------------------------------------- |
|
|
58
|
+
| `currentUserId` | `number` | No | — | Prevents the current user from deleting their own account |
|
|
59
|
+
|
|
60
|
+
`UserList` fetches users via the `useUsersControllerFindAllQuery()` hook and deletes them via `useUsersControllerDeleteMutation()` (both RTK Query hooks auto-generated from OpenAPI). It dispatches `showSuccessNotification` after a successful delete. Users are rendered in a `DataGrid` with columns for Email, Name (computed from first and last name), Role (displayed as a badge), and Actions (a delete button). An "Invite User" button opens an `InviteUserModal`, and a `ConfirmDialog` is shown before each delete.
|
|
61
|
+
|
|
62
|
+
### `StatusCard`
|
|
63
|
+
|
|
64
|
+
Used internally by `AcceptInvitation` to render success or error outcomes.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Setup
|
|
69
|
+
|
|
70
|
+
All required Redux slices and RTK Query middleware must be registered in the store:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { configureStore } from '@reduxjs/toolkit';
|
|
74
|
+
import { ApiKey, apiReducer, apiMiddleware, AuthKey, authReducer } from '@open-kingdom/shared-frontend-data-access-api-client';
|
|
75
|
+
import { NotificationKey, notificationReducer } from '@open-kingdom/shared-frontend-data-access-notifications';
|
|
76
|
+
|
|
77
|
+
export const store = configureStore({
|
|
78
|
+
reducer: {
|
|
79
|
+
[ApiKey]: apiReducer,
|
|
80
|
+
[AuthKey]: authReducer,
|
|
81
|
+
[NotificationKey]: notificationReducer,
|
|
82
|
+
},
|
|
83
|
+
middleware: (getDefault) => getDefault().concat(apiMiddleware),
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Usage Examples
|
|
90
|
+
|
|
91
|
+
### Admin user management page
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { UserList } from '@open-kingdom/shared-frontend-feature-user-management';
|
|
95
|
+
import { useSelector } from 'react-redux';
|
|
96
|
+
import { selectUser } from '@open-kingdom/shared-frontend-data-access-api-client';
|
|
97
|
+
|
|
98
|
+
function AdminUsersPage() {
|
|
99
|
+
const currentUser = useSelector(selectToken); // or read from your auth state
|
|
100
|
+
return (
|
|
101
|
+
<div className="p-6">
|
|
102
|
+
<UserList currentUserId={currentUser?.id} />
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Invitation list page
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import { InvitationList } from '@open-kingdom/shared-frontend-feature-user-management';
|
|
112
|
+
|
|
113
|
+
function AdminInvitationsPage() {
|
|
114
|
+
return (
|
|
115
|
+
<div className="p-6">
|
|
116
|
+
<InvitationList />
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Accept invitation page (public route)
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import { AcceptInvitation } from '@open-kingdom/shared-frontend-feature-user-management';
|
|
126
|
+
|
|
127
|
+
// Mount at the invitation acceptance URL, e.g. /invitations/accept?token=<jwt>
|
|
128
|
+
function AcceptInvitationPage() {
|
|
129
|
+
return <AcceptInvitation />;
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Testing
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
nx test shared-frontend-feature-user-management
|
|
139
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { UserList } from './lib/components/users/UserList.component';
|
|
2
2
|
export { AcceptInvitation } from './lib/components/invitations';
|
|
3
|
+
export { InvitationList } from './lib/components/invitations';
|
|
3
4
|
export { StatusCard } from './lib/components/shared/StatusCard.component';
|
|
4
|
-
export type { User, Role } from './lib/types';
|
|
5
|
+
export type { User, Role, Invitation, InvitationStatus } from './lib/types';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2CAA2C,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC1E,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2CAA2C,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC1E,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|