Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e4124dc
ILEX-83 make changes to login page: connect to backend api
Aiga115 Feb 13, 2025
550290d
Merge branch 'devel' into feature/ILEX-83
Aiga115 Feb 17, 2025
3355e33
ILEX-83 make changes after merge
Aiga115 Feb 17, 2025
8534634
ILEX-83 make changes to login api call and change from email to username
Aiga115 Feb 20, 2025
67d3716
ILEX-83 change from email to username in login page
Aiga115 Feb 20, 2025
afad205
ILEX-83 make a small change
Aiga115 Feb 20, 2025
b94f1ad
ILEX-83 make changes to sign in with orcid
Aiga115 Feb 21, 2025
57561ef
Merge branch 'devel' into feature/ILEX-83
Aiga115 Feb 24, 2025
983a650
ilex-83 push yup
Aiga115 Feb 24, 2025
b49401b
fixing login form styling
ddelpiano Feb 28, 2025
53f5474
ILEX-83 add orcid js widget
Aiga115 Mar 3, 2025
e7ab039
ILEX-83 make changes to orcid widget button style
Aiga115 Mar 4, 2025
f2c68f3
changes for the orcid login
ddelpiano Mar 5, 2025
18f81d3
Merge branch 'feature/ILEX-83' of https://github.com/metacell/interle…
ddelpiano Mar 5, 2025
6c02607
moving the widget on the landing page
ddelpiano Mar 5, 2025
4a3e733
fix double button
ddelpiano Mar 5, 2025
2092b77
Merge branch 'devel' of https://github.com/metacell/interlex into fea…
ddelpiano Mar 6, 2025
0b09b65
Merge branch 'devel' into feature/ILEX-83
Aiga115 Mar 27, 2025
421e6ee
ILEX-83 centralize api service
Aiga115 Mar 28, 2025
efd3b9d
ILEX-83 add base url
Aiga115 Apr 1, 2025
2223eb5
ILEX-83 fix base url
Aiga115 Apr 1, 2025
68111e0
Merge branch 'devel' into feature/ILEX-83
Aiga115 Apr 1, 2025
3b5004f
Merge branch 'feature/ILEX-83' of https://github.com/metacell/interle…
ddelpiano Apr 1, 2025
81b46cb
fixing logging
ddelpiano Apr 1, 2025
2e5fd04
ILEX-83 connect orcid login page
Aiga115 Apr 3, 2025
ae4f1b1
ILEX-97 connect top bar to user data
Aiga115 Apr 3, 2025
a545faa
ILEX-96 registration form update
Aiga115 Apr 3, 2025
e50e696
ILEX-96 connect register api to centralized api service
Aiga115 Apr 3, 2025
1242347
ILEX-96 change password minimum character
Aiga115 Apr 3, 2025
9555a69
ILEX-83 perform clean up
Aiga115 Apr 7, 2025
93d0218
ILEX-83 fix linting
Aiga115 Apr 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions mock/mutator/customClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Axios, { AxiosRequestConfig } from 'axios';
export const AXIOS_INSTANCE = Axios.create({ baseURL: '.' }); // use your own URL here or environment variable
import { API_CONFIG } from '../../src/config';
export const AXIOS_INSTANCE = Axios.create({ baseURL: API_CONFIG.BASE_URL });

// add a second `options` argument here if you want to pass extra options to each generated query
export const customInstance = <T>(
Expand All @@ -12,7 +12,9 @@ export const customInstance = <T>(
...config,
...options,
cancelToken: source.token,
}).then(({ data }) => data).catch(error => console.log("Error ", error));
}).then(({ data }) => data).catch(error => {
throw error;
});

