Skip to content

Commit

Permalink
Merge pull request #31 from azeddine-hmd/dev
Browse files Browse the repository at this point in the history
fix bug: pushing instead of refreshing and adding delay for network req
  • Loading branch information
azeddine-hmd authored Jan 8, 2024
2 parents d2f9749 + 854ef77 commit 34de74d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions frontend/app/(auth)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useMutation } from "@tanstack/react-query";
import { api } from "@/config";
import { AxiosError } from "axios";
import { HttpError } from "@/types/http-error";
import { delay } from "@/lib/delay";

type LoginForm = {
email: string;
Expand Down Expand Up @@ -41,10 +42,11 @@ export default function Login() {
});

const loginMut = useMutation({
mutationFn: (form: LoginForm) => {
return api.post("/api/auth/login", { ...form });
mutationFn: async (form: LoginForm) => {
await delay(500);
return await api.post("/api/auth/login", { ...form });
},
onSuccess: () => router.push("/"),
onSuccess: () => window.location.assign("/channels/friends"),
onError: (error: AxiosError) => {
setOnLoading(false);
setError((error.response?.data as HttpError).message);
Expand Down

0 comments on commit 34de74d

Please sign in to comment.