From 9f75b66d85776df513d0603668aa995426b83cee Mon Sep 17 00:00:00 2001 From: ddelpiano Date: Thu, 10 Apr 2025 11:18:27 +0200 Subject: [PATCH] migrate to new scicrunch endpoint --- src/api/endpoints/index.ts | 24 +++++++++++++++---- src/components/Auth/Register.jsx | 40 -------------------------------- src/components/Header/index.jsx | 1 + src/config.js | 4 ++-- vite.config.js | 4 ++-- 5 files changed, 24 insertions(+), 49 deletions(-) diff --git a/src/api/endpoints/index.ts b/src/api/endpoints/index.ts index 649881c9..1fe20fb0 100644 --- a/src/api/endpoints/index.ts +++ b/src/api/endpoints/index.ts @@ -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) { diff --git a/src/components/Auth/Register.jsx b/src/components/Auth/Register.jsx index e5068b38..d0d953d7 100644 --- a/src/components/Auth/Register.jsx +++ b/src/components/Auth/Register.jsx @@ -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({}); @@ -137,28 +131,6 @@ const Register = () => {
- - setFormData({ ...formData, firstName: e.target.value }) - } - errorMessage={errors.firstName} - helperText="Required" - /> - - setFormData({ ...formData, lastName: e.target.value }) - } - errorMessage={errors.lastName} - helperText="Required" - /> { errorMessage={errors.password} helperText="Required" /> - - - setFormData({ ...formData, organization: e.target.value }) - } - errorMessage={errors.organization} - helperText="Required" - /> -