Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 19 additions & 5 deletions src/api/endpoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,25 @@ export const elasticSearch = async (query) => {
const url = API_CONFIG.BASE_SCICRUNCH_URL + API_CONFIG.SCICRUNCH_KEY;
try {
const result = await fetchData(url, "POST", {
query: {
query_string: {
query: query,
},
},
"size": 20,
"from": 0,
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"*"
],
"query": query,
"type": "cross_fields",
"default_operator": "and",
"lenient": "true"
}
}
]
}
}
});
return elasticSearhParser(result?.hits?.hits)
} catch (error) {
Expand Down
40 changes: 0 additions & 40 deletions src/components/Auth/Register.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,16 @@ import { GlobalDataContext } from "../../contexts/DataContext";
// import { register } from "../../api/endpoints/apiService";

const schema = yup.object().shape({
firstName: yup.string().required("First name is a required field"),
lastName: yup.string().required("Last name is a required field"),
email: yup.string().email().required(),
username: yup.string().required().min(3),
password: yup.string().required().min(10),
organization: yup.string().required()
});

const Register = () => {
const [formData, setFormData] = React.useState({
firstName: "",
lastName: "",
username: "",
email: "",
password: "",
organization: "",
});

const [errors, setErrors] = React.useState({});
Expand Down Expand Up @@ -137,28 +131,6 @@ const Register = () => {

<form className="authForm">
<Grid container spacing={2.5}>
<FormField
xs={6}
label="First name"
placeholder="Enter your name"
value={formData.firstName}
onChange={(e) =>
setFormData({ ...formData, firstName: e.target.value })
}
errorMessage={errors.firstName}
helperText="Required"
/>
<FormField
xs={6}
label="Last name"
placeholder="Enter your surname"
value={formData.lastName}
onChange={(e) =>
setFormData({ ...formData, lastName: e.target.value })
}
errorMessage={errors.lastName}
helperText="Required"
/>
<FormField
label="Username"
placeholder="Enter your username"
Expand Down Expand Up @@ -189,18 +161,6 @@ const Register = () => {
errorMessage={errors.password}
helperText="Required"
/>
<Grid item xs={12}>
<FormField
label="Organization"
placeholder="Enter your organization"
value={formData.organization}
onChange={(e) =>
setFormData({ ...formData, organization: e.target.value })
}
errorMessage={errors.organization}
helperText="Required"
/>
</Grid>
<Grid item xs={12}>
<FormControl>
<Button variant="contained" color="primary" onClick={registerUser}>
Expand Down
1 change: 1 addition & 0 deletions src/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ const Header = () => {

const handleMenuClick = (e, menu) => {
if (menu.label === 'Log out') {
window.cookieStore.delete({name: 'session', domain: 'https://uri.olympiangods.org'});
setUserData(null, null);
navigate('/');
}
Expand Down
4 changes: 2 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export const API_CONFIG = {
GET_ENDPOINTS_ILX: "/api/real/endpoints-ilx",
PATCH_ENDPOINTS_ILX: "/api/real/patch-endpoints-ilx",
SIGNIN: "/u/ops/user-login",
ORCID_SIGNIN: "/u/ops/orcid-new",
ORCID_SIGNIN: "/u/ops/orcid-login",
NEWUSER_ILX: "/u/ops/user-new",
NEWUSER_ORCID: "/u/ops/orcid-new",
},
OLYMPIAN_GODS : "https://uri.olympiangods.org",
BASE_SCICRUNCH_URL: "/api/elasticsearch?key=",
BASE_SCICRUNCH_URL: "/api/elasticsearch?apikey=",
SCICRUNCH_KEY: import.meta.env.VITE_SCICRUNCH_API_KEY,
BASE_URL: import.meta.env.MODE === "production" ? "https://uri.olympiangods.org" : window.location.origin,
};
4 changes: 2 additions & 2 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export default defineConfig({
server: {
proxy: {
"/api/elasticsearch": {
target: "https://scicrunch.org",
target: "https://api.scicrunch.io",
changeOrigin: true,
secure: true, // Ensure HTTPS requests work
rewrite: (path) =>
path.replace(/^\/api\/elasticsearch/, "/api/1/elastic/Interlex_pr/_search"),
path.replace(/^\/api\/elasticsearch/, "/elastic/v1/Interlex_pr/_search"),
headers: {
// Forward headers correctly
"Content-Type": "application/json",
Expand Down