Skip to content

Commit

Permalink
feat(VIL-621): adding new archive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasambry committed Nov 19, 2024
1 parent a81edc7 commit 2b809e2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const BUILD_VERSION = process.env.BUILD_VERSION;

// eslint-disable-next-line no-undef
module.exports = withTM({
env: {
ARCHIVE_MODE: process.env.ARCHIVE_MODE || 'false',

Check failure on line 10 in next.config.js

View workflow job for this annotation

GitHub Actions / lint

'process' is not defined
},
distDir: './dist/next',
poweredByHeader: false,
webpack: (config) => {
Expand Down
13 changes: 11 additions & 2 deletions src/components/accueil/Accueil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,19 @@ export const Accueil = () => {
const router = useRouter();
const [withPagination, setWithPagination] = React.useState(true);

//Check if the app is in archive mode
React.useEffect(() => {
const isArchiveMode = process.env.NEXT_PUBLIC_ARCHIVE_MODE === 'true';
if (isArchiveMode) {
setWithPagination(false);
return;
}

if (!router.isReady) return;
setWithPagination(!('nopagination' in router.query));
}, [router.isReady, router.query]);
const urlParams = new URLSearchParams(window.location.search);
const noPagination = urlParams.has('nopagination');
setWithPagination(!noPagination);
}, [router.isReady]);

//TODO: redo conditions and switchs
const filterCountries = React.useMemo(() => {
Expand Down
10 changes: 9 additions & 1 deletion src/components/activities/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,18 @@ export const Activities = ({ activities, noButtons = false, withLinks = false, w
const [usePagination, setUsePagination] = React.useState(withPagination);

React.useEffect(() => {
const isArchiveMode = process.env.NEXT_PUBLIC_ARCHIVE_MODE === 'true';
if (isArchiveMode) {
setUsePagination(false);
return;
}

if (!router.isReady) {
return;
}
setUsePagination(!('nopagination' in router.query));
const urlParams = new URLSearchParams(window.location.search);
const noPagination = urlParams.has('nopagination');
setUsePagination(!noPagination);
}, [router.isReady, router.query, withPagination]);

React.useEffect(() => {
Expand Down

0 comments on commit 2b809e2

Please sign in to comment.