From 866fe16a35e2d63630277ed7dc50d7c55b42cb90 Mon Sep 17 00:00:00 2001
From: Luis Felipe Risch <lfr20@inf.ufpr.br>
Date: Fri, 18 Dec 2020 09:35:00 -0300
Subject: [PATCH] Fixed filter error

---
 src/Pages/Search.js | 82 +++++++++++++++++++++++----------------------
 1 file changed, 42 insertions(+), 40 deletions(-)

diff --git a/src/Pages/Search.js b/src/Pages/Search.js
index 08f6f80b..1ee9749f 100644
--- a/src/Pages/Search.js
+++ b/src/Pages/Search.js
@@ -75,11 +75,9 @@ export default function Search(props) {
   const [optionResult, setOptionResult] = useState(option);
 
   const collectStuff = (tipoBusca, filtro) => {
-    currFilter = filtro; 
-    if(filtro)
+    currFilter = filtro;
+    if (filtro)
       setIsFiltering(true);
-    if(tipoBusca === "Collection" || tipoBusca === "User")
-      setIsLoading(true);
 
     axios
       .get(
@@ -193,6 +191,7 @@ export default function Search(props) {
                   options={options}
                   value={optionResult}
                   onChange={(e) => {
+                    setIsLoading(true);
                     setOption(e.value);
                     collectStuff(e.value, "");
                   }}
@@ -213,44 +212,47 @@ export default function Search(props) {
                 Resultados encontrados: {totalResults}
               </div>
             </Grid>
-            <Grid
-              item
-              xs={4}
-              style={{
-                display: "flex",
-                flexDirection: "column",
-                justifyContent: "center",
-                paddingRight: 20,
-              }}
-            >
-              <div
-                style={{
-                  display: "flex",
-                  flexDirection: "row",
-                  justifyContent: "end",
-                }}
-              >
-                <span
+            {
+              optionResult === "User" ? null :
+                <Grid
+                  item
+                  xs={4}
                   style={{
-                    textAlign: "right",
-                    alignSelf: "center",
-                    marginRight: 10,
+                    display: "flex",
+                    flexDirection: "column",
+                    justifyContent: "center",
+                    paddingRight: 20,
                   }}
                 >
-                  ORDENAR POR:
+                  <div
+                    style={{
+                      display: "flex",
+                      flexDirection: "row",
+                      justifyContent: "end",
+                    }}
+                  >
+                    <span
+                      style={{
+                        textAlign: "right",
+                        alignSelf: "center",
+                        marginRight: 10,
+                      }}
+                    >
+                      ORDENAR POR:
                 </span>
-                <Dropdown
-                  options={ordenar}
-                  value={currOrder}
-                  onChange={(e) => {
-                    order = e.value;
-                    setCurrOrder(e.label)
-                    collectStuff(optionResult, currFilter);
-                  }}
-                  placeholder="Select an order "
-                />
-              </div>
-            </Grid>
+                    <Dropdown
+                      options={ordenar}
+                      value={currOrder}
+                      onChange={(e) => {
+                        order = e.value;
+                        setCurrOrder(e.label)
+                        collectStuff(optionResult, currFilter);
+                      }}
+                      placeholder="Select an order "
+                    />
+                  </div>
+                </Grid>
+            }
           </Grid>
         </HeaderFilters>
 
@@ -311,7 +313,7 @@ export default function Search(props) {
                 <GridBuscaResource container spacing={2}>
                   <Grid item md={3} xs={12}>
                     <Paper elevation={4} square>
-                      <SearchExpansionPanel onChange={collectStuff} onFiltering={isFiltering}/>
+                      <SearchExpansionPanel onChange={collectStuff} onFiltering={isFiltering} />
                     </Paper>
                   </Grid>
                   <Grid item md={9} xs={12}>
@@ -413,7 +415,7 @@ export default function Search(props) {
                           }}
                         >
                           {
-                            loadingMoreData ? <CircularProgress size={24}  /> : "Carregar mais 12"
+                            loadingMoreData ? <CircularProgress color="inherit" size={24} /> : "Carregar mais 12"
                           }
                         </button>
                       </div>
-- 
GitLab