Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #12: Build profile viewing and validated data layer.
New files:
src/features/profile/api/profile.types.ts- Profile types.src/features/profile/api/profile.schema.ts- Zod schema for validating the backend profile response.src/features/profile/api/profile.mapper.ts- Maps backend data to Profile and parseProfile as the shared entry point for validation and mapping.src/features/profile/api/profile.errors.ts- Network, invalid data, and session expired errors.src/features/profile/api/profile.gateway.ts- ProfileGateway interface.src/features/profile/api/fakeProfileGateway.ts- Fake gateway with student, mentor, missing-data, failure, invalid-data, and session-expired scenarios, and failTimes for retry testing. Sample data is clearly fake (sample.*,.invalidemail).src/features/profile/api/ApiProfileGateway.ts- Structure for a future ApiProfileGateway.src/features/profile/api/gatewayProvider.ts- Exports the gateway the app uses (currently the fake).src/features/profile/hooks/useProfile.ts- TanStack Query hook that loads the profile through the gateway.test/profile.schema.test.ts,test/profile.mapper.test.ts,test/fakeProfileGateway.test.ts,test/ProfileScreen.test.tsx- Tests for the new code.Updated files:
app/(app)/(tabs)/profile.tsx- Name and role now come fromuseProfileinstead of the session. Added a "Profile" details card (username, role, school, grade level, location). Missing values show "Not provided", and location is omitted when unavailable. Added loading, error (with retry), invalid-data, and expired-session states. Sign Out works in every state. Stats, badges, and menu rows remain the visual mock.test/navigation.test.tsx- The profile assertion now expects the fake gateway's name ("Sample Student") instead of the old hardcoded session name ("Mock Student").The screen calls
useProfile(), which calls theProfileGateway, and the gateway validates the data with Zod and converts it with the mapper. Connecting the real gateway later is a change ingatewayProvider.tsandApiProfileGateway.ts.Screenshots
Student Profile




Mentor Profile
Profile with missing data
Loading screen
Tests
Run the new tests with: npm run test -- ./test/ProfileScreen.test.tsx ./test/profile.schema.test.ts ./test/profile.mapper.test.ts ./test/fakeProfileGateway.test.ts




This should be result: