@addev-be/ui 0.6.12 → 0.6.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@addev-be/ui",
3
- "version": "0.6.12",
3
+ "version": "0.6.14",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "watch": "tsc -b --watch",
@@ -1,10 +1,14 @@
1
1
  export * from './WebSocketService';
2
2
  export * from './HttpService';
3
3
  export * from './hooks';
4
+ export * from './globalSearch';
4
5
 
5
6
  export * from './requests/auth';
6
- export * from './globalSearch';
7
+ export * from './requests/users';
8
+ export * from './requests/userProfiles';
7
9
 
8
10
  export * from './types/auth';
9
11
  export * from './types/base';
10
12
  export * from './types/users';
13
+ export * from './types/userProfiles';
14
+ export * from './types/userPermissions';
@@ -0,0 +1,36 @@
1
+ import {
2
+ DeleteUserPermissionRequestDTO,
3
+ DeleteUserPermissionResponseDTO,
4
+ GetAllUserPermissionsRequestDTO,
5
+ GetAllUserPermissionsResponseDTO,
6
+ GetUserPermissionRequestDTO,
7
+ GetUserPermissionResponseDTO,
8
+ SaveUserPermissionRequestDTO,
9
+ SaveUserPermissionResponseDTO,
10
+ } from '../types/userPermissions';
11
+
12
+ import { useLoadingRequestHandler } from '../hooks';
13
+
14
+ export const useGetUserPermissionRequestHandler = () =>
15
+ useLoadingRequestHandler<
16
+ GetUserPermissionRequestDTO,
17
+ GetUserPermissionResponseDTO
18
+ >('GetUserPermission');
19
+
20
+ export const useGetAllUserPermissionsRequestHandler = () =>
21
+ useLoadingRequestHandler<
22
+ GetAllUserPermissionsRequestDTO,
23
+ GetAllUserPermissionsResponseDTO
24
+ >('GetAllUserPermissions');
25
+
26
+ export const useSaveUserPermissionRequestHandler = () =>
27
+ useLoadingRequestHandler<
28
+ SaveUserPermissionRequestDTO,
29
+ SaveUserPermissionResponseDTO
30
+ >('SaveUserPermission');
31
+
32
+ export const useDeleteUserPermissionRequestHandler = () =>
33
+ useLoadingRequestHandler<
34
+ DeleteUserPermissionRequestDTO,
35
+ DeleteUserPermissionResponseDTO
36
+ >('DeleteUserPermission');
@@ -0,0 +1,35 @@
1
+ import {
2
+ DeleteUserProfileRequestDTO,
3
+ DeleteUserProfileResponseDTO,
4
+ GetAllUserProfilesRequestDTO,
5
+ GetAllUserProfilesResponseDTO,
6
+ GetUserProfileRequestDTO,
7
+ GetUserProfileResponseDTO,
8
+ SaveUserProfileRequestDTO,
9
+ SaveUserProfileResponseDTO,
10
+ } from '../types/userProfiles';
11
+
12
+ import { useLoadingRequestHandler } from '../hooks';
13
+
14
+ export const useGetUserProfileRequestHandler = () =>
15
+ useLoadingRequestHandler<GetUserProfileRequestDTO, GetUserProfileResponseDTO>(
16
+ 'GetUserProfile'
17
+ );
18
+
19
+ export const useGetAllUserProfilesRequestHandler = () =>
20
+ useLoadingRequestHandler<
21
+ GetAllUserProfilesRequestDTO,
22
+ GetAllUserProfilesResponseDTO
23
+ >('GetAllUserProfiles');
24
+
25
+ export const useSaveUserProfileRequestHandler = () =>
26
+ useLoadingRequestHandler<
27
+ SaveUserProfileRequestDTO,
28
+ SaveUserProfileResponseDTO
29
+ >('SaveUserProfile');
30
+
31
+ export const useDeleteUserProfileRequestHandler = () =>
32
+ useLoadingRequestHandler<
33
+ DeleteUserProfileRequestDTO,
34
+ DeleteUserProfileResponseDTO
35
+ >('DeleteUserProfile');
@@ -0,0 +1,28 @@
1
+ import {
2
+ DeleteUserRequestDTO,
3
+ DeleteUserResponseDTO,
4
+ GetAllUsersRequestDTO,
5
+ GetAllUsersResponseDTO,
6
+ GetUserRequestDTO,
7
+ GetUserResponseDTO,
8
+ SaveUserRequestDTO,
9
+ SaveUserResponseDTO,
10
+ } from '../types/users';
11
+
12
+ import { useLoadingRequestHandler } from '../hooks';
13
+
14
+ export const useGetUserRequestHandler = () =>
15
+ useLoadingRequestHandler<GetUserRequestDTO, GetUserResponseDTO>('GetUser');
16
+
17
+ export const useGetAllUsersRequestHandler = () =>
18
+ useLoadingRequestHandler<GetAllUsersRequestDTO, GetAllUsersResponseDTO>(
19
+ 'GetAllUsers'
20
+ );
21
+
22
+ export const useSaveUserRequestHandler = () =>
23
+ useLoadingRequestHandler<SaveUserRequestDTO, SaveUserResponseDTO>('SaveUser');
24
+
25
+ export const useDeleteUserRequestHandler = () =>
26
+ useLoadingRequestHandler<DeleteUserRequestDTO, DeleteUserResponseDTO>(
27
+ 'DeleteUser'
28
+ );
@@ -0,0 +1,3 @@
1
+ export const userPermissions: Record<string, string> = {
2
+ 'users:manage': 'Gérer les utilisateurs',
3
+ };
@@ -0,0 +1,106 @@
1
+ import * as t from 'io-ts';
2
+
3
+ import { baseModelDtoCodec } from './base';
4
+
5
+ export const userProfileDtoCodec = t.type(
6
+ {
7
+ ...baseModelDtoCodec.props,
8
+ name: t.string,
9
+ permissions: t.array(t.string),
10
+ isAdmin: t.string,
11
+ },
12
+ 'UserProfileDTO'
13
+ );
14
+
15
+ export type UserProfileDTO = t.TypeOf<typeof userProfileDtoCodec>;
16
+
17
+ /*****/
18
+
19
+ export const getUserProfileRequestDtoCodec = t.type(
20
+ {
21
+ id: t.string,
22
+ },
23
+ 'GetUserProfileRequestDTO'
24
+ );
25
+
26
+ export const getUserProfileResponseDtoCodec = t.type(
27
+ {
28
+ data: userProfileDtoCodec,
29
+ },
30
+ 'GetUserProfileResponseDTO'
31
+ );
32
+
33
+ export type GetUserProfileRequestDTO = t.TypeOf<
34
+ typeof getUserProfileRequestDtoCodec
35
+ >;
36
+ export type GetUserProfileResponseDTO = t.TypeOf<
37
+ typeof getUserProfileResponseDtoCodec
38
+ >;
39
+
40
+ /*****/
41
+
42
+ export const getAllUserProfilesRequestDtoCodec = t.type(
43
+ {},
44
+ 'GetAllUserProfilesRequestDTO'
45
+ );
46
+
47
+ export const getAllUserProfilesResponseDtoCodec = t.type(
48
+ {
49
+ data: t.array(userProfileDtoCodec),
50
+ },
51
+ 'GetAllUserProfilesResponseDTO'
52
+ );
53
+
54
+ export type GetAllUserProfilesRequestDTO = t.TypeOf<
55
+ typeof getAllUserProfilesRequestDtoCodec
56
+ >;
57
+ export type GetAllUserProfilesResponseDTO = t.TypeOf<
58
+ typeof getAllUserProfilesResponseDtoCodec
59
+ >;
60
+
61
+ /*****/
62
+
63
+ export const saveUserProfileRequestDtoCodec = t.type(
64
+ {
65
+ id: t.string,
66
+ },
67
+ 'SaveUserProfileRequestDTO'
68
+ );
69
+
70
+ export const saveUserProfileResponseDtoCodec = t.type(
71
+ {
72
+ status: t.number,
73
+ data: userProfileDtoCodec,
74
+ },
75
+ 'SaveUserProfileResponseDTO'
76
+ );
77
+
78
+ export type SaveUserProfileRequestDTO = t.TypeOf<
79
+ typeof saveUserProfileRequestDtoCodec
80
+ >;
81
+ export type SaveUserProfileResponseDTO = t.TypeOf<
82
+ typeof saveUserProfileResponseDtoCodec
83
+ >;
84
+
85
+ /*****/
86
+
87
+ export const deleteUserProfileRequestDtoCodec = t.type(
88
+ {
89
+ id: t.string,
90
+ },
91
+ 'DeleteUserProfileRequestDTO'
92
+ );
93
+
94
+ export const deleteUserProfileResponseDtoCodec = t.type(
95
+ {
96
+ status: t.number,
97
+ },
98
+ 'DeleteUserProfileResponseDTO'
99
+ );
100
+
101
+ export type DeleteUserProfileRequestDTO = t.TypeOf<
102
+ typeof deleteUserProfileRequestDtoCodec
103
+ >;
104
+ export type DeleteUserProfileResponseDTO = t.TypeOf<
105
+ typeof deleteUserProfileResponseDtoCodec
106
+ >;
@@ -7,6 +7,8 @@ export const userDtoCodec = t.intersection(
7
7
  t.type({
8
8
  ...baseModelDtoCodec.props,
9
9
  username: t.string,
10
+ permissions: t.array(t.string),
11
+ isAdmin: t.boolean,
10
12
  }),
11
13
  t.partial({
12
14
  name: t.string,
@@ -18,3 +20,77 @@ export const userDtoCodec = t.intersection(
18
20
  );
19
21
 
20
22
  export type UserDTO = t.TypeOf<typeof userDtoCodec>;
23
+
24
+ /*****/
25
+
26
+ export const getUserRequestDtoCodec = t.type(
27
+ {
28
+ id: t.string,
29
+ },
30
+ 'GetUserRequestDTO'
31
+ );
32
+
33
+ export const getUserResponseDtoCodec = t.type(
34
+ {
35
+ data: userDtoCodec,
36
+ },
37
+ 'GetUserResponseDTO'
38
+ );
39
+
40
+ export type GetUserRequestDTO = t.TypeOf<typeof getUserRequestDtoCodec>;
41
+ export type GetUserResponseDTO = t.TypeOf<typeof getUserResponseDtoCodec>;
42
+
43
+ /*****/
44
+
45
+ export const getAllUsersRequestDtoCodec = t.type({}, 'GetAllUsersRequestDTO');
46
+
47
+ export const getAllUsersResponseDtoCodec = t.type(
48
+ {
49
+ data: t.array(userDtoCodec),
50
+ },
51
+ 'GetAllUsersResponseDTO'
52
+ );
53
+
54
+ export type GetAllUsersRequestDTO = t.TypeOf<typeof getAllUsersRequestDtoCodec>;
55
+ export type GetAllUsersResponseDTO = t.TypeOf<
56
+ typeof getAllUsersResponseDtoCodec
57
+ >;
58
+
59
+ /*****/
60
+
61
+ export const saveUserRequestDtoCodec = t.type(
62
+ {
63
+ id: t.string,
64
+ },
65
+ 'SaveUserRequestDTO'
66
+ );
67
+
68
+ export const saveUserResponseDtoCodec = t.type(
69
+ {
70
+ status: t.number,
71
+ data: userDtoCodec,
72
+ },
73
+ 'SaveUserResponseDTO'
74
+ );
75
+
76
+ export type SaveUserRequestDTO = t.TypeOf<typeof saveUserRequestDtoCodec>;
77
+ export type SaveUserResponseDTO = t.TypeOf<typeof saveUserResponseDtoCodec>;
78
+
79
+ /*****/
80
+
81
+ export const deleteUserRequestDtoCodec = t.type(
82
+ {
83
+ id: t.string,
84
+ },
85
+ 'DeleteUserRequestDTO'
86
+ );
87
+
88
+ export const deleteUserResponseDtoCodec = t.type(
89
+ {
90
+ status: t.number,
91
+ },
92
+ 'DeleteUserResponseDTO'
93
+ );
94
+
95
+ export type DeleteUserRequestDTO = t.TypeOf<typeof deleteUserRequestDtoCodec>;
96
+ export type DeleteUserResponseDTO = t.TypeOf<typeof deleteUserResponseDtoCodec>;