Added condition to filter by user and likes when unauthorized

This commit is contained in:
Lucas Oliveira 2023-11-16 12:09:56 -03:00
commit 219d8803b8

View file

@ -23,7 +23,7 @@ import { storeComponent } from "../../types/store";
import { cn } from "../../utils/utils"; import { cn } from "../../utils/utils";
import { MarketCardComponent } from "./components/market-card"; import { MarketCardComponent } from "./components/market-card";
export default function StorePage(): JSX.Element { export default function StorePage(): JSX.Element {
const { errorApiKey, hasApiKey } = useContext(StoreContext); const { errorApiKey, hasApiKey, setHasApiKey } = useContext(StoreContext);
const { setErrorData } = useContext(alertContext); const { setErrorData } = useContext(alertContext);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [loadingTags, setLoadingTags] = useState(true); const [loadingTags, setLoadingTags] = useState(true);
@ -52,6 +52,7 @@ export default function StorePage(): JSX.Element {
pageSize, pageSize,
filteredCategories, filteredCategories,
selectFilter, selectFilter,
hasApiKey,
]); ]);
function handleGetTags() { function handleGetTags() {
@ -70,12 +71,13 @@ export default function StorePage(): JSX.Element {
tabActive === "All" ? null : tabActive === "Flows" ? false : true, tabActive === "All" ? null : tabActive === "Flows" ? false : true,
pageOrder === "Popular" ? "-count(downloads)" : "name", pageOrder === "Popular" ? "-count(downloads)" : "name",
filteredCategories, filteredCategories,
selectFilter === "likedbyme" ? true : null, selectFilter === "likedbyme" && hasApiKey ? true : null,
null, null,
searchText === "" ? null : searchText, searchText === "" ? null : searchText,
selectFilter === "createdbyme" ? true : null selectFilter === "createdbyme" && hasApiKey ? true : null
) )
.then((res) => { .then((res) => {
setHasApiKey(res?.authorized ?? false);
setLoading(false); setLoading(false);
setSearchData(res?.results ?? []); setSearchData(res?.results ?? []);
setTotalRowsCount( setTotalRowsCount(