Skip to content

Commit

Permalink
Fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Archinowsk committed Dec 15, 2024
1 parent f739bb5 commit dc5ea0d
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 18 deletions.
7 changes: 4 additions & 3 deletions client/src/components/KompassiLoginCallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useNavigate, useSearchParams } from "react-router";
import { submitKompassiLogin } from "client/views/login/loginThunks";
import { useAppDispatch } from "client/utils/hooks";
import { Loading } from "client/components/Loading";
import { AppRoute } from "client/app/AppRoutes";

export const KompassiLoginCallback = (): ReactElement => {
const dispatch = useAppDispatch();
Expand All @@ -18,15 +19,15 @@ export const KompassiLoginCallback = (): ReactElement => {
if (code) {
const errorMessage = await dispatch(submitKompassiLogin(code));
if (errorMessage) {
navigate(`/login?error=${errorMessage}`);
await navigate(`${AppRoute.LOGIN}?error=${errorMessage}`);
return;
}
}
if (error) {
navigate(`/login`);
await navigate(AppRoute.LOGIN);
return;
}
navigate(`/`);
await navigate(AppRoute.ROOT);
};
// eslint-disable-next-line @typescript-eslint/no-floating-promises
fetchData();
Expand Down
3 changes: 2 additions & 1 deletion client/src/utils/navigation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NavigateFunction } from "react-router";
import { AppRoute } from "client/app/AppRoutes";

// Navigate to previous page or front page if no previous page exists
export const navigateToPreviousOrRoot = async (
Expand All @@ -9,5 +10,5 @@ export const navigateToPreviousOrRoot = async (
if (history.state?.idx > 0) {
await navigate(-1);
}
await navigate("/");
await navigate(AppRoute.ROOT);
};
7 changes: 6 additions & 1 deletion client/src/views/login/LoginView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useAppSelector } from "client/utils/hooks";
import { LoginProvider } from "shared/config/eventConfigTypes";
import { KompassiLogin } from "client/views/login/components/KompassiLogin";
import { Button, ButtonStyle } from "client/components/Button";
import { AppRoute } from "client/app/AppRoutes";

export const LoginView = (): ReactElement => {
const { t } = useTranslation();
Expand All @@ -19,8 +20,12 @@ export const LoginView = (): ReactElement => {
const adminLogin = location.pathname === "/admin/login";

useEffect(() => {
const navigateToRoot = async (): Promise<void> => {
await navigate(AppRoute.ROOT);
};
if (loggedIn) {
navigate("/");
// eslint-disable-next-line @typescript-eslint/no-floating-promises
navigateToRoot();
}
}, [loggedIn, navigate]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from "client/views/my-program-items/components/shared";
import { ErrorMessage } from "client/components/ErrorMessage";
import { InfoText, InfoTextVariant } from "client/components/InfoText";
import { AppRoute } from "client/app/AppRoutes";

interface Props {
signup: Signup;
Expand Down Expand Up @@ -113,17 +114,19 @@ export const DirectSignupItem = ({
<StyledButtonContainer>
<TertiaryButton
icon="circle-arrow-right"
onClick={() => {
navigate(`/program/item/${signup.programItem.programItemId}`);
onClick={async () => {
await navigate(
`${AppRoute.PROGRAM_ITEM}/${signup.programItem.programItemId}`,
);
}}
>
{t("button.showInfo")}
</TertiaryButton>
<TertiaryButton
icon="ticket"
onClick={() => {
navigate(
`/program/item/${signup.programItem.programItemId}/admission`,
onClick={async () => {
await navigate(
`${AppRoute.PROGRAM_ITEM}/${signup.programItem.programItemId}/admission`,
);
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
MyProgramListItem,
MyProgramTime,
} from "client/views/my-program-items/components/shared";
import { AppRoute } from "client/app/AppRoutes";

interface Props {
programItems: readonly ProgramItem[];
Expand Down Expand Up @@ -62,9 +63,9 @@ export const FavoritesByStartTimes = ({
<MyProgramButtonContainer>
<TertiaryButton
icon="circle-arrow-right"
onClick={() => {
navigate(
`/program/item/${programItem.programItemId}`,
onClick={async () => {
await navigate(
`${AppRoute.PROGRAM_ITEM}/${programItem.programItemId}`,
);
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
MyProgramTime,
} from "client/views/my-program-items/components/shared";
import { TertiaryButton } from "client/components/TertiaryButton";
import { AppRoute } from "client/app/AppRoutes";

interface Props {
lotterySignups: Signup[];
Expand Down Expand Up @@ -54,9 +55,9 @@ export const LotterySignupsByStartTimes = ({
<StyledButtons>
<TertiaryButton
icon="circle-arrow-right"
onClick={() => {
navigate(
`/program/item/${signup.programItem.programItemId}`,
onClick={async () => {
await navigate(
`${AppRoute.PROGRAM_ITEM}/${signup.programItem.programItemId}`,
);
}}
>
Expand Down
3 changes: 2 additions & 1 deletion client/src/views/profile/ProfileView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ChangePasswordForm } from "client/views/helper/components/ChangePasswor
import { useAppSelector } from "client/utils/hooks";
import { Button, ButtonStyle } from "client/components/Button";
import { LoginProvider } from "shared/config/eventConfigTypes";
import { AppRoute } from "client/app/AppRoutes";

export const ProfileView = (): ReactElement => {
const { t } = useTranslation();
Expand All @@ -30,7 +31,7 @@ export const ProfileView = (): ReactElement => {
)}
<StyledButton
buttonStyle={ButtonStyle.SECONDARY}
onClick={() => navigate("/logout")}
onClick={() => navigate(AppRoute.LOGOUT)}
>
{t("button.logout")}
</StyledButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NavLink } from "react-router";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import { Button, ButtonStyle } from "client/components/Button";
import { AppRoute } from "client/app/AppRoutes";

interface Props {
programItemId: string;
Expand All @@ -11,7 +12,7 @@ export const AdmissionTicketLink = ({ programItemId }: Props): ReactElement => {
const { t } = useTranslation();

return (
<StyledLink to={`/program/item/${programItemId}/admission`}>
<StyledLink to={`${AppRoute.PROGRAM_ITEM}/${programItemId}/admission`}>
<StyledButton buttonStyle={ButtonStyle.PRIMARY}>
{t("button.showAdmissionTicket")}
</StyledButton>
Expand Down

0 comments on commit dc5ea0d

Please sign in to comment.