chore(frontend): fixed all eslint errors

This commit is contained in:
akhilmhdh
2023-01-17 21:06:14 +05:30
parent 9f82e2d836
commit cf7834bfc3
184 changed files with 6255 additions and 6117 deletions
@@ -1,4 +1,4 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* This function adds a user to a project
@@ -6,25 +6,21 @@ import SecurityClient from '~/utilities/SecurityClient';
* @param {*} workspaceId
* @returns
*/
const addUserToWorkspace = (email: string, workspaceId: string) => {
return SecurityClient.fetchCall(
'/api/v1/workspace/' + workspaceId + '/invite-signup',
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: email
})
}
).then(async (res) => {
if (res && res.status == 200) {
return await res.json();
} else {
console.log('Failed to add a user to project');
const addUserToWorkspace = (email: string, workspaceId: string) =>
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceId}/invite-signup`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email
})
}).then(async (res) => {
if (res && res.status === 200) {
return res.json();
}
console.log('Failed to add a user to project');
return undefined;
});
};
export default addUserToWorkspace;
@@ -1,4 +1,4 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* This function change the access of a user in a certain workspace
@@ -6,25 +6,21 @@ import SecurityClient from '~/utilities/SecurityClient';
* @param {*} role
* @returns
*/
const changeUserRoleInWorkspace = (membershipId: string, role: string) => {
return SecurityClient.fetchCall(
'/api/v1/membership/' + membershipId + '/change-role',
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
role: role
})
}
).then(async (res) => {
if (res && res.status == 200) {
const changeUserRoleInWorkspace = (membershipId: string, role: string) =>
SecurityClient.fetchCall(`/api/v1/membership/${membershipId}/change-role`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
role
})
}).then(async (res) => {
if (res && res.status === 200) {
return res;
} else {
console.log('Failed to change the user role in a project');
}
console.log('Failed to change the user role in a project');
return undefined;
});
};
export default changeUserRoleInWorkspace;
@@ -1,4 +1,4 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* This route creates a new workspace for a user within a certain organization.
@@ -12,23 +12,22 @@ const createWorkspace = ({
}: {
workspaceName: string;
organizationId: string;
}) => {
return SecurityClient.fetchCall('/api/v1/workspace', {
}) =>
SecurityClient.fetchCall('/api/v1/workspace', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
workspaceName: workspaceName,
organizationId: organizationId
workspaceName,
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');
}
console.log('Failed to create a project');
return undefined;
});
};
export default createWorkspace;
@@ -1,23 +1,22 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* This function removes a certain member from a certain workspace
* @param {*} membershipId
* @returns
*/
const deleteUserFromWorkspace = (membershipId: string) => {
return SecurityClient.fetchCall('/api/v1/membership/' + membershipId, {
const deleteUserFromWorkspace = (membershipId: string) =>
SecurityClient.fetchCall(`/api/v1/membership/${membershipId}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
}
}).then(async (res) => {
if (res && res.status == 200) {
if (res && res.status === 200) {
return res;
} else {
console.log('Failed to delete a user from a project');
}
console.log('Failed to delete a user from a project');
return undefined;
});
};
export default deleteUserFromWorkspace;
@@ -1,23 +1,22 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* This route deletes a specified workspace.
* @param {*} workspaceId
* @returns
*/
const deleteWorkspace = (workspaceId: string) => {
return SecurityClient.fetchCall('/api/v1/workspace/' + workspaceId, {
const deleteWorkspace = (workspaceId: string) =>
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceId}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
}
}).then(async (res) => {
if (res && res.status == 200) {
if (res && res.status === 200) {
return res;
} else {
console.log('Failed to delete a project');
}
console.log('Failed to delete a project');
return undefined;
});
};
export default deleteWorkspace;
@@ -1,4 +1,4 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
interface Workspace {
__v: number;
@@ -12,20 +12,19 @@ interface Workspace {
* This route lets us get the workspaces of a certain user
* @returns
*/
const getAWorkspace = (workspaceID:string) => {
return SecurityClient.fetchCall(`/api/v1/workspace/${workspaceID}`, {
const getAWorkspace = (workspaceID: string) =>
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceID}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
'Content-Type': 'application/json'
}
}).then(async (res) => {
if (res?.status == 200) {
if (res?.status === 200) {
const data = (await res.json()) as unknown as { workspace: Workspace };
return data.workspace;
}
throw new Error('Failed to get workspace');
});
};
export default getAWorkspace;
@@ -1,23 +1,22 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* Get the latest key pairs from a certain workspace
* @param {string} workspaceId
* @returns
*/
const getLatestFileKey = ({ workspaceId }: { workspaceId: string }) => {
return SecurityClient.fetchCall('/api/v1/key/' + workspaceId + '/latest', {
const getLatestFileKey = ({ workspaceId }: { workspaceId: string }) =>
SecurityClient.fetchCall(`/api/v1/key/${workspaceId}/latest`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}).then(async (res) => {
if (res?.status == 200) {
return await res.json();
} else {
console.log('Failed to get the latest key pairs for a certain project');
if (res?.status === 200) {
return res.json();
}
console.log('Failed to get the latest key pairs for a certain project');
return undefined;
});
};
export default getLatestFileKey;
@@ -1,23 +1,22 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* This route lets us get the information of a certain project.
* @param {*} projectId - project ID (we renamed workspaces to projects in the app)
* @returns
*/
const getProjectInfo = ({ projectId }: { projectId: string }) => {
return SecurityClient.fetchCall('/api/v1/workspace/' + projectId, {
const getProjectInfo = ({ projectId }: { projectId: string }) =>
SecurityClient.fetchCall(`/api/v1/workspace/${projectId}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}).then(async (res) => {
if (res?.status == 200) {
if (res?.status === 200) {
return (await res.json()).workspace;
} else {
console.log('Failed to get project info');
}
console.log('Failed to get project info');
return undefined;
});
};
export default getProjectInfo;
@@ -1,26 +1,22 @@
import SecurityClient from "~/utilities/SecurityClient";
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* This route lets us get the public keys of everyone in your workspace.
* @param {string} workspaceId
* @returns
*/
const getWorkspaceKeys = ({ workspaceId }: { workspaceId: string; }) => {
return SecurityClient.fetchCall(
"/api/v1/workspace/" + workspaceId + "/keys",
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
const getWorkspaceKeys = ({ workspaceId }: { workspaceId: string }) =>
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceId}/keys`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
).then(async (res) => {
if (res?.status == 200) {
}).then(async (res) => {
if (res?.status === 200) {
return (await res.json()).publicKeys;
} else {
console.log("Failed to get the public keys of everyone in the workspace");
}
console.log('Failed to get the public keys of everyone in the workspace');
return undefined;
});
};
export default getWorkspaceKeys;
@@ -1,26 +1,22 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* This route lets us get all the users in the workspace.
* @param {string} workspaceId - workspace ID
* @returns
*/
const getWorkspaceUsers = ({ workspaceId }: { workspaceId: string }) => {
return SecurityClient.fetchCall(
'/api/v1/workspace/' + workspaceId + '/users',
{
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
const getWorkspaceUsers = ({ workspaceId }: { workspaceId: string }) =>
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceId}/users`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
).then(async (res) => {
if (res?.status == 200) {
}).then(async (res) => {
if (res?.status === 200) {
return (await res.json()).users;
} else {
console.log('Failed to get Project Users');
}
console.log('Failed to get Project Users');
return undefined;
});
};
export default getWorkspaceUsers;
@@ -1,31 +1,30 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
interface Workspace {
__v: number;
_id: string;
name: string;
organization: string;
environments: Array<{name:string, slug:string}>
environments: Array<{ name: string; slug: string }>;
}
/**
* This route lets us get the workspaces of a certain user
* @returns
*/
const getWorkspaces = () => {
return SecurityClient.fetchCall('/api/v1/workspace', {
const getWorkspaces = () =>
SecurityClient.fetchCall('/api/v1/workspace', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}).then(async (res) => {
if (res?.status == 200) {
if (res?.status === 200) {
const data = (await res.json()) as unknown as { workspaces: Workspace[] };
return data.workspaces;
}
throw new Error('Failed to get projects');
});
};
export default getWorkspaces;
@@ -1,4 +1,4 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* This route lets us rename a certain workspace.
@@ -6,25 +6,21 @@ import SecurityClient from '~/utilities/SecurityClient';
* @param {*} res
* @returns
*/
const renameWorkspace = (workspaceId: string, newWorkspaceName: string) => {
return SecurityClient.fetchCall(
'/api/v1/workspace/' + workspaceId + '/name',
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: newWorkspaceName
})
}
).then(async (res) => {
if (res && res.status == 200) {
const renameWorkspace = (workspaceId: string, newWorkspaceName: string) =>
SecurityClient.fetchCall(`/api/v1/workspace/${workspaceId}/name`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: newWorkspaceName
})
}).then(async (res) => {
if (res && res.status === 200) {
return res;
} else {
console.log('Failed to rename a project');
}
console.log('Failed to rename a project');
return undefined;
});
};
export default renameWorkspace;
+9 -15
View File
@@ -1,4 +1,4 @@
import SecurityClient from '~/utilities/SecurityClient';
import SecurityClient from '@app/components/utilities/SecurityClient';
/**
* This route uplods the keys in an encrypted format.
@@ -8,31 +8,25 @@ import SecurityClient from '~/utilities/SecurityClient';
* @param {*} nonce
* @returns
*/
const uploadKeys = (
workspaceId: string,
userId: string,
encryptedKey: string,
nonce: string
) => {
return SecurityClient.fetchCall('/api/v1/key/' + workspaceId, {
const uploadKeys = (workspaceId: string, userId: string, encryptedKey: string, nonce: string) =>
SecurityClient.fetchCall(`/api/v1/key/${workspaceId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
key: {
userId: userId,
encryptedKey: encryptedKey,
nonce: nonce
userId,
encryptedKey,
nonce
}
})
}).then(async (res) => {
if (res && res.status == 200) {
if (res && res.status === 200) {
return res;
} else {
console.log('Failed to upload keys for a new user');
}
console.log('Failed to upload keys for a new user');
return undefined;
});
};
export default uploadKeys;