Skip to content

Commit

Permalink
join: Navigate to game upon login during game join.
Browse files Browse the repository at this point in the history
  • Loading branch information
sethdivyansh authored and kuv2707 committed Jun 29, 2024
1 parent 54c2f84 commit 5460f7f
Showing 1 changed file with 5 additions and 3 deletions.
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

0 comments on commit 5460f7f

Please sign in to comment.