Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

join: Navigate to game upon login during game join. #175

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions frontend/src/pages/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import Button from '../library/button';
import Input from '../library/input';
import { Link, useNavigate } from 'react-router-dom';
import { Link, useLocation, useNavigate } from 'react-router-dom';
import { useAuth } from '../contexts/AuthContext';
import '../index.css';

Expand All @@ -10,6 +10,7 @@ const Login: React.FC = () => {
const [password, setPassword] = useState('');
const auth = useAuth();
const navigate = useNavigate();
const location = useLocation();

const handleUsernameChange = (
event: React.ChangeEvent<HTMLInputElement>
Expand All @@ -27,8 +28,9 @@ const Login: React.FC = () => {
event.preventDefault();
console.log('Form submitted');
await auth.authenticate(username, password);
//todo: Check query params for a join game link
navigate('/');
//Check query params for a join game link
const navigateTo = location.search;
navigateTo ? navigate(navigateTo) : navigate('/');
};

return (
Expand Down
Loading