Skip to content
Snippets Groups Projects
Commit 62b8bdc3 authored by lfr20's avatar lfr20
Browse files

Fixing requests

parent 6d8c8b76
Branches
No related tags found
1 merge request!46Gamefication admin
...@@ -45,8 +45,6 @@ import MobileList from "../../../Components/Components/MobileComponents/SimpleLi ...@@ -45,8 +45,6 @@ import MobileList from "../../../Components/Components/MobileComponents/SimpleLi
import styled from "styled-components" import styled from "styled-components"
import PageHeader from "../../../Components/Components/PageHeader" import PageHeader from "../../../Components/Components/PageHeader"
let currPage = 0;
const StyledTableCell = withStyles((theme) => ({ const StyledTableCell = withStyles((theme) => ({
head: { head: {
backgroundColor: theme.palette.common.black, backgroundColor: theme.palette.common.black,
...@@ -84,8 +82,8 @@ const Activity = () => { ...@@ -84,8 +82,8 @@ const Activity = () => {
const [isUpdating, setIsUpdating] = useState(false); //controlls the state of updating data const [isUpdating, setIsUpdating] = useState(false); //controlls the state of updating data
const [showFilter, setShowFilter] = useState(false); const [showFilter, setShowFilter] = useState(false);
const [option, setOption] = useState(); //labels of the text field 'to'
const [option, setOption] = useState("Todos os usuários"); //labels of the text field 'to' const [currPage, setCurrPage] = useState(0)
const [snackInfo, setSnackInfo] = useState({ const [snackInfo, setSnackInfo] = useState({
message: "", message: "",
...@@ -96,12 +94,12 @@ const Activity = () => { ...@@ -96,12 +94,12 @@ const Activity = () => {
const options = [ const options = [
{ {
value: "private", name: "private",
label: "Privado", value: "Privado",
}, },
{ {
value: "public", name: "public",
label: "Público", value: "Público",
}, },
]; ];
...@@ -115,74 +113,8 @@ const Activity = () => { ...@@ -115,74 +113,8 @@ const Activity = () => {
}); });
}; };
//handle load more items
const LoadMoreItens = async (api) => {
setIsLoadingMoreItems(true);
getRequest(api,
(data, header) => {
const arrData = [...data];
if (arrData.length === 0) {
HandleSnack(
"Não há mais dados para serem carregados",
true,
"warning",
"#FFC125"
);
} else {
const arrItems = [...items];
arrItems.pop(); //Deleting the last position, that was used to display the button of load more items
const arrResult = arrItems.concat(arrData);
setItems(arrResult.concat(ADD_ONE_LENGHT));
}
setIsLoadingMoreItems(false);
},
(error) => {
HandleSnack("Erro ao carregar os dados", true, "warning", "#FA8072");
setIsLoadingMoreItems(false);
}
)
};
// handle update list data
const UpdateHandler = async (api) => {
setIsUpdating(true);
getRequest(api,
(data, header) => {
HandleSnack(
"A lista de dados foi atualizada",
true,
"success",
"#228B22"
);
const arrData = [...data];
setItems(arrData.concat(ADD_ONE_LENGHT))
setIsUpdating(false);
},
(error) => {
HandleSnack("Erro ao carregar os dados", true, "warning", "#FA8072");
setIsUpdating(false);
}
)
};
const handleChange = (e) => { const handleChange = (e) => {
setIsLoaded(false) setOption(e.target.value);
const value = e.target.value;
currPage = 0;
setOption(value);
getRequest(Url("activities", `"privacy" : "${value}"`, `${currPage}`, "DESC"),
(data, header) => {
const arrData = [...data];
setItems(arrData.concat(ADD_ONE_LENGHT));
HandleSnack("Filtro aplicado com sucesso", true, "success", "#228B22");
setIsLoaded(true);
},
(error) => {
HandleSnack("Erro ao carregar os dados", true, "warning", "#FA8072");
setIsLoaded(true);
}
)
}; };
const DisplayDate = (date) => { const DisplayDate = (date) => {
...@@ -210,13 +142,59 @@ const Activity = () => { ...@@ -210,13 +142,59 @@ const Activity = () => {
) )
}, []); }, []);
const buildUrl = (privacyOpt) => {
if (privacyOpt)
return Url("/activities", `"privacy" : "${privacyOpt}"`, currPage, "DESC")
return Url("/activities", "", currPage, "DESC")
}
useEffect(() => {
if (currPage === 0)
setIsLoaded(false)
else
setIsLoadingMoreItems(true)
getRequest(
buildUrl(option),
(data, header) => {
const arrData = [...data]
if (arrData.length === 0) {
HandleSnack('Não há mais dados para serem carregados', true, 'warning', '#FFC125')
} else {
const arrItems = [...items]
if (currPage === 0) {
setItems(arrData.concat(ADD_ONE_LENGHT))
}
else {
arrItems.pop(); //Deleting the last position, that was used to display the button of load more items
const arrResult = arrItems.concat(arrData)
setItems(arrResult.concat(ADD_ONE_LENGHT))
}
}
setIsLoaded(true)
setIsLoadingMoreItems(false)
},
(error) => {
HandleSnack('Erro ao carregar os dados', true, 'warning', '#FA8072')
setIsLoadingMoreItems(false)
setIsLoaded(true)
setError(true)
}
)
}, [currPage, option])
useEffect(() => {
setOption()
setCurrPage(0)
}, [showFilter])
if (error) { if (error) {
return <div>Error: {error.message}</div>; return <div>Error: {error.message}</div>;
} else if (!isLoaded) { } else if (!isLoaded) {
return <LoadingSpinner text="Carregando..." /> return <LoadingSpinner text="Carregando..." />
} else { } else {
if (WINDOW_WIDTH <= 758) { if (WINDOW_WIDTH <= 820) {
return <> return <>
<SnackBar <SnackBar
severity={snackInfo.icon} severity={snackInfo.icon}
...@@ -249,10 +227,7 @@ const Activity = () => { ...@@ -249,10 +227,7 @@ const Activity = () => {
color="secondary" color="secondary"
disabled={isUpdating} disabled={isUpdating}
onClick={() => { onClick={() => {
currPage = 0; setCurrPage(0)
UpdateHandler(
Url("activities", "", `${currPage}`, "DESC")
);
}} }}
startIcon={<UpdateRoundedIcon />} startIcon={<UpdateRoundedIcon />}
> >
...@@ -281,18 +256,19 @@ const Activity = () => { ...@@ -281,18 +256,19 @@ const Activity = () => {
<div style={{ alignSelf: "flex-end" }}> <div style={{ alignSelf: "flex-end" }}>
<TextField <TextField
select={true} select
label="Filtro" label="Filtro"
value={option ? option : ""} value={option}
onChange={handleChange} onChange={handleChange}
helperText="Por favor, selecione uma das opções" helperText="Por favor, selecione uma das opções"
> >
{options.map((option, index) => ( {options.map((option, index) => (
<MenuItem <MenuItem
key={option.value} key={option.value}
value={option.value} value={option.name}
name={option.value}
> >
{option.label} {option.value}
</MenuItem> </MenuItem>
))} ))}
</TextField> </TextField>
...@@ -305,7 +281,9 @@ const Activity = () => { ...@@ -305,7 +281,9 @@ const Activity = () => {
{items.map((row, index) => {items.map((row, index) =>
index === items.length - 1 ? ( index === items.length - 1 ? (
<StyledDivButton> <StyledDivButton
key="Load more"
>
<Button <Button
key={index} key={index}
color="primary" color="primary"
...@@ -314,16 +292,7 @@ const Activity = () => { ...@@ -314,16 +292,7 @@ const Activity = () => {
startIcon={<AddRoundedIcon />} startIcon={<AddRoundedIcon />}
disabled={isLoadingMoreItems} disabled={isLoadingMoreItems}
onClick={() => { onClick={() => {
currPage++; setCurrPage(currPage + 1)
if (showFilter) {
LoadMoreItens(
Url("activities", `"privacy" : "${option}"`, `${currPage}`, "DESC")
);
} else {
LoadMoreItens(
Url("activities", "", `${currPage}`, "DESC")
);
}
}} }}
> >
{isLoadingMoreItems ? ( {isLoadingMoreItems ? (
...@@ -343,7 +312,7 @@ const Activity = () => { ...@@ -343,7 +312,7 @@ const Activity = () => {
avatar={<AllOutIcon />} avatar={<AllOutIcon />}
href={`/admin/activity/${row.id}`} href={`/admin/activity/${row.id}`}
reset={() => { reset={() => {
currPage = 0;
}} }}
data={ data={
[ [
...@@ -392,10 +361,7 @@ const Activity = () => { ...@@ -392,10 +361,7 @@ const Activity = () => {
name: "Atualizar", name: "Atualizar",
isLoading: isUpdating, isLoading: isUpdating,
func: () => { func: () => {
currPage = 0; setCurrPage(0)
UpdateHandler(
Url("activities", "", `${currPage}`, "DESC")
);
}, },
icon: <UpdateRoundedIcon /> icon: <UpdateRoundedIcon />
}, },
...@@ -424,9 +390,10 @@ const Activity = () => { ...@@ -424,9 +390,10 @@ const Activity = () => {
{options.map((option, index) => ( {options.map((option, index) => (
<MenuItem <MenuItem
key={option.value} key={option.value}
value={option.value} value={option.name}
name={option.value}
> >
{option.label} {option.value}
</MenuItem> </MenuItem>
))} ))}
</TextField> </TextField>
...@@ -441,7 +408,7 @@ const Activity = () => { ...@@ -441,7 +408,7 @@ const Activity = () => {
<TableBody> <TableBody>
{items.map((row, index) => {items.map((row, index) =>
index === items.length - 1 ? ( index === items.length - 1 ? (
<StyledTableRow key={index} style={{ padding: "1em" }}> <StyledTableRow key={row.created_at} style={{ padding: "1em" }}>
{/* Button to load more data */} {/* Button to load more data */}
<StyledTableCell> <StyledTableCell>
<Button <Button
...@@ -451,16 +418,7 @@ const Activity = () => { ...@@ -451,16 +418,7 @@ const Activity = () => {
startIcon={<AddRoundedIcon />} startIcon={<AddRoundedIcon />}
disabled={isLoadingMoreItems} disabled={isLoadingMoreItems}
onClick={() => { onClick={() => {
currPage++; setCurrPage(currPage + 1)
if (showFilter) {
LoadMoreItens(
Url("activities", `"privacy" : "${option}"`, `${currPage}`, "DESC")
);
} else {
LoadMoreItens(
Url("activities", "", `${currPage}`, "DESC")
);
}
}} }}
> >
{isLoadingMoreItems ? ( {isLoadingMoreItems ? (
......
...@@ -49,10 +49,6 @@ import { Link } from "react-router-dom"; ...@@ -49,10 +49,6 @@ import { Link } from "react-router-dom";
import MobileList from "../../../Components/Components/MobileComponents/SimpleList" import MobileList from "../../../Components/Components/MobileComponents/SimpleList"
import styled from 'styled-components' import styled from 'styled-components'
let currPage = 0;
let currPrivacyFilter = "";
let currNameFilter = "";
const StyledTableCell = withStyles((theme) => ({ const StyledTableCell = withStyles((theme) => ({
head: { head: {
backgroundColor: theme.palette.common.black, backgroundColor: theme.palette.common.black,
...@@ -94,12 +90,13 @@ const Collections = () => { ...@@ -94,12 +90,13 @@ const Collections = () => {
const [isUpdating, setIsUpdating] = useState(false); //controlls the state of updating data const [isUpdating, setIsUpdating] = useState(false); //controlls the state of updating data
const [showFilter, setShowFilter] = useState(false); const [showFilter, setShowFilter] = useState(false);
const [valueOfSearch, setValueOfSearch] = useState("")
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
const [currPage, setCurrPage] = useState(0)
const [openAlertDialog, setOpenAlertDialog] = useState(false); const [openAlertDialog, setOpenAlertDialog] = useState(false);
const [deleteItem, setDeleteItem] = useState({}); //Delete Item const [deleteItem, setDeleteItem] = useState({}); //Delete Item
const [isLoadingToDelete, setIsLoadingToDelete] = useState(null); const [isLoadingToDelete, setIsLoadingToDelete] = useState(null);
const [option, setOption] = useState("Todos os usuários"); //labels of the text field 'to' const [option, setOption] = useState("Todos os usuários"); //labels of the text field 'to'
const [snackInfo, setSnackInfo] = useState({ const [snackInfo, setSnackInfo] = useState({
...@@ -109,17 +106,12 @@ const Collections = () => { ...@@ -109,17 +106,12 @@ const Collections = () => {
color: "", color: "",
}); });
const options = [ const privacyOptions = [
{ { name: "private", value: "Privado" },
value: "private", { name: "public", value: "Público" }
label: "Privado",
},
{
value: "public",
label: "Público",
},
]; ];
//handle snack info //handle snack info
const HandleSnack = (message, state, icon, color) => { const HandleSnack = (message, state, icon, color) => {
setSnackInfo({ setSnackInfo({
...@@ -130,63 +122,11 @@ const Collections = () => { ...@@ -130,63 +122,11 @@ const Collections = () => {
}); });
}; };
//handle load more items
const LoadMoreItens = async (api) => {
setIsLoadingMoreItems(true);
getRequest(
api,
(data, header) => {
const arrData = [...data];
if (arrData.length === 0) {
HandleSnack(
"Não há mais dados para serem carregados",
true,
"warning",
"#FFC125"
);
} else {
const arrItems = [...items];
arrItems.pop(); //Deleting the last position, that was used to display the button of load more items
const arrResult = arrItems.concat(arrData);
setItems(arrResult.concat(ADD_ONE_LENGHT));
}
setIsLoadingMoreItems(false);
},
(error) => {
HandleSnack("Erro ao carregar os dados", true, "warning", "#FA8072");
setIsLoadingMoreItems(false);
}
);
};
//Defines which row must show the circular progress //Defines which row must show the circular progress
const HandleStateCircularProgress = (i) => { const HandleStateCircularProgress = (i) => {
setIsLoadingToDelete(i); setIsLoadingToDelete(i);
}; };
// handle update list data
const UpdateHandler = async (api) => {
setIsUpdating(true);
getRequest(
api,
(data, header) => {
HandleSnack(
"A lista de dados foi atualizada",
true,
"success",
"#228B22"
);
const arrData = [...data];
setItems(arrData.concat(ADD_ONE_LENGHT));
setIsUpdating(false);
},
(error) => {
HandleSnack("Erro ao carregar os dados", true, "warning", "#FA8072");
setIsUpdating(false);
}
);
};
//Called when user want to delete one institution //Called when user want to delete one institution
async function DeleteHandler() { async function DeleteHandler() {
const id = deleteItem.id; const id = deleteItem.id;
...@@ -203,9 +143,8 @@ const Collections = () => { ...@@ -203,9 +143,8 @@ const Collections = () => {
"success", "success",
"#228B22" "#228B22"
); );
currPage = 0; setCurrPage(0)
HandleStateCircularProgress(null); HandleStateCircularProgress(null);
UpdateHandler(Url("collections", "", `${currPage}`, "DESC"));
} }
}, },
(error) => { (error) => {
...@@ -222,57 +161,14 @@ const Collections = () => { ...@@ -222,57 +161,14 @@ const Collections = () => {
setOpenAlertDialog(!openAlertDialog); setOpenAlertDialog(!openAlertDialog);
}; };
const ApplyFilter = (value) => {
currPrivacyFilter = value
currPage = 0;
setIsLoaded(false);
getRequest(
Url(
"collections",
`"privacy" : "${currPrivacyFilter}" , "name" : "${currNameFilter}"`,
`${currPage}`,
"DESC"
),
(data, header) => {
const arrData = [...data];
setItems(arrData.concat(ADD_ONE_LENGHT));
HandleSnack("Filtro aplicado com sucesso", true, "success", "#228B22");
setIsLoaded(true);
},
(error) => {
HandleSnack("Erro ao carregar os dados", true, "warning", "#FA8072");
setIsLoaded(true);
}
);
}
// handle change of privacy // handle change of privacy
const handleChange = (e) => { const handleChange = (e) => {
setOption(e.target.value); setOption(e.target.value);
}; };
//Handle the search filter const HandleSearch = (e) => {
const HandleSearch = (event) => { setValueOfSearch(e.target.value)
currNameFilter = event.target.value
setSearch(currNameFilter);
getRequest(
Url(
"collections",
`"privacy" : "${currPrivacyFilter}" , "name" : "${currNameFilter}"`,
`${currPage}`,
"DESC"
),
(data, header) => {
const arrData = [...data];
setItems(arrData.concat(ADD_ONE_LENGHT));
setIsLoaded(true);
},
(error) => {
HandleSnack("Erro ao carregar os dados", true, "warning", "#FA8072");
setIsLoaded(true);
} }
);
};
const DisplayDate = (date) => { const DisplayDate = (date) => {
const convertedData = moment.utc(date); const convertedData = moment.utc(date);
...@@ -281,35 +177,64 @@ const Collections = () => { ...@@ -281,35 +177,64 @@ const Collections = () => {
.toString(); .toString();
}; };
//getting data from server const buildUrl = (privacyOpt, name) => {
if (privacyOpt && name)
return Url("/collections", `"privacy" : "${privacyOpt}", "name" : "${name}"`, currPage, "DESC")
else if (privacyOpt)
return Url("/collections", `"privacy" : "${privacyOpt}"`, currPage, "DESC")
else if (name)
return Url("/collections", `"name" : "${name}"`, currPage, "DESC")
else
return Url("/collections", "", currPage, "DESC")
}
useEffect(() => { useEffect(() => {
if (currPage === 0)
setIsLoaded(false)
else
setIsLoadingMoreItems(true)
getRequest( getRequest(
Url( buildUrl(option, search),
"collections",
`"privacy" : "${currPrivacyFilter}" , "name" : "${currNameFilter}"`,
`${currPage}`,
"DESC"
),
(data, header) => { (data, header) => {
const arrData = [...data]; const arrData = [...data]
setItems(arrData.concat(ADD_ONE_LENGHT)); if (arrData.length === 0) {
setIsLoaded(true); HandleSnack('Não há mais dados para serem carregados', true, 'warning', '#FFC125')
setError(false); } else {
const arrItems = [...items]
if (currPage === 0) {
setItems(arrData.concat(ADD_ONE_LENGHT))
}
else {
arrItems.pop(); //Deleting the last position, that was used to display the button of load more items
const arrResult = arrItems.concat(arrData)
setItems(arrResult.concat(ADD_ONE_LENGHT))
}
}
setIsLoaded(true)
setIsLoadingMoreItems(false)
}, },
(error) => { (error) => {
HandleSnack("Erro ao carregar os dados", true, "warning", "#FA8072"); HandleSnack('Erro ao carregar os dados', true, 'warning', '#FA8072')
setIsLoaded(false); setIsLoadingMoreItems(false)
setError(true); setIsLoaded(true)
setError(true)
} }
); )
}, []); }, [currPage, search, option])
useEffect(() => {
setCurrPage(0)
setOption()
setSearch("")
setValueOfSearch("")
}, [showFilter])
if (error) { if (error) {
return <div>Error: {error.message}</div>; return <div>Error: {error.message}</div>;
} else if (!isLoaded) { } else if (!isLoaded) {
return <LoadingSpinner text="Carregando..." />; return <LoadingSpinner text="Carregando..." />;
} else { } else {
if (WINDOW_WIDTH <= 954) { if (WINDOW_WIDTH <= 1024) {
return ( return (
<> <>
<SnackBar <SnackBar
...@@ -339,15 +264,7 @@ const Collections = () => { ...@@ -339,15 +264,7 @@ const Collections = () => {
color="secondary" color="secondary"
disabled={isUpdating} disabled={isUpdating}
onClick={() => { onClick={() => {
currPage = 0; setCurrPage(0)
UpdateHandler(
Url(
"collections",
`"privacy" : "${currPrivacyFilter}" , "name" : "${currNameFilter}"`,
`${currPage}`,
"DESC"
)
);
}} }}
startIcon={<UpdateRoundedIcon />} startIcon={<UpdateRoundedIcon />}
> >
...@@ -386,13 +303,17 @@ const Collections = () => { ...@@ -386,13 +303,17 @@ const Collections = () => {
<TextField <TextField
select select
label="Filtro" label="Filtro"
value={option ? option : ""} value={option}
onChange={handleChange} onChange={handleChange}
helperText="Por favor, selecione uma das opções" helperText="Por favor, selecione uma das opções"
> >
{options.map((option, index) => ( {privacyOptions.map((option, index) => (
<MenuItem key={index} value={option.value} onClick={() => { ApplyFilter(option.value) }}> <MenuItem
{option.label} key={option.value}
value={option.name}
name={option.value}
>
{option.value}
</MenuItem> </MenuItem>
))} ))}
</TextField> </TextField>
...@@ -401,8 +322,10 @@ const Collections = () => { ...@@ -401,8 +322,10 @@ const Collections = () => {
<Grid item> <Grid item>
<TextField <TextField
label="Pesquisa" label="Pesquisa"
value={search} value={valueOfSearch}
helperText="Ao digitar, tire o foco do campo de texto"
onChange={(event) => HandleSearch(event)} onChange={(event) => HandleSearch(event)}
onBlur={(event) => setSearch(event.target.value)}
></TextField> ></TextField>
</Grid> </Grid>
</Grid> </Grid>
...@@ -414,24 +337,17 @@ const Collections = () => { ...@@ -414,24 +337,17 @@ const Collections = () => {
{items.map((row, index) => {items.map((row, index) =>
index === items.length - 1 ? ( index === items.length - 1 ? (
<StyledDivButton> <StyledDivButton
key="Load more"
>
<Button <Button
key={index}
color="primary" color="primary"
variant="text" variant="text"
// disabled={isLoadingMoreItems} // disabled={isLoadingMoreItems}
startIcon={<AddRoundedIcon />} startIcon={<AddRoundedIcon />}
disabled={isLoadingMoreItems} disabled={isLoadingMoreItems}
onClick={() => { onClick={() => {
currPage++; setCurrPage(currPage + 1)
LoadMoreItens(
Url(
"collections",
`"privacy" : "${currPrivacyFilter}" , "name" : "${currNameFilter}"`,
`${currPage}`,
"DESC"
)
);
}} }}
> >
{isLoadingMoreItems ? ( {isLoadingMoreItems ? (
...@@ -451,9 +367,7 @@ const Collections = () => { ...@@ -451,9 +367,7 @@ const Collections = () => {
avatar={<PeopleRoundedIcon />} avatar={<PeopleRoundedIcon />}
href={`/admin/Collection/${row.id}`} href={`/admin/Collection/${row.id}`}
reset={() => { reset={() => {
currPage = 0;
currPrivacyFilter = "";
currNameFilter = "";
}} }}
data={ data={
[ [
...@@ -516,15 +430,7 @@ const Collections = () => { ...@@ -516,15 +430,7 @@ const Collections = () => {
color="secondary" color="secondary"
disabled={isUpdating} disabled={isUpdating}
onClick={() => { onClick={() => {
currPage = 0; setCurrPage(0)
UpdateHandler(
Url(
"collections",
`"privacy" : "${currPrivacyFilter}" , "name" : "${currNameFilter}"`,
`${currPage}`,
"DESC"
)
);
}} }}
startIcon={<UpdateRoundedIcon />} startIcon={<UpdateRoundedIcon />}
> >
...@@ -567,9 +473,13 @@ const Collections = () => { ...@@ -567,9 +473,13 @@ const Collections = () => {
onChange={handleChange} onChange={handleChange}
helperText="Por favor, selecione uma das opções" helperText="Por favor, selecione uma das opções"
> >
{options.map((option, index) => ( {privacyOptions.map((option, index) => (
<MenuItem key={index} value={option.value} onClick={() => { ApplyFilter(option.value) }}> <MenuItem
{option.label} key={option.value}
value={option.name}
name={option.value}
>
{option.value}
</MenuItem> </MenuItem>
))} ))}
</TextField> </TextField>
...@@ -578,8 +488,10 @@ const Collections = () => { ...@@ -578,8 +488,10 @@ const Collections = () => {
<Grid item> <Grid item>
<TextField <TextField
label="Pesquisa" label="Pesquisa"
value={search} value={valueOfSearch}
helperText="Ao digitar, tire o foco do campo de texto"
onChange={(event) => HandleSearch(event)} onChange={(event) => HandleSearch(event)}
onBlur={(event) => setSearch(event.target.value)}
></TextField> ></TextField>
</Grid> </Grid>
</Grid> </Grid>
...@@ -593,7 +505,7 @@ const Collections = () => { ...@@ -593,7 +505,7 @@ const Collections = () => {
<TableBody> <TableBody>
{items.map((row, index) => {items.map((row, index) =>
index === items.length - 1 ? ( index === items.length - 1 ? (
<StyledTableRow key={index}> <StyledTableRow key={row.created_at}>
<StyledTableCell> <StyledTableCell>
<Button <Button
key={index} key={index}
...@@ -603,15 +515,7 @@ const Collections = () => { ...@@ -603,15 +515,7 @@ const Collections = () => {
startIcon={<AddRoundedIcon />} startIcon={<AddRoundedIcon />}
disabled={isLoadingMoreItems} disabled={isLoadingMoreItems}
onClick={() => { onClick={() => {
currPage++; setCurrPage(currPage + 1)
LoadMoreItens(
Url(
"collections",
`"privacy" : "${currPrivacyFilter}" , "name" : "${currNameFilter}"`,
`${currPage}`,
"DESC"
)
);
}} }}
> >
{isLoadingMoreItems ? ( {isLoadingMoreItems ? (
...@@ -644,13 +548,7 @@ const Collections = () => { ...@@ -644,13 +548,7 @@ const Collections = () => {
<StyledTableCell align="right">{row.privacy}</StyledTableCell> <StyledTableCell align="right">{row.privacy}</StyledTableCell>
<StyledTableCell align="right"> <StyledTableCell align="right">
<Link to={`/admin/Collection/${row.id}`}> <Link to={`/admin/Collection/${row.id}`}>
<IconButton <IconButton>
onClick={() => {
currPage = 0;
currPrivacyFilter = "";
currNameFilter = "";
}}
>
<VisibilityIcon style={{ fill: "#00bcd4" }} /> <VisibilityIcon style={{ fill: "#00bcd4" }} />
</IconButton> </IconButton>
</Link> </Link>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment