MCPcopy
hub / github.com/stackryze/FreeDomains / handleSubmit

Function handleSubmit

src/pages/ForgotPassword.jsx:16–52  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

14 const { toast } = useToast();
15
16 const handleSubmit = async (e) => {
17 e.preventDefault();
18
19 if (!captchaToken) {
20 toast({
21 variant: "destructive",
22 title: "Verification Required",
23 description: "Please complete the CAPTCHA verification.",
24 });
25 return;
26 }
27
28 setIsLoading(true);
29 try {
30 await subdomainAPI.post('/auth/email/forgot-password', {
31 email,
32 captchaToken
33 });
34
35 // Show success toast
36 toast({
37 title: "Code Sent!",
38 description: "Check your inbox for the reset code.",
39 });
40
41 // Navigate to reset password page with email pre-filled
42 navigate(`/reset-password?email=${encodeURIComponent(email)}`);
43 } catch (err) {
44 toast({
45 variant: "destructive",
46 title: "Error",
47 description: err.response?.data?.error || "Failed to send reset code.",
48 });
49 } finally {
50 setIsLoading(false);
51 }
52 };
53
54 return (
55 <>

Callers

nothing calls this directly

Calls 1

toastFunction · 0.50

Tested by

no test coverage detected