diff --git a/web/src/layout/explore/cardCategory/Content.tsx b/web/src/layout/explore/cardCategory/Content.tsx
index d8fa099a..d43930ab 100644
--- a/web/src/layout/explore/cardCategory/Content.tsx
+++ b/web/src/layout/explore/cardCategory/Content.tsx
@@ -1,11 +1,13 @@
import { orderBy } from 'lodash';
-import { useNavigate, useOutletContext } from 'react-router-dom';
+import { useContext } from 'react';
+import { useNavigate } from 'react-router-dom';
import { Waypoint } from 'react-waypoint';
-import { BaseItem, CardMenu, Item, OutletContext } from '../../../types';
+import { BaseItem, CardMenu, Item } from '../../../types';
import convertStringSpaces from '../../../utils/convertStringSpaces';
import isElementInView from '../../../utils/isElementInView';
import { CategoriesData } from '../../../utils/prepareData';
+import { AppContext, Context } from '../../context/AppContext';
import Card from './Card';
import styles from './Content.module.css';
@@ -16,7 +18,7 @@ interface Props {
}
const Content = (props: Props) => {
const navigate = useNavigate();
- const { updateActiveItemId } = useOutletContext() as OutletContext;
+ const { updateActiveItemId } = useContext(AppContext) as Context;
const sortItems = (firstCategory: string, firstSubcategory: string): BaseItem[] => {
return orderBy(
diff --git a/web/src/layout/explore/cardCategory/index.tsx b/web/src/layout/explore/cardCategory/index.tsx
index 6a76a8cb..bb5aa4c7 100644
--- a/web/src/layout/explore/cardCategory/index.tsx
+++ b/web/src/layout/explore/cardCategory/index.tsx
@@ -1,5 +1,5 @@
import { isEqual, isUndefined } from 'lodash';
-import { memo, useEffect, useLayoutEffect, useState } from 'react';
+import { memo, useContext, useEffect, useLayoutEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { CardMenu } from '../../../types';
@@ -10,13 +10,13 @@ import { SubcategoryDetails } from '../../../utils/gridCategoryLayout';
import isElementInView from '../../../utils/isElementInView';
import { CategoriesData } from '../../../utils/prepareData';
import { Loading } from '../../common/Loading';
+import { AppContext, Context } from '../../context/AppContext';
import ButtonToTopScroll from './ButtonToTopScroll';
import Content from './Content';
import Menu from './Menu';
interface Props {
isVisible: boolean;
- fullDataReady: boolean;
data: CategoriesData;
categories_overridden?: string[];
}
@@ -24,6 +24,7 @@ interface Props {
const TITLE_OFFSET = 16;
const CardCategory = memo(function CardCategory(props: Props) {
+ const { fullDataReady } = useContext(AppContext) as Context;
const navigate = useNavigate();
const [menu, setMenu] = useState
();
const [initialFullRender, setInitialFullRender] = useState(false);
@@ -101,7 +102,7 @@ const CardCategory = memo(function CardCategory(props: Props) {
}
};
- if (props.isVisible && menu && props.fullDataReady) {
+ if (props.isVisible && menu && fullDataReady) {
const firstItem = getFirstItem();
if (firstItem) {
if (initialFullRender) {
@@ -127,7 +128,7 @@ const CardCategory = memo(function CardCategory(props: Props) {
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [menu, props.isVisible, props.fullDataReady]);
+ }, [menu, props.isVisible, fullDataReady]);
if (isUndefined(menu)) return null;
@@ -135,7 +136,7 @@ const CardCategory = memo(function CardCategory(props: Props) {
- {props.fullDataReady ? : }
+ {fullDataReady ? : }
diff --git a/web/src/layout/explore/gridCategory/Grid.module.css b/web/src/layout/explore/gridCategory/Grid.module.css
index 61fb59c2..190f3f56 100644
--- a/web/src/layout/explore/gridCategory/Grid.module.css
+++ b/web/src/layout/explore/gridCategory/Grid.module.css
@@ -18,5 +18,4 @@
grid-template-columns: repeat(auto-fit, var(--card-size-width));
grid-auto-rows: var(--card-size-height);
gap: var(--card-gap);
- /* justify-content: center; */
}
diff --git a/web/src/layout/explore/gridCategory/Grid.tsx b/web/src/layout/explore/gridCategory/Grid.tsx
index 7b5f44ab..5be22576 100644
--- a/web/src/layout/explore/gridCategory/Grid.tsx
+++ b/web/src/layout/explore/gridCategory/Grid.tsx
@@ -1,6 +1,6 @@
import classNames from 'classnames';
-import { isUndefined, sortBy } from 'lodash';
-import { memo, useEffect, useState } from 'react';
+import { isUndefined } from 'lodash';
+import { memo, useContext, useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { BaseItem, Item, SVGIconKind } from '../../../types';
@@ -13,7 +13,9 @@ import getGridCategoryLayout, {
transformGridLayout,
} from '../../../utils/gridCategoryLayout';
import { SubcategoryData } from '../../../utils/prepareData';
+import sortItemsByOrderValue from '../../../utils/sortItemsByOrderValue';
import SVGIcon from '../../common/SVGIcon';
+import { AppContext, Context } from '../../context/AppContext';
import styles from './Grid.module.css';
import GridItem from './GridItem';
@@ -29,12 +31,9 @@ interface Props {
}
const Grid = memo(function Grid(props: Props) {
+ const { updateActiveSection } = useContext(AppContext) as Context;
const [grid, setGrid] = useState();
- const sortItems = (items: BaseItem[]): BaseItem[] => {
- return sortBy(items, ['featured.order']);
- };
-
useEffect(() => {
if (props.containerWidth > 0) {
setGrid(
@@ -68,8 +67,8 @@ const Grid = memo(function Grid(props: Props) {
{row.map((subcat: LayoutColumn) => {
if (props.categoryData[subcat.subcategoryName].items.length === 0) return null;
- const sortedItems: (BaseItem | Item)[] = sortItems(
- sortItems(props.categoryData[subcat.subcategoryName].items)
+ const sortedItems: (BaseItem | Item)[] = sortItemsByOrderValue(
+ props.categoryData[subcat.subcategoryName].items
);
return (
@@ -92,16 +91,38 @@ const Grid = memo(function Grid(props: Props) {
+
+
+
+