|
1 | | -import LogoutButton from "@/components/Logout"; |
| 1 | +import { View, Text, ScrollView, ActivityIndicator } from "react-native"; |
| 2 | +import { SafeAreaView } from "react-native-safe-area-context"; |
| 3 | +import { useAuth } from "@clerk/clerk-expo"; |
2 | 4 | import { router } from "expo-router"; |
3 | | -import { View } from "react-native"; |
| 5 | +import { useGetUser } from "@shared"; |
| 6 | +import LogoutButton from "@/components/Logout"; |
| 7 | +import { ProfileHero } from "@/components/profile/ProfileHero"; |
| 8 | +import { ProfileInfoCard } from "@/components/profile/ProfileInfoCard"; |
4 | 9 |
|
5 | 10 | export default function Profile() { |
| 11 | + const { userId } = useAuth(); |
| 12 | + const { data: user, isLoading } = useGetUser(userId ?? undefined); |
| 13 | + |
6 | 14 | const onSignOut = () => { |
7 | 15 | router.replace("/sign-in"); |
8 | 16 | }; |
9 | 17 |
|
| 18 | + const firstName = user?.first_name ?? ""; |
| 19 | + const lastName = user?.last_name ?? ""; |
| 20 | + const displayName = [firstName, lastName].filter(Boolean).join(" ") || "User"; |
| 21 | + |
10 | 22 | return ( |
11 | | - <View className="flex-1 justify-center px-6"> |
12 | | - <LogoutButton onSignOut={onSignOut} /> |
13 | | - </View> |
| 23 | + <SafeAreaView className="flex-1 bg-bg-primary" edges={["top"]}> |
| 24 | + <View className="px-4 py-4 border-b border-stroke-subtle"> |
| 25 | + <Text className="text-2xl font-semibold text-text-default"> |
| 26 | + Profile |
| 27 | + </Text> |
| 28 | + <Text className="text-sm text-text-subtle">Overview of profile</Text> |
| 29 | + </View> |
| 30 | + |
| 31 | + {isLoading ? ( |
| 32 | + <View className="flex-1 items-center justify-center"> |
| 33 | + <ActivityIndicator size="large" /> |
| 34 | + </View> |
| 35 | + ) : ( |
| 36 | + <ScrollView className="flex-1" contentContainerClassName="pb-12"> |
| 37 | + <ProfileHero |
| 38 | + firstName={firstName} |
| 39 | + lastName={lastName} |
| 40 | + avatarUrl={user?.profile_picture ?? undefined} |
| 41 | + /> |
| 42 | + <ProfileInfoCard |
| 43 | + governmentName={displayName} |
| 44 | + email={user?.primary_email ?? "—"} |
| 45 | + phoneNumber={user?.phone_number ?? "—"} |
| 46 | + department={user?.department ?? "—"} |
| 47 | + /> |
| 48 | + <View className="px-4 mt-8"> |
| 49 | + <LogoutButton onSignOut={onSignOut} /> |
| 50 | + </View> |
| 51 | + </ScrollView> |
| 52 | + )} |
| 53 | + </SafeAreaView> |
14 | 54 | ); |
15 | 55 | } |
0 commit comments