Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PortalMEC-React
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PortalMEC
PortalMEC-React
Commits
82b1aaac
Commit
82b1aaac
authored
4 years ago
by
Lucas Eduardo Schoenfelder
Browse files
Options
Downloads
Patches
Plain Diff
removed axios call
parent
393245d0
No related branches found
No related tags found
5 merge requests
!57
Merge of develop into master
,
!56
Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...
,
!39
Update admin system
,
!32
Homologa
,
!31
Fix console error
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Pages/Search.js
+20
-22
20 additions, 22 deletions
src/Pages/Search.js
with
20 additions
and
22 deletions
src/Pages/Search.js
+
20
−
22
View file @
82b1aaac
...
...
@@ -40,7 +40,7 @@ import CollectionCardFunction from "../Components/CollectionCardFunction";
import
ContactCard
from
"
../Components/ContactCard
"
;
import
CircularProgress
from
'
@material-ui/core/CircularProgress
'
;
import
{
saveHeaders
}
from
'
../Components/HelperFunctions/saveTokens
'
;
import
getRequest
from
'
./HelperFunctions/getAxiosConfig
'
let
order
=
"
review_average
"
;
...
...
@@ -77,22 +77,10 @@ export default function Search(props) {
);
const
[
optionResult
,
setOptionResult
]
=
useState
(
option
);
const
collectStuff
=
(
tipoBusca
,
filtro
)
=>
{
if
(
!
loadingMoreData
)
// this line prevents resetting filter when loading more data
currFilter
=
filtro
;
if
(
filtro
)
setIsFiltering
(
true
);
/// TODO: FIX this axios call
const
axiosConfig
=
getAxiosConfig
();
axios
({
method
:
'
get
'
,
url
:
`
${
apiUrl
}
/search?page=
${
page
}
&results_per_page=
${
resultsPerPage
}
&order=
${
order
}
&query=
${
state
.
search
.
query
}${
currFilter
?
currFilter
:
""
}
&search_class=
${
tipoBusca
}
`
,
headers
:
axiosConfig
.
headers
}).
then
(
res
=>
{
if
(
tipoBusca
===
"
LearningObject
"
)
setResultsResource
(
res
.
data
);
else
if
(
tipoBusca
===
"
Collection
"
)
setResultsCollection
(
res
.
data
);
else
if
(
tipoBusca
===
"
User
"
)
setResultsUser
(
res
.
data
);
function
handleSuccessfulGet
(
data
)
{
if
(
tipoBusca
===
"
LearningObject
"
)
setResultsResource
(
data
);
else
if
(
tipoBusca
===
"
Collection
"
)
setResultsCollection
(
data
);
else
if
(
tipoBusca
===
"
User
"
)
setResultsUser
(
data
);
setOptionResult
(
tipoBusca
);
dispatch
({
type
:
"
SAVE_SEARCH
"
,
...
...
@@ -101,12 +89,22 @@ export default function Search(props) {
class
:
tipoBusca
,
},
});
setTotalResults
(
res
.
headers
[
"
x-total-count
"
]);
setTotalResults
(
data
.
headers
[
"
x-total-count
"
]);
setIsLoading
(
false
);
setIsFiltering
(
false
);
setLoadingMoreData
(
false
);
saveHeaders
(
res
);
})
}
const
collectStuff
=
(
tipoBusca
,
filtro
)
=>
{
if
(
!
loadingMoreData
)
// this line prevents resetting filter when loading more data
currFilter
=
filtro
;
if
(
filtro
)
setIsFiltering
(
true
);
const
url
=
`/search?page=
${
page
}
&results_per_page=
${
resultsPerPage
}
&order=
${
order
}
&query=
${
state
.
search
.
query
}${
currFilter
?
currFilter
:
""
}
&search_class=
${
tipoBusca
}
`
getRequest
(
url
,
handleSuccessfulGet
,
(
error
)
=>
{
console
.
console
.
log
(
error
)})
};
useEffect
(()
=>
{
...
...
@@ -197,7 +195,7 @@ export default function Search(props) {
<
/Grid
>
<
/Grid
>
<
/HeaderFilters
>
{
isloading
?
<
LoadingSpinner
text
=
"
Carregando...
"
/>
:
optionResult
===
"
Collection
"
?
(
...
...
@@ -228,7 +226,7 @@ export default function Search(props) {
<
div
style
=
{{
display
:
"
flex
"
,
flexDirection
:
"
row
"
,
justifyContent
:
"
center
"
,
}}
>
<
button
style
=
{{
height
:
36
,
backgroundColor
:
"
#ff7f00
"
,
marginBottom
:
50
,
marginTop
:
50
,
fontSize
:
14
,
color
:
"
white
"
,
borderRadius
:
4
,
border
:
"
none
"
,
color
:
"
white
"
,
borderRadius
:
4
,
border
:
"
none
"
,
}}
onClick
=
{()
=>
{
setLoadingMoreData
(
true
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment