Skip to content

Commit

Permalink
params register -> login
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoCampanher committed Aug 7, 2024
1 parent 0cdfe6c commit e5da27e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
import Button from "@/components/Button";
import TextInput from "@/components/TextInput";
import APICaller from "@/utils/APICaller";
import { useRouter } from "next/navigation";
import { useRouter, useSearchParams } from "next/navigation";
import { useState } from "react";
import toast from "react-hot-toast";

export default function Login() {
const [email, setEmail] = useState("");
const params = useSearchParams();
const [email, setEmail] = useState(params.get("email") || "");
const [password, setPassword] = useState("");

const router = useRouter();

async function handleLogin() {
if (!email || !password) {
toast.error("Preencha todos os campos");
return;
}
try {
Expand Down
2 changes: 1 addition & 1 deletion src/app/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Register() {
const response = await APICaller("/api/register", "POST", requestData);
if (response.success) {
toast.success("Registrado com sucesso!");
router.replace("/login");
router.replace(`/login?email=${email}`);
}
response.error && toast.error(response.error);
} catch (error) {
Expand Down

0 comments on commit e5da27e

Please sign in to comment.