Skip to content

Commit 6213e64

Browse files
committed
Pass UTM params through on redirect
1 parent d3dc678 commit 6213e64

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

frontend/src/components/routes/auth/Login/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Button, PasswordInput, TextInput, Collapse, UnstyledButton} from "@mantine/core";
2-
import {NavLink} from "react-router";
2+
import {NavLink, useLocation} from "react-router";
33
import {useMutation} from "@tanstack/react-query";
44
import {notifications} from '@mantine/notifications';
55
import {authClient} from "../../../../api/auth.client.ts";
@@ -15,6 +15,7 @@ import {showError} from "../../../../utilites/notifications.tsx";
1515
import {IconTicket, IconChevronDown} from "@tabler/icons-react";
1616

1717
const Login = () => {
18+
const location = useLocation();
1819
const form = useForm({
1920
initialValues: {
2021
email: '',
@@ -80,7 +81,7 @@ const Login = () => {
8081
<p>
8182
<Trans>
8283
Don't have an account?{' '}
83-
<NavLink to={'/auth/register'}>
84+
<NavLink to={`/auth/register${location.search}`}>
8485
Sign up
8586
</NavLink>
8687
</Trans>

frontend/src/components/routes/auth/Register/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const Register = () => {
4343
const registerUser = (data: RegisterAccountRequest) => {
4444
mutate.mutate({registerData: data}, {
4545
onSuccess: () => {
46-
navigate('/welcome');
46+
navigate(`/welcome${location.search}`);
4747
},
4848
onError: (error: any) => {
4949
errorHandler(form, error, error.response?.data?.message);
@@ -67,7 +67,7 @@ export const Register = () => {
6767
<p>
6868
<Trans>
6969
Already have an account?{' '}
70-
<NavLink to={'/auth/login'}>
70+
<NavLink to={`/auth/login${location.search}`}>
7171
{t`Log in`}
7272
</NavLink>
7373
</Trans>

frontend/src/router.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ const Root = () => {
1212

1313
useEffect(() => {
1414
if (me.isFetched) {
15-
setRedirectPath(me.isSuccess ? "/manage/events" : "/auth/login");
15+
const searchParams = typeof window !== 'undefined' ? window.location.search : '';
16+
const basePath = me.isSuccess ? "/manage/events" : "/auth/login";
17+
setRedirectPath(basePath + searchParams);
1618
}
1719
}, [me.isFetched]);
1820

0 commit comments

Comments
 (0)