fix: email storing

This commit is contained in:
Oleg Proskurin 2025-12-14 15:02:33 +07:00
parent 98d8e31373
commit 77006e8f47
2 changed files with 11 additions and 8 deletions

View File

@ -106,10 +106,9 @@ export function HeroSection() {
} }
setIsInvalid(false); setIsInvalid(false);
const result = await submitEmail(email); // Fire and forget - don't block popup on logging failure
if (result.success) { submitEmail(email).catch(console.error);
setShowPopup(true); setShowPopup(true);
}
}; };
const handlePopupClose = () => { const handlePopupClose = () => {
@ -117,8 +116,9 @@ export function HeroSection() {
setIsSubmitted(true); setIsSubmitted(true);
}; };
const handleWaitlistSubmit = async (data: { selected: string[]; other: string }) => { const handleWaitlistSubmit = (data: { selected: string[]; other: string }) => {
await submitWaitlistData(email, data); // Fire and forget - don't block on logging failure
submitWaitlistData(email, data).catch(console.error);
}; };
return ( return (

View File

@ -22,13 +22,15 @@ function isRateLimited(identifier: string): boolean {
export async function submitEmail(email: string): Promise<{ success: boolean; error?: string }> { export async function submitEmail(email: string): Promise<{ success: boolean; error?: string }> {
try { try {
if (isRateLimited(email)) { if (isRateLimited(email)) {
console.warn('[WAITLIST] Rate limited:', email);
return { success: false, error: 'Too many requests' }; return { success: false, error: 'Too many requests' };
} }
await storeMail(email); await storeMail(email);
console.log('[WAITLIST] Email stored:', email);
return { success: true }; return { success: true };
} catch (error) { } catch (error) {
console.error('Failed to store email:', error); console.error('[WAITLIST] Failed to store email:', email, error);
return { success: false, error: 'Failed to save' }; return { success: false, error: 'Failed to save' };
} }
} }
@ -39,9 +41,10 @@ export async function submitWaitlistData(
): Promise<{ success: boolean; error?: string }> { ): Promise<{ success: boolean; error?: string }> {
try { try {
await updateMail(email, data); await updateMail(email, data);
console.log('[WAITLIST] Data updated:', email, data.selected);
return { success: true }; return { success: true };
} catch (error) { } catch (error) {
console.error('Failed to update waitlist data:', error); console.error('[WAITLIST] Failed to update data:', email, error);
return { success: false, error: 'Failed to save' }; return { success: false, error: 'Failed to save' };
} }
} }