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

Function handleSubmit

src/pages/CompleteProfile.jsx:46–82  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

44 };
45
46 const handleSubmit = async (e) => {
47 e.preventDefault();
48 setLoading(true);
49
50 try {
51 // Validation
52 if (!formData.legalName || !formData.address.street || !formData.address.city ||
53 !formData.address.state || !formData.address.postalCode || !formData.address.country) {
54 throw new Error("Please fill in all profile fields");
55 }
56 // Password validation: Not required if user is already authenticated via session
57 // The backend will handle session-based authentication
58 // if (!formData.password) {
59 // throw new Error("Please enter your password to confirm changes");
60 // }
61
62 const res = await subdomainAPI.post('/auth/email/complete-profile', formData);
63
64 if (res.message) {
65 toast({
66 title: "Profile Updated",
67 description: "Redirecting to verification...",
68 });
69 window.location.href = `/verify-email?email=${encodeURIComponent(formData.email)}`;
70 }
71
72 } catch (err) {
73 console.error(err);
74 toast({
75 variant: "destructive",
76 title: "Update Failed",
77 description: err.message || "Something went wrong",
78 });
79 } finally {
80 setLoading(false);
81 }
82 };
83
84 return (
85 <div className="min-h-screen flex flex-col items-center justify-center bg-[#FFF8F0] px-4 font-sans py-10" style={{ paddingTop: 'var(--incident-height, 0px)' }}>

Callers

nothing calls this directly

Calls 1

toastFunction · 0.50

Tested by

no test coverage detected