Tranforming more components to typescript (#47)

This commit is contained in:
Vladyslav Matsiiako
2022-12-04 23:03:57 -05:00
parent 90ef67399b
commit b21cb521da
12 changed files with 49 additions and 42 deletions
@@ -6,7 +6,7 @@ import SecurityClient from "~/utilities/SecurityClient";
* @param {string} obj.orgId - organization Id
* @returns
*/
const getOrganizationUsers = ({ orgId }) => {
const getOrganizationUsers = ({ orgId }: { orgId: string; }) => {
return SecurityClient.fetchCall(
"/api/v1/organization/" + orgId + "/users",
{
@@ -16,7 +16,7 @@ const getOrganizationUsers = ({ orgId }) => {
},
}
).then(async (res) => {
if (res.status == 200) {
if (res?.status == 200) {
return (await res.json()).users;
} else {
console.log("Failed to get org users");
@@ -1,11 +1,12 @@
import SecurityClient from "~/utilities/SecurityClient";
/**
* This route creates a new workspace for a user.
* @param {*} workspaceName
* This route creates a new workspace for a user within a certain organization.
* @param {string} workspaceName - project Name
* @param {string} organizationId - org ID
* @returns
*/
const createWorkspace = (workspaceName, organizationId) => {
const createWorkspace = ( { workspaceName, organizationId }: { workspaceName: string; organizationId: string; }) => {
return SecurityClient.fetchCall("/api/v1/workspace", {
method: "POST",
headers: {
@@ -16,7 +17,7 @@ const createWorkspace = (workspaceName, organizationId) => {
organizationId: organizationId,
}),
}).then(async (res) => {
if (res.status == 200) {
if (res?.status == 200) {
return (await res.json()).workspace;
} else {
console.log("Failed to create a project");
@@ -2,10 +2,10 @@ import SecurityClient from "~/utilities/SecurityClient";
/**
* Get the latest key pairs from a certain workspace
* @param {*} workspaceId
* @param {string} workspaceId
* @returns
*/
const getLatestFileKey = (workspaceId) => {
const getLatestFileKey = ({ workspaceId } : { workspaceId: string; }) => {
return SecurityClient.fetchCall(
"/api/v1/key/" + workspaceId + "/latest",
{
@@ -15,7 +15,7 @@ const getLatestFileKey = (workspaceId) => {
},
}
).then(async (res) => {
if (res.status == 200) {
if (res?.status == 200) {
return await res.json();
} else {
console.log("Failed to get the latest key pairs for a certain project");
@@ -2,13 +2,12 @@ import SecurityClient from "~/utilities/SecurityClient";
/**
* This route lets us get the public keys of everyone in your workspace.
* @param {*} req
* @param {*} res
* @param {string} workspaceId
* @returns
*/
const getWorkspaceKeys = (req, res) => {
const getWorkspaceKeys = ({ workspaceId }: { workspaceId: string; }) => {
return SecurityClient.fetchCall(
"/api/v1/workspace/" + req.workspaceId + "/keys",
"/api/v1/workspace/" + workspaceId + "/keys",
{
method: "GET",
headers: {
@@ -16,7 +15,7 @@ const getWorkspaceKeys = (req, res) => {
},
}
).then(async (res) => {
if (res.status == 200) {
if (res?.status == 200) {
return (await res.json()).publicKeys;
} else {
console.log("Failed to get the public keys of everyone in the workspace");
@@ -2,13 +2,12 @@ import SecurityClient from "~/utilities/SecurityClient";
/**
* This route lets us get all the users in the workspace.
* @param {*} req
* @param {*} res
* @param {string} workspaceId - workspace ID
* @returns
*/
const getWorkspaceUsers = (req, res) => {
const getWorkspaceUsers = ({ workspaceId }: { workspaceId: string; }) => {
return SecurityClient.fetchCall(
"/api/v1/workspace/" + req.workspaceId + "/users",
"/api/v1/workspace/" + workspaceId + "/users",
{
method: "GET",
headers: {
@@ -16,7 +15,7 @@ const getWorkspaceUsers = (req, res) => {
},
}
).then(async (res) => {
if (res.status == 200) {
if (res?.status == 200) {
return (await res.json()).users;
} else {
console.log("Failed to get Project Users");
@@ -1,19 +1,17 @@
import SecurityClient from "~/utilities/SecurityClient";
/**
* This route lets us get the public keys of everyone in your workspace.
* @param {*} req
* @param {*} res
* This route lets us get the workspaces of a certain user
* @returns
*/
const getWorkspaces = (req, res) => {
const getWorkspaces = () => {
return SecurityClient.fetchCall("/api/v1/workspace", {
method: "GET",
headers: {
"Content-Type": "application/json",
},
}).then(async (res) => {
if (res.status == 200) {
if (res?.status == 200) {
return (await res.json()).workspaces;
} else {
console.log("Failed to get projects");