diff --git a/frontend/src/APIClients/AuthAPIClient.ts b/frontend/src/APIClients/AuthAPIClient.ts index 5c1e8b07..8ee3b47e 100644 --- a/frontend/src/APIClients/AuthAPIClient.ts +++ b/frontend/src/APIClients/AuthAPIClient.ts @@ -5,13 +5,13 @@ import { } from "@apollo/client"; import AUTHENTICATED_USER_KEY from "../constants/AuthConstants"; import { AuthenticatedUser } from "../types/AuthTypes"; -// rest { +/* } rest import baseAPIClient from "./BaseAPIClient"; import { getLocalStorageObjProperty, setLocalStorageObjProperty, } from "../utils/LocalStorageUtils"; -// } rest +} rest */ // graphql { import { setLocalStorageObjProperty } from "../utils/LocalStorageUtils"; // } graphql @@ -189,7 +189,7 @@ export default { login, logout, loginWithGoogle, register, refresh }; // } graphql -// rest { +/* } rest const login = async ( email: string, password: string, @@ -295,4 +295,4 @@ const refresh = async (): Promise => { }; export default { login, logout, loginWithGoogle, register, resetPassword, refresh }; -// } rest +} rest */ diff --git a/frontend/src/APIClients/BaseAPIClient.ts b/frontend/src/APIClients/BaseAPIClient.ts index fb123111..7e4df25a 100644 --- a/frontend/src/APIClients/BaseAPIClient.ts +++ b/frontend/src/APIClients/BaseAPIClient.ts @@ -1,10 +1,10 @@ -// typescript { +/* typescript { import axios, { AxiosRequestConfig } from "axios"; -// } typescript -// python { +} typescript */ +/* python { import axios, { AxiosResponse, AxiosRequestConfig } from "axios"; import { camelizeKeys, decamelizeKeys } from "humps"; -// } python +python { */ // auth { import jwt from "jsonwebtoken"; @@ -17,7 +17,7 @@ const baseAPIClient = axios.create({ baseURL: process.env.REACT_APP_BACKEND_URL, }); -// python { +/* python { // Python API uses snake_case, frontend uses camelCase // convert request and response data to/from snake_case and camelCase through axios interceptors baseAPIClient.interceptors.response.use((response: AxiosResponse) => { @@ -30,7 +30,7 @@ baseAPIClient.interceptors.response.use((response: AxiosResponse) => { return response; }); -// } python +python { */ baseAPIClient.interceptors.request.use(async (config: AxiosRequestConfig) => { const newConfig = { ...config }; @@ -67,7 +67,7 @@ baseAPIClient.interceptors.request.use(async (config: AxiosRequestConfig) => { } // } auth - // python { + /* python { if (config.params) { newConfig.params = decamelizeKeys(config.params); } @@ -75,7 +75,7 @@ baseAPIClient.interceptors.request.use(async (config: AxiosRequestConfig) => { newConfig.data = decamelizeKeys(config.data); } - // } python + python { */ return newConfig; }); diff --git a/frontend/src/APIClients/EntityAPIClient.ts b/frontend/src/APIClients/EntityAPIClient.ts index a1f56a64..e14e98ff 100644 --- a/frontend/src/APIClients/EntityAPIClient.ts +++ b/frontend/src/APIClients/EntityAPIClient.ts @@ -102,12 +102,12 @@ const getFile = async (uuid: string): Promise => { // no-auth { const { data } = await baseAPIClient.get(`/entities/files/${uuid}`); // } no-auth - // typescript { + /* typescript { return data.fileURL - // } typescript - // python { + } typescript */ + /* python { return data.fileUrl; - // } python + python { */ } catch (error) { return error; } diff --git a/frontend/src/components/auth/Login.tsx b/frontend/src/components/auth/Login.tsx index 7074209c..e7f58012 100644 --- a/frontend/src/components/auth/Login.tsx +++ b/frontend/src/components/auth/Login.tsx @@ -70,9 +70,9 @@ const Login = (): React.ReactElement => { login, ); // } graphql - // rest { + /* } rest const user: AuthenticatedUser = await authAPIClient.login(email, password); - // } rest + } rest */ setAuthenticatedUser(user); }; @@ -89,14 +89,14 @@ const Login = (): React.ReactElement => { setAuthenticatedUser(user); }; // } graphql - // rest { + /* } rest const onGoogleLoginSuccess = async (tokenId: string) => { const user: AuthenticatedUser = await authAPIClient.loginWithGoogle( tokenId, ); setAuthenticatedUser(user); }; - // } rest + } rest */ if (authenticatedUser) { return ; diff --git a/frontend/src/components/auth/Logout.tsx b/frontend/src/components/auth/Logout.tsx index 99a06c1a..447a02ff 100644 --- a/frontend/src/components/auth/Logout.tsx +++ b/frontend/src/components/auth/Logout.tsx @@ -28,9 +28,9 @@ const Logout = (): React.ReactElement => { logout, ); // } graphql - // rest { + /* } rest const success = await authAPIClient.logout(authenticatedUser?.id); - // } rest + } rest */ if (success) { setAuthenticatedUser(null); } diff --git a/frontend/src/components/auth/RefreshCredentials.tsx b/frontend/src/components/auth/RefreshCredentials.tsx index b9f286df..ac305969 100644 --- a/frontend/src/components/auth/RefreshCredentials.tsx +++ b/frontend/src/components/auth/RefreshCredentials.tsx @@ -25,9 +25,9 @@ const RefreshCredentials = (): React.ReactElement => { // graphql { const success = await authAPIClient.refresh(refresh); // } graphql - // rest { + /* } rest const success = await authAPIClient.refresh(); - // } rest + } rest */ if (!success) { setAuthenticatedUser(null); } diff --git a/frontend/src/components/auth/ResetPassword.tsx b/frontend/src/components/auth/ResetPassword.tsx index 46376431..1e9fa520 100644 --- a/frontend/src/components/auth/ResetPassword.tsx +++ b/frontend/src/components/auth/ResetPassword.tsx @@ -2,9 +2,9 @@ import React, { useContext } from "react"; // graphql { import { gql, useMutation } from "@apollo/client"; // } graphql -// rest { +/* } rest import authAPIClient from "../../APIClients/AuthAPIClient"; -// } rest +} rest */ import AuthContext from "../../contexts/AuthContext"; // graphql { @@ -28,9 +28,9 @@ const ResetPassword = (): React.ReactElement => { // graphql { await resetPassword({ variables: { email: authenticatedUser?.email } }); // } graphql - // rest { + /* } rest await authAPIClient.resetPassword(authenticatedUser?.email); - // } rest + } rest */ }; return ( diff --git a/frontend/src/components/auth/Signup.tsx b/frontend/src/components/auth/Signup.tsx index 4ba12d06..f0b0d852 100644 --- a/frontend/src/components/auth/Signup.tsx +++ b/frontend/src/components/auth/Signup.tsx @@ -57,14 +57,14 @@ const Signup = (): React.ReactElement => { register, ); // } graphql - // rest { + /* } rest const user: AuthenticatedUser = await authAPIClient.register( firstName, lastName, email, password, ); - // } rest + } rest */ setAuthenticatedUser(user); }; diff --git a/frontend/src/components/crud/CreateForm.tsx b/frontend/src/components/crud/CreateForm.tsx index 178f4499..84e02a0f 100644 --- a/frontend/src/components/crud/CreateForm.tsx +++ b/frontend/src/components/crud/CreateForm.tsx @@ -1,7 +1,7 @@ import React, { useState } from "react"; -// python { +/* python { import { decamelizeKeys } from "humps"; -// } python +python { */ import { JSONSchema7 } from "json-schema"; import { Form } from "@rjsf/bootstrap-4"; // graphql { @@ -12,12 +12,12 @@ import { EntityResponse, } from "../../APIClients/EntityAPIClient"; // } graphql -// rest { +/* } rest import EntityAPIClient, { EntityRequest, EntityResponse, } from "../../APIClients/EntityAPIClient"; -// } rest +} rest */ const schema: JSONSchema7 = { title: "Create Entity", @@ -147,24 +147,26 @@ const CreateForm = (): React.ReactElement => { const result: EntityResponse | null = graphQLResult.data?.createEntity ?? null; // } graphql - // rest { + /* } rest // no-file-storage { const result = await EntityAPIClient.create({ formData }); // } no-file-storage // file-storage { const multipartFormData = new FormData(); - // typescript { + /* typescript { multipartFormData.append("body", JSON.stringify(formData)); - // } typescript - // python { + } typescript */ + /* python { multipartFormData.append("body", JSON.stringify(decamelizeKeys(formData))); - // } python + python { */ if (fileField) { multipartFormData.append("file", fileField); } - const result = await EntityAPIClient.create({ formData: multipartFormData }); + const result = await EntityAPIClient.create({ + formData: multipartFormData, + }); // } file-storage - // } rest + } rest */ setData(result); }; // no-file-storage { diff --git a/frontend/src/components/crud/DisplayTableContainer.tsx b/frontend/src/components/crud/DisplayTableContainer.tsx index 0ca3e2ab..b39072bc 100644 --- a/frontend/src/components/crud/DisplayTableContainer.tsx +++ b/frontend/src/components/crud/DisplayTableContainer.tsx @@ -2,9 +2,9 @@ // graphql { import React, { useState } from "react"; // } graphql -// rest { +/* } rest import React, { useState, useEffect } from "react"; -// } rest +} rest */ import BTable from "react-bootstrap/Table"; import { HeaderGroup, useTable, Column } from "react-table"; @@ -13,12 +13,12 @@ import { gql, useApolloClient, useQuery } from "@apollo/client"; import { EntityResponse } from "../../APIClients/EntityAPIClient"; // } graphql -// rest { +/* } rest import EntityAPIClient, { EntityResponse, } from "../../APIClients/EntityAPIClient"; -// } rest +} rest */ import { downloadCSV } from "../../utils/CSVUtils"; // file-storage { import { downloadFile } from "../../utils/FileUtils"; @@ -219,7 +219,7 @@ const DisplayTableContainer: React.FC = (): React.ReactElement | null => { }, }); // } graphql - // rest { + /* } rest useEffect(() => { const retrieveAndUpdateData = async () => { const result = await EntityAPIClient.get(); @@ -229,7 +229,7 @@ const DisplayTableContainer: React.FC = (): React.ReactElement | null => { }; retrieveAndUpdateData(); }, []); - // } rest + } rest */ // file-storage { const downloadEntityFile = async (fileUUID: string) => { @@ -241,10 +241,10 @@ const DisplayTableContainer: React.FC = (): React.ReactElement | null => { downloadFile(data.file, "file"); // } graphql - // rest { + /* } rest const data = await EntityAPIClient.getFile(fileUUID); downloadFile(data, "file"); - // } rest + } rest */ }; // } file-storage @@ -256,10 +256,10 @@ const DisplayTableContainer: React.FC = (): React.ReactElement | null => { }); downloadCSV(data.entitiesCSV, "export.csv"); // } graphql - // rest { + /* } rest const csvString = await EntityAPIClient.getCSV(); downloadCSV(csvString, "export.csv"); - // } rest + } rest */ // Use the following lines to download CSV using frontend CSV generation instead of API // const csvString = await generateCSV({ data: entities }); // downloadCSV(csvString, "export.csv"); diff --git a/frontend/src/components/crud/UpdateForm.tsx b/frontend/src/components/crud/UpdateForm.tsx index 71eb7a41..8cd0231c 100644 --- a/frontend/src/components/crud/UpdateForm.tsx +++ b/frontend/src/components/crud/UpdateForm.tsx @@ -1,7 +1,7 @@ import React, { useState } from "react"; -// python { +/* python { import { decamelizeKeys } from "humps"; -// } python +python { */ import { JSONSchema7 } from "json-schema"; import { Form } from "@rjsf/bootstrap-4"; // graphql { @@ -12,12 +12,12 @@ import { EntityResponse, } from "../../APIClients/EntityAPIClient"; // } graphql -// rest { +/* } rest import EntityAPIClient, { EntityRequest, EntityResponse, } from "../../APIClients/EntityAPIClient"; -// } rest +} rest */ const schema: JSONSchema7 = { title: "Update Entity", @@ -163,27 +163,29 @@ const UpdateForm = (): React.ReactElement => { const result: EntityResponse | null = graphQLResult.data?.updateEntity ?? null; // } graphql - // rest { + /* } rest // no-file-storage { const result = await EntityAPIClient.update(formData.id, { entityData }); // } no-file-storage // file-storage { const multipartFormData = new FormData(); - // typescript { + /* typescript { multipartFormData.append("body", JSON.stringify(entityData)); - // } typescript - // python { - multipartFormData.append("body", JSON.stringify(decamelizeKeys(entityData))); - // } python + } typescript */ + /* python { + multipartFormData.append( + "body", + JSON.stringify(decamelizeKeys(entityData)), + ); + python { */ if (fileField) { multipartFormData.append("file", fileField); } - const result = await EntityAPIClient.update( - formData.id, - { entityData: multipartFormData } - ); + const result = await EntityAPIClient.update(formData.id, { + entityData: multipartFormData, + }); // } file-storage - // } rest + } rest */ setData(result); }; // no-file-storage { diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index 1a522c40..ed40937b 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -127,11 +127,11 @@ ReactDOM.render( , // } graphql - // rest { + /* } rest , - // } rest + } rest */ document.getElementById("root"), );