fix: Handle family data correctly during registration and onboarding
Some checks failed
CI/CD Pipeline / Lint and Test (push) Has been cancelled
CI/CD Pipeline / E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Application (push) Has been cancelled

- Extract family data from registration response and add to user object
- Backend returns family separately in registration, but included in user for login
- Remove error messages for language/measurement preferences (they save correctly)
- Add detailed console logging for debugging family issues
- Improve error message when family is missing during child creation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-03 15:39:04 +00:00
parent 952efa6d37
commit 0dc2fcf284
4 changed files with 94 additions and 58 deletions

View File

@@ -170,7 +170,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
// Backend returns { success, data: { user, family, tokens } }
const { data: responseData } = response.data;
const { tokens, user: userData } = responseData;
const { tokens, user: userData, family: familyData } = responseData;
if (!tokens?.accessToken || !tokens?.refreshToken) {
throw new Error('Invalid response from server');
@@ -178,9 +178,19 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
const { accessToken, refreshToken } = tokens;
// Add family data to user object (registration returns family separately)
const userWithFamily = {
...userData,
families: familyData ? [{
id: familyData.id,
familyId: familyData.id,
role: familyData.role || 'parent',
}] : [],
};
tokenStorage.setTokens(accessToken, refreshToken);
setToken(accessToken);
setUser(userData);
setUser(userWithFamily);
// Redirect to onboarding
router.push('/onboarding');