Skip to content

Commit

Permalink
Fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
vhande committed Nov 8, 2024
1 parent 32f93ab commit cfb6326
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/hooks/useLegacyPath.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,30 @@ const useLegacyPath = () => {
const { publicRuntimeConfig } = getConfig();
const prefixWhenNotEmpty = (value, prefix) =>
value ? `${prefix}${value}` : value;
const {
// eslint-disable-next-line no-unused-vars
query: { params = [], ...queryWithoutParams },
asPath,
} = router;

const jwt = cookies.token;
const lang = cookies['udb-language'];

const legacyPath = useMemo(() => {
const path = new URL(`http://localhost${asPath}`).pathname;
const ownershipPaths =
router.asPath.startsWith('/organizer') &&
!router.asPath.endsWith('/ownerships');
const path = new URL(`http://localhost${router.asPath}`).pathname;
const { params = [], ...queryWithoutParams } = router.query;
const queryString = prefixWhenNotEmpty(
new URLSearchParams({
...queryWithoutParams,
jwt: cookies.token,
lang: cookies['udb-language'],
...(ownershipPaths &&
publicRuntimeConfig.ownershipEnabled === 'true' && {
ownership: 'true',
}),
jwt,
lang,
}),
'?',
);

return `${publicRuntimeConfig.legacyAppUrl}${path}${queryString}`;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [asPath, cookies.token, cookies['udb-language']]);
}, [
router.asPath,
router.query,
jwt,
lang,
publicRuntimeConfig.legacyAppUrl,
]);

return legacyPath;
};
Expand Down

0 comments on commit cfb6326

Please sign in to comment.