-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/create-lead-upload-files
- Loading branch information
Showing
13 changed files
with
130 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { ClientType } from '../../index'; | ||
import { GET_ROLES } from '../../queries'; | ||
import { | ||
AssignRoleUser, | ||
CreatedRoles, | ||
OrderBy, | ||
RemoveRoleUser, | ||
UserRoleParams, | ||
WhereCondition, | ||
} from '../../types'; | ||
import { ASSIGN_ROLE_USER, REMOVE_ROLE_USER } from '../../mutations'; | ||
|
||
export class Roles { | ||
constructor(protected client: ClientType) {} | ||
|
||
public async getRoles( | ||
options: { | ||
whereCondition?: WhereCondition; | ||
orderByCondition?: OrderBy[]; | ||
} = {} | ||
): Promise<CreatedRoles> { | ||
const { whereCondition, orderByCondition } = options; | ||
|
||
const response = await this.client.query({ | ||
query: GET_ROLES, | ||
variables: { | ||
whereCondition, | ||
orderByCondition, | ||
}, | ||
}); | ||
return response.data; | ||
} | ||
|
||
public async assignRoleUser(params: UserRoleParams): Promise<AssignRoleUser> { | ||
const response = await this.client.mutate({ | ||
mutation: ASSIGN_ROLE_USER, | ||
variables: { ...params }, | ||
}); | ||
return response.data; | ||
} | ||
|
||
public async removeRoleUser(params: UserRoleParams): Promise<RemoveRoleUser> { | ||
const response = await this.client.mutate({ | ||
mutation: REMOVE_ROLE_USER, | ||
variables: { ...params }, | ||
}); | ||
return response.data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
export const ASSIGN_ROLE_USER = gql` | ||
mutation($userId: ID!, $role: Mixed!) { | ||
assignRoleToUser(userId: $userId, role: $role) | ||
} | ||
`; | ||
|
||
export const REMOVE_ROLE_USER = gql` | ||
mutation($userId: ID!, $role: Mixed!) { | ||
removeRole(userId: $userId, role: $role) | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
export const GET_ROLES = gql` | ||
query getRoles( | ||
$whereCondition: QueryRolesWhereWhereConditions | ||
$orderByCondition: [QueryRolesOrderByOrderByClause!] | ||
) { | ||
roles(where: $whereCondition, orderBy: $orderByCondition) { | ||
data { | ||
id | ||
name | ||
title | ||
scope | ||
} | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
export enum Roles { | ||
export enum RolesEnum { | ||
OWNER = 'Owner', | ||
ADMIN = 'Admin', | ||
USER = 'Users', | ||
AGENT = 'Agents', | ||
DEVELOPER = 'Developer', | ||
MANAGER = 'Managers', | ||
} | ||
|
||
export interface RolesInterface { | ||
id: string | number; | ||
name: string; | ||
title: string; | ||
scope: string; | ||
} | ||
|
||
export interface CreatedRoles { | ||
roles: { | ||
data: RolesInterface[]; | ||
}; | ||
} | ||
|
||
export interface AssignRoleUser { | ||
assignRoleToUser: boolean; | ||
} | ||
|
||
export interface RemoveRoleUser { | ||
removeRole: boolean; | ||
} | ||
|
||
export interface UserRoleParams { | ||
userId: string | number; | ||
role: string | number; | ||
} |