From 952efa6d37f3ac1ce0a84377394d922d4450e67c Mon Sep 17 00:00:00 2001 From: Andrei Date: Fri, 3 Oct 2025 15:23:02 +0000 Subject: [PATCH] fix: Add missing COPPA fields to registration payload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added dateOfBirth, parentalEmail, and coppaConsentGiven to RegisterData interface - Updated register function to include all required COPPA compliance fields in API payload - Added debug logging to see registration payload - Fixed 400 error during registration due to missing required dateOfBirth field 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- maternal-web/app/track/page.tsx | 30 ++++++++++++++--- .../features/analytics/InsightsDashboard.tsx | 32 +++++++++---------- maternal-web/lib/auth/AuthContext.tsx | 20 ++++++++++-- 3 files changed, 59 insertions(+), 23 deletions(-) diff --git a/maternal-web/app/track/page.tsx b/maternal-web/app/track/page.tsx index dfd515b..6382cc2 100644 --- a/maternal-web/app/track/page.tsx +++ b/maternal-web/app/track/page.tsx @@ -55,9 +55,9 @@ export default function TrackPage() { {t('selectActivity')} - + {trackingOptions.map((option) => ( - + - + {option.icon} - + {option.title} diff --git a/maternal-web/components/features/analytics/InsightsDashboard.tsx b/maternal-web/components/features/analytics/InsightsDashboard.tsx index 20c7253..a970a67 100644 --- a/maternal-web/components/features/analytics/InsightsDashboard.tsx +++ b/maternal-web/components/features/analytics/InsightsDashboard.tsx @@ -363,8 +363,8 @@ export const InsightsDashboard: React.FC = () => { animate={{ opacity: 1, scale: 1 }} transition={{ duration: 0.3, delay: 0 }} > - - + + @@ -388,8 +388,8 @@ export const InsightsDashboard: React.FC = () => { animate={{ opacity: 1, scale: 1 }} transition={{ duration: 0.3, delay: 0.1 }} > - - + + @@ -413,8 +413,8 @@ export const InsightsDashboard: React.FC = () => { animate={{ opacity: 1, scale: 1 }} transition={{ duration: 0.3, delay: 0.2 }} > - - + + @@ -438,8 +438,8 @@ export const InsightsDashboard: React.FC = () => { animate={{ opacity: 1, scale: 1 }} transition={{ duration: 0.3, delay: 0.3 }} > - - + + @@ -461,8 +461,8 @@ export const InsightsDashboard: React.FC = () => { {/* Charts */} - - + + @@ -483,8 +483,8 @@ export const InsightsDashboard: React.FC = () => { - - + + @@ -513,8 +513,8 @@ export const InsightsDashboard: React.FC = () => { {diaperData.length > 0 && ( - - + + @@ -546,8 +546,8 @@ export const InsightsDashboard: React.FC = () => { )} 0 ? 6 : 12}> - - + + diff --git a/maternal-web/lib/auth/AuthContext.tsx b/maternal-web/lib/auth/AuthContext.tsx index 3bcb4d4..03d8498 100644 --- a/maternal-web/lib/auth/AuthContext.tsx +++ b/maternal-web/lib/auth/AuthContext.tsx @@ -28,6 +28,9 @@ export interface RegisterData { password: string; name: string; role?: string; + dateOfBirth: string; // COPPA compliance - required + parentalEmail?: string; // For users 13-17 + coppaConsentGiven?: boolean; // For users 13-17 } interface AuthContextType { @@ -144,13 +147,26 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => { // Auto-detect timezone from user's device const detectedTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; - const response = await apiClient.post('/api/v1/auth/register', { + const payload: any = { email: data.email, password: data.password, name: data.name, timezone: detectedTimezone || 'UTC', + dateOfBirth: data.dateOfBirth, deviceInfo, - }); + }; + + // Add optional COPPA fields if provided + if (data.parentalEmail) { + payload.parentalEmail = data.parentalEmail; + } + if (data.coppaConsentGiven !== undefined) { + payload.coppaConsentGiven = data.coppaConsentGiven; + } + + console.log('[Auth] Registration payload:', JSON.stringify(payload, null, 2)); + + const response = await apiClient.post('/api/v1/auth/register', payload); // Backend returns { success, data: { user, family, tokens } } const { data: responseData } = response.data;