Skip to content

Commit

Permalink
Merge pull request #1023 from AI4Bharat/develop
Browse files Browse the repository at this point in the history
Shoonya Patch Update
  • Loading branch information
ishvindersethi22 authored May 6, 2024
2 parents be97be6 + 7707057 commit 27a5a36
Show file tree
Hide file tree
Showing 12 changed files with 527 additions and 60 deletions.
1 change: 1 addition & 0 deletions src/config/apiendpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const apiendpoint = {
fetch:"/users/account/",
getTasks:"/task/",
getOrganizations:"/organizations/",
getPendingUsers:"/users/invite/",
notification:"/notifications/",
getLanguages:"/users/languages/",
getDatasets:"/data/",
Expand Down
43 changes: 43 additions & 0 deletions src/redux/actions/api/Organization/ApproveManagerSuggestions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* ApproveManagerSuggestions API
*/
import API from "../../../api";
import ENDPOINTS from "../../../../config/apiendpoint";
import constants from "../../../constants";

export default class ApproveManagerSuggestionsAPI extends API {
constructor(userId, timeout = 2000) {
super("POST", timeout, false);
this.type = constants.APPROVE_MANAGER_SUGGESTIONS;
this.userId = userId;
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getPendingUsers}approve_user/?userId=${this.userId}`;
}

processResponse(res) {
super.processResponse(res);
if (res) {
this.approveManagerSuggestions = res;
}
}

apiEndPoint() {
return this.endpoint;
}

getBody() {}

getHeaders() {
this.headers = {
headers: {
"Content-Type": "application/json",
"Authorization":`JWT ${localStorage.getItem('shoonya_access_token')}`
},
};
return this.headers;
}

getPayload() {
return this.approveManagerSuggestions;
}
}

43 changes: 43 additions & 0 deletions src/redux/actions/api/Organization/GetManagerSuggestions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* GetManagerSuggestion API
*/
import API from "../../../api";
import ENDPOINTS from "../../../../config/apiendpoint";
import constants from "../../../constants";

export default class GetManagerSuggestionsAPI extends API {
constructor(orgId, timeout = 2000) {
super("GET", timeout, false);
this.type = constants.GET_MANAGER_SUGGESTIONS;
this.orgId = orgId;
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getPendingUsers}pending_users/?organisation_id=${this.orgId}`;
}

processResponse(res) {
super.processResponse(res);
if (res) {
this.managerSuggestions = res;
}
}

apiEndPoint() {
return this.endpoint;
}

getBody() {}

getHeaders() {
this.headers = {
headers: {
"Content-Type": "application/json",
"Authorization":`JWT ${localStorage.getItem('shoonya_access_token')}`
},
};
return this.headers;
}

getPayload() {
return this.managerSuggestions;
}
}

51 changes: 51 additions & 0 deletions src/redux/actions/api/Organization/InviteManagerSuggestions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* RequestUsersToOrg API
*/
import API from "../../../api";
import ENDPOINTS from "../../../../config/apiendpoint";
import constants from "../../../constants";

export default class InviteManagerSuggestions extends API {
constructor(orgId, emails, role, timeout = 2000) {
super("POST", timeout, false);
this.type = constants.REQUEST_MANAGER_SUGGESTIONS;
this.organization_id = orgId;
this.emails = emails;
this.role = role;
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getPendingUsers}request_user/`;
}

processResponse(res) {
super.processResponse(res);
if (res) {
this.InviteManagerSuggestions = res;
}
}

apiEndPoint() {
return this.endpoint;
}

getBody() {
return {
organization_id: this.organization_id,
emails : this.emails,
role : this.role
}
}

getHeaders() {
this.headers = {
headers: {
"Content-Type": "application/json",
"Authorization":`JWT ${localStorage.getItem('shoonya_access_token')}`
},
};
return this.headers;
}

getPayload() {
return this.InviteManagerSuggestions;
}
}

43 changes: 43 additions & 0 deletions src/redux/actions/api/Organization/RejectManagerSuggestions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* RejectManagerSuggestions API
*/
import API from "../../../api";
import ENDPOINTS from "../../../../config/apiendpoint";
import constants from "../../../constants";

export default class RejectManagerSuggestionsAPI extends API {
constructor(userId, timeout = 2000) {
super("DELETE", timeout, false);
this.type = constants.DELETE_MANAGER_SUGGESTIONS;
this.userId = userId;
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getPendingUsers}reject_user/?userId=${this.userId}`;
}

processResponse(res) {
super.processResponse(res);
if (res) {
this.rejecManagerSuggestion = res;
}
}

apiEndPoint() {
return this.endpoint;
}

getBody() {}

getHeaders() {
this.headers = {
headers: {
"Content-Type": "application/json",
"Authorization":`JWT ${localStorage.getItem('shoonya_access_token')}`
},
};
return this.headers;
}

getPayload() {
return this.rejecManagerSuggestion;
}
}

4 changes: 4 additions & 0 deletions src/redux/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const constants = {
GET_TASK_PREDICTION:"GET_TASK_PREDICTION",
GET_LANGUAGES:"GET_LANGUAGES",
GET_ORGANIZATION_USERS:"GET_ORGANIZATION_USERS",
GET_MANAGER_SUGGESTIONS:"GET_MANAGER_SUGGESTIONS",
DELETE_MANAGER_SUGGESTIONS:"DEL_MANAGER_SUGGESTIONS",
APPROVE_MANAGER_SUGGESTIONS:"APPROVE_MANAGER_SUGGESTIONS",
REQUEST_MANAGER_SUGGESTIONS:"REQUEST_MANAGER_SUGGESTIONS",
GET_DATASET_LIST:"GET_DATASET_LIST",
GET_TASK_DETAILS:"GET_TASK_DETAILS",
GET_QUEUED_TASK_DETAILS:"GET_QUEUED_TASK_DETAILS",
Expand Down
21 changes: 21 additions & 0 deletions src/redux/reducers/Organization/GetManagerSuggestions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import constants from "../../constants";

let initialState = {
data: []
}
const reducer = (state = initialState, action) => {
switch (action.type) {
case constants.GET_MANAGER_SUGGESTIONS:
return {
...state,
data: action.payload
}

default:
return {
...state
}
}
};

export default reducer;
3 changes: 2 additions & 1 deletion src/redux/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import getWorkspaceDetails from './WorkspaceDetails/GetWorkspaceDetails'
import getTaskPrediction from './Tasks/GetTaskPrediction';
import fetchLanguages from './UserManagement/FetchLanguages';
import getOrganizationUsers from './Organization/GetOragnizationUsers';
import getManagerSuggestions from './Organization/GetManagerSuggestions';
import getDatasetList from './Dataset/GetDatasetList';
import getTaskDetails from './Tasks/GetTaskDetails'
import getQueuedTaskDetails from './Tasks/GetQueuedTaskDetails'
Expand Down Expand Up @@ -202,7 +203,7 @@ const index = {
getAnnotationsTask,
patchAnnotation,
updateUIPrefs,

getManagerSuggestions,
};

export default index;
Loading

0 comments on commit 27a5a36

Please sign in to comment.