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

Customize Toast with Action Button for Resending Verification on Sign-In Failure #4

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Route, Routes } from "react-router-dom";

import { ForgotPasswordPage } from "@/pages/forgot-password/page";
import { ResetPasswordPage } from "@/pages/reset-password/page";
import { ResendVerifyPage } from "@/pages/resend-verify/page";
import VerifyEmailPage from "@/pages/verify-email/page";
import PrivateGuard from "@/guards/private-guard";
import { AppRoutes } from "@/constants/routes";
Expand All @@ -21,6 +22,7 @@ function App() {
<Route path={AppRoutes.SignUp} element={<SignUpPage />} />
<Route path={AppRoutes.SignIn} element={<SignInPage />} />
<Route path={AppRoutes.VerifyEmail} element={<VerifyEmailPage />} />
<Route path={AppRoutes.ResendVerify} element={<ResendVerifyPage />} />
</Route>
<Route
path={AppRoutes.ForgotPassword}
Expand Down
11 changes: 11 additions & 0 deletions client/src/pages/resend-verify/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { AuthTitle } from "@/components/auth-title";

const ResendVerifyPage = () => {
return (
<section className="px-4 lg:px-0 h-full flex-center flex-col gap-y-6 w-fit mx-auto">
<AuthTitle title="Resend Code" />
</section>
);
};

export { ResendVerifyPage };
19 changes: 17 additions & 2 deletions client/src/pages/sign-in/_components/sign-in-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Input } from "@/components/input";
const SignInForm = () => {
const navigate = useNavigate();
const { setEmail, setAuthorized } = useAuthStore();

const { mutate, isPending } = useMutation({
mutationKey: [SIGNINKEY],
mutationFn: AuthService.signIn,
Expand All @@ -26,7 +25,23 @@ const SignInForm = () => {
setAuthorized(true);
},
onError: (error: ErrorResponse) => {
toast.error("Please verify to sign in");
toast.error("Please verify to sign in. Didn't get the code?", {
className: "gap-x-4",
actionButtonStyle: {
background: "rgb(var(--accent))",
color: "rgb(var(--foreground))",
padding: "16px",
marginLeft: "16px",
filter: `
drop-shadow(0 0px 25px rgb(var(--accent)))
drop-shadow(0 0px 50px rgb(var(--accent)))
`,
},
action: {
label: "Resend",
onClick: () => navigate(AppRoutes.ResendVerify),
},
});

if (error.status == 403) {
navigate(AppRoutes.VerifyEmail);
Expand Down