Skip to content

Commit 11c98a6

Browse files
committed
Add Toaster and useToast for notifications
1 parent 3dbc327 commit 11c98a6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

frontend/src/app/signin/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import { Toaster } from "@/components/ui/toaster";
12
import { ReactNode } from "react";
23

34
export default function AuthLayout({ children }: { children: ReactNode }) {
45
return (
56
<>
67
<main>{children}</main>
8+
<Toaster />
79
</>
810
);
911
}

frontend/src/app/signin/page.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { z } from "zod";
1515
import { zodResolver } from "@hookform/resolvers/zod";
1616
import { login } from "@/services/authService";
1717
import { useRouter } from "next/navigation";
18+
import { useToast } from "@/hooks/use-toast";
1819

1920
const FormSchema = z.object({
2021
email: z.string(),
@@ -24,6 +25,8 @@ const FormSchema = z.object({
2425
export default function DashboardPage() {
2526
const router = useRouter();
2627

28+
const { toast } = useToast();
29+
2730
const methods = useForm<z.infer<typeof FormSchema>>({
2831
resolver: zodResolver(FormSchema),
2932
});
@@ -42,12 +45,20 @@ export default function DashboardPage() {
4245
"access_token",
4346
accessTokenResponse.data.access_token
4447
);
48+
toast({
49+
title: "Successfully Logged in!",
50+
description: "You should be redirect to /dashboard",
51+
});
4552
router.push("/dashboard");
4653
} else {
54+
toast({
55+
title: "Error!",
56+
description: accessTokenResponse.message,
57+
});
4758
// TODO: Display error message
4859
}
4960
},
50-
[router]
61+
[router, toast]
5162
);
5263

5364
return (

0 commit comments

Comments
 (0)