diff --git a/src/components/Discover/index.tsx b/src/components/Discover/index.tsx index 74e416f6a..9a4d05c8e 100644 --- a/src/components/Discover/index.tsx +++ b/src/components/Discover/index.tsx @@ -38,7 +38,7 @@ const Discover: React.FC = () => { data: requests, error: requestError, } = useSWR( - '/api/v1/request?filter=unavailable&take=10&sort=modified&skip=0', + '/api/v1/request?filter=all&take=10&sort=modified&skip=0', { revalidateOnMount: true } ); @@ -63,7 +63,7 @@ const Discover: React.FC = () => { ))} />
- + {intl.formatMessage(messages.recentrequests)} { const router = useRouter(); const intl = useIntl(); - const [currentFilter, setCurrentFilter] = useState('pending'); + const [currentFilter, setCurrentFilter] = useState(Filter.PENDING); const [currentSort, setCurrentSort] = useState('added'); const [currentPageSize, setCurrentPageSize] = useState(10); @@ -47,7 +55,12 @@ const RequestList: React.FC = () => { setCurrentSort(filterSettings.currentSort); setCurrentPageSize(filterSettings.currentPageSize); } - }, []); + + // If filter value is provided in query, use that instead + if (Object.values(Filter).includes(router.query.filter as Filter)) { + setCurrentFilter(router.query.filter as Filter); + } + }, [router.query.filter]); // Set filter values to local storage any time they are changed useEffect(() => { @@ -118,6 +131,9 @@ const RequestList: React.FC = () => { +
@@ -167,11 +183,11 @@ const RequestList: React.FC = () => { {intl.formatMessage(globalMessages.noresults)} - {currentFilter !== 'all' && ( + {currentFilter !== Filter.ALL && (