// @ts-ignore
promise.cancel = () => {
Expand All @@ -30,4 +32,4 @@ export type BodyType<BodyData> = BodyData;

// Or, in case you want to wrap the body type (optional)
// (if the custom instance is processing data before sending it, like changing the case for example)
export type BodyType<BodyData> = CamelCase<BodyData>;
export type BodyType<BodyData> = CamelCase<BodyData>;
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
"@mui/lab": "^5.0.0-alpha.170",
"@mui/material": "^5.15.15",
"@mui/x-tree-view": "^7.5.0",
"body-parser" : "^1.20.3",
"cors" : "^2.8.5",
"body-parser": "^1.20.3",
"cors": "^2.8.5",
"d3": "^7.1.1",
"dotenv": "16.4.7",
"date-fns": "^3.6.0",
"express" : "^4.21.2",
"dotenv": "16.4.7",
"express": "^4.21.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.23.1",
"react-rte": "^0.16.5",
"react-syntax-highlighter": "^15.5.0"
"react-syntax-highlighter": "^15.5.0",
"yup": "^1.6.1"
},
"devDependencies": {
"@faker-js/faker": "^8.4.1",
Expand Down
17 changes: 17 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect } from "react";
import CssBaseline from "@mui/material/CssBaseline";
import { Box, ThemeProvider } from "@mui/material";
import {
Expand All @@ -24,6 +25,7 @@ import ForgotPassword from "./components/Auth/ForgotPassword";
import SingleOrganization from "./components/SingleOrganization";
import TermActivity from "./components/term_activity/TermActivity";
import OrganizationsCurieEditor from "./components/CurieEditor/OrganizationCurieEditor";
import { handleOrcidLogin } from "./api/endpoints";

const PageContainer = ({ children }) => {
return (
Expand Down Expand Up @@ -116,6 +118,20 @@ const Layout = ({ children }) => {
const authPaths = ["/login", "/register", "/forgot", "/reset"];
const location = useLocation();
const isAuthPath = authPaths.includes(location.pathname);

useEffect(() => {
const params = new URLSearchParams(location.search);
const code = params.get("code");
if (code) {(async () => {
try {
const response = await handleOrcidLogin(code);
localStorage.setItem("token", response.token);
} catch (error) {
console.log("error: ", error)
}})();
}
}, [location]);

// Determine whether to show the footer based on the current route
const showFooter = location.pathname !== "/";
return (
Expand All @@ -134,6 +150,7 @@ const Layout = ({ children }) => {
};

function App() {

return (
<ThemeProvider theme={theme}>
<CssBaseline />
Expand Down
4 changes: 2 additions & 2 deletions src/api/custom-axios-instance.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios";
import { API_CONFIG } from "../../config/config.js";
import { API_CONFIG } from "../config.ts";

export const customAxiosInstance = axios.create({
baseURL: API_CONFIG.BASE_SCICRUNCH_URL,
Expand All @@ -14,4 +14,4 @@ customAxiosInstance.interceptors.request.use((config) => {
api_key: process.env.API_KEY, // Load API key from .env
};
return config;
});
});
42 changes: 42 additions & 0 deletions src/api/endpoints/apiActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { AxiosRequestConfig } from 'axios';
import { customInstance } from '../../../mock/mutator/customClient';
import { API_CONFIG } from '../../config';


type SecondParameter<T extends (...args: any) => any> = Parameters<T>[1];

export const createPostRequest = <T = any, D = any>(endpoint: string, contentType = "application/json") => {
return (data?: D, options?: SecondParameter<typeof customInstance>) => {
return customInstance<T>(
{
url: API_CONFIG.BASE_URL + endpoint,
method: "POST",
data: data,
headers: {
"Content-Type": contentType,
},
},
options,
)
}
}

export const createGetRequest = <T = any, P = any>(endpoint: string, contentType?: string) => {
return (params?: P, options?: SecondParameter<typeof customInstance>, signal?: AbortSignal) => {
const config: AxiosRequestConfig = {
url: API_CONFIG.BASE_URL + endpoint,
method: "GET",
params,
signal,
}

if (contentType) {
config.headers = {
...config.headers,
"Content-Type": contentType,
}
}

return customInstance<T>(config, options)
}
}
19 changes: 19 additions & 0 deletions src/api/endpoints/apiService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { createPostRequest } from "./apiActions";
import { API_CONFIG } from "../../config";

export interface LoginRequest {
username: string
password: string
}

export interface RegisterRequest {
username: string
password: string
firstName: string
lastName: string
email: string
organization: string
}

export const login = createPostRequest<any, LoginRequest>(API_CONFIG.REAL_API.SIGNIN, "application/x-www-form-urlencoded")
export const register = createPostRequest<any, RegisterRequest>(API_CONFIG.REAL_API.NEWUSER_ILX, "application/x-www-form-urlencoded")
23 changes: 17 additions & 6 deletions src/api/endpoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,21 +344,32 @@ export const addMessateToVariantDiscussion = async (group, variantID, message) =
});
}

export const handleLogin = async (email: string, password: string) => {
export const handleLogin = async (username: string, password: string) => {
try {
const { postOpsUserLogin } = useApi()
const response = await postOpsUserLogin({
email,
password,
});
const response = await postOpsUserLogin({ username: username, password: password });
console.log("Login successful:", response);
return response.data;
return response;
} catch (error) {
console.error("Login failed:", error);
throw error;
}
};

export const handleOrcidLogin = async (code: string) => {
const response = await fetch("https://uri.olympiangods.org/u/ops/orcid-login", {
method: "POST",
headers: { "Content-Type": "application/json" },
// body: JSON.strijiuigngify({ code }),
});

if (!response.ok) {
throw new Error("ORCID authentication failed");
}

return response.json();
};

export const handleRegister = async (
firstName: string,
lastName: string,
Expand Down
31 changes: 24 additions & 7 deletions src/api/endpoints/interLexURIStructureAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
} from '@tanstack/react-query'
import { customInstance } from '../../../mock/mutator/customClient';
import type { ErrorType } from '../../../mock/mutator/customClient';
import { API_CONFIG } from '../../config';

type AwaitedInput<T> = PromiseLike<T> | T;

Expand Down Expand Up @@ -483,16 +484,32 @@ export const useGetOpsUserLogin = <TData = Awaited<ReturnType<typeof getOpsUserL



export const postOpsUserLogin = (
// export const postOpsUserLogin = (

options?: SecondParameter<typeof customInstance>,) => {
// options?: SecondParameter<typeof customInstance>,) => {


return customInstance<void>(
{url: `https://uri.olympiangods.org/u/ops/user-login`, method: 'POST'
},
options);
}
// return customInstance<void>(
// {url: `https://uri.olympiangods.org/u/ops/user-login`, method: 'POST'
// },
// options);
// }
export const postOpsUserLogin = (
userData: { username: string; password: string },
options?: SecondParameter<typeof customInstance>
) => {
return customInstance<void>(
{
url: `${API_CONFIG.BASE_URL}${API_CONFIG.REAL_API.SIGNIN}`,
method: 'POST',
data: userData,
headers: {
'Content-Type': "application/x-www-form-urlencoded",
},
},
options
);
};



Expand Down
Loading