Skip to content

Commit 574ca75

Browse files
committed
fix: use email_id in the payload instead of emailId for User
1 parent e4475a4 commit 574ca75

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/Pages/GlobalConfigurations/Authorization/authorization.service.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ export const getUserById = async (userId: User['id']): Promise<User> => {
3636
}
3737
}
3838

39-
export const createOrUpdateUser = (data: UserCreateOrUpdatePayload) => {
40-
const isUpdate = !!data.id
39+
export const createOrUpdateUser = ({ emailId, ...data }: UserCreateOrUpdatePayload) => {
40+
const _data: UserDto = {
41+
...data,
42+
email_id: emailId,
43+
}
44+
const isUpdate = !!_data.id
4145
const options: APIOptions = {
4246
timeout: window._env_.CONFIGURABLE_TIMEOUT ? parseInt(window._env_.CONFIGURABLE_TIMEOUT, 10) : null,
4347
}
44-
return isUpdate ? put(Routes.USER, data, options) : post(Routes.USER, data, options)
48+
return isUpdate ? put(Routes.USER, _data, options) : post(Routes.USER, _data, options)
4549
}
4650

4751
export const deleteUser = (userId: User['id']) => trash(`${Routes.USER}/${userId}`)

src/Pages/GlobalConfigurations/Authorization/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export interface UserDto {
5050
/**
5151
* Email of the user
5252
*/
53-
emailId: string
53+
email_id: string
5454
/**
5555
* Status of the user
5656
*
@@ -87,14 +87,15 @@ export interface UserDto {
8787
roleGroups?: Pick<PermissionGroup, 'id' | 'name' | 'description'>
8888
}
8989

90-
export interface User extends Omit<UserDto, 'timeoutWindowExpression'> {
90+
export interface User extends Omit<UserDto, 'timeoutWindowExpression' | 'email_id'> {
9191
/**
9292
* Time until which the user is active
9393
* Note: Only a user with status 'active' can have 'timeToLive'
9494
*
9595
* @default ''
9696
*/
9797
timeToLive?: string
98+
emailId: UserDto['email_id']
9899
}
99100

100101
export type UserCreateOrUpdatePayload = Pick<

src/Pages/GlobalConfigurations/Authorization/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import { PermissionGroup, User, UserDto } from './types'
55
import { LAST_LOGIN_TIME_NULL_STATE } from './UserPermissions/constants'
66

77
export const transformUserResponse = (_user: UserDto): User => {
8-
const { lastLoginTime, timeoutWindowExpression, ...user } = _user
8+
const { lastLoginTime, timeoutWindowExpression, email_id: emailId, ...user } = _user
99

1010
return {
1111
...user,
12+
emailId,
1213
lastLoginTime:
1314
lastLoginTime === ZERO_TIME_STRING || !lastLoginTime
1415
? LAST_LOGIN_TIME_NULL_STATE

0 commit comments

Comments
 (0)