Skip to content

Commit

Permalink
Merge pull request #4390 from webkom/router-6-bugs
Browse files Browse the repository at this point in the history
Resolve some router-v6 bugs
  • Loading branch information
norbye committed Jan 14, 2024
2 parents 1185b54 + 5044429 commit 2ff0eb1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/reducers/events.ts
Expand Up @@ -321,7 +321,7 @@ export const selectMergedPoolWithRegistrations = createSelector(
pool.permissionGroups
);
const registrations = total.registrations.concat(
pool.registrations.map((regId) => {
pool.registrations?.map((regId) => {
const registration = registrationsById[regId];
return { ...registration, user: usersById[registration.user] };
})
Expand Down
2 changes: 1 addition & 1 deletion app/routes/events/components/EventDetail/index.tsx
Expand Up @@ -212,7 +212,7 @@ const EventDetail = () => {
}

const currentPool = pools.find((pool) =>
pool.registrations.some(
pool.registrations?.some(
(registration) => registration.user?.id === currentUser.id
)
);
Expand Down
13 changes: 9 additions & 4 deletions app/routes/pages/components/PageDetail.tsx
Expand Up @@ -232,8 +232,13 @@ const getSection = (sectionName) =>
fetchItemActions: [],
};

const loadData = async (pageSlug, section, loggedIn, dispatch) => {
const { fetchItemActions } = getSection(section);
const loadData = async (
pageSlug: string | undefined,
sectionName: string | undefined,
loggedIn: boolean,
dispatch
) => {
const { fetchItemActions } = getSection(sectionName);

// Only handle flatpages and groups when user isn't authenticated
if (!loggedIn) {
Expand All @@ -244,7 +249,7 @@ const loadData = async (pageSlug, section, loggedIn, dispatch) => {
return Promise.all([...actionsToDispatch, dispatch(fetchAllPages())]);
}

const itemActions = [];
const itemActions: (typeof dispatch)[] = [];

for (let i = 0; i < fetchItemActions.length; i++) {
itemActions[i] = await dispatch(fetchItemActions[i](pageSlug));
Expand Down Expand Up @@ -298,7 +303,7 @@ const PageDetail = () => {
})
);

const loggedIn = useUserContext();
const { loggedIn } = useUserContext();

const dispatch = useAppDispatch();

Expand Down
2 changes: 1 addition & 1 deletion app/routes/polls/components/PollsList.tsx
Expand Up @@ -40,7 +40,7 @@ const PollsList = () => {
}
/>
<Paginator
hasMore={hasMore}
hasMore={!!hasMore}
fetching={fetching}
fetchNext={() => {
dispatch(
Expand Down
3 changes: 2 additions & 1 deletion app/routes/search/SearchPageWrapper.tsx
@@ -1,7 +1,7 @@
import { usePreparedEffect } from '@webkom/react-prepare';
import { debounce } from 'lodash';
import qs from 'qs';
import { useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import { search } from 'app/actions/SearchActions';
import { Content } from 'app/components/Content';
import SearchPage from 'app/components/Search/SearchPage';
Expand All @@ -11,6 +11,7 @@ import { useAppDispatch, useAppSelector } from 'app/store/hooks';
const SearchPageWrapper = () => {
const results = useAppSelector((state) => selectResult(state));

const location = useLocation();
const query = qs.parse(location.search, {
ignoreQueryPrefix: true,
}).q;
Expand Down
3 changes: 2 additions & 1 deletion app/routes/userValidator/WrappedValidator.tsx
@@ -1,6 +1,6 @@
import { debounce } from 'lodash';
import qs from 'qs';
import { useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import { autocomplete } from 'app/actions/SearchActions';
import { fetchUser } from 'app/actions/UserActions';
import { Content } from 'app/components/Content';
Expand All @@ -14,6 +14,7 @@ const searchTypes = ['users.user'];
const WrappedValidator = () => {
const navigate = useNavigate();
const dispatch = useAppDispatch();
const location = useLocation();

const clearSearch = () =>
navigate(`/validator?${qs.stringify({ ...search, q: '' })}`);
Expand Down

0 comments on commit 2ff0eb1

Please sign in to comment.