forked from agentic-review-benchmarks/cal.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile-sheet.tsx
More file actions
191 lines (182 loc) · 6.02 KB
/
profile-sheet.tsx
File metadata and controls
191 lines (182 loc) · 6.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import { Ionicons } from "@expo/vector-icons";
import * as Clipboard from "expo-clipboard";
import * as Haptics from "expo-haptics";
import { Stack, useRouter } from "expo-router";
import { ActivityIndicator, Image, ScrollView, Text, TouchableOpacity, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { HeaderButtonWrapper } from "@/components/HeaderButtonWrapper";
import { useUserProfile } from "@/hooks";
import { showSuccessAlert } from "@/utils/alerts";
import { openInAppBrowser } from "@/utils/browser";
import { getAvatarUrl } from "@/utils/getAvatarUrl";
interface ProfileMenuItem {
id: string;
label: string;
icon: keyof typeof Ionicons.glyphMap;
onPress: () => void;
external?: boolean;
}
export default function ProfileSheet() {
const router = useRouter();
const insets = useSafeAreaInsets();
const { data: userProfile, isLoading } = useUserProfile();
const publicPageUrl = userProfile?.username ? `https://cal.com/${userProfile.username}` : null;
const menuItems: ProfileMenuItem[] = [
{
id: "profile",
label: "My Profile",
icon: "person-outline",
onPress: () =>
openInAppBrowser("https://app.cal.com/settings/my-account/profile", "Profile page"),
external: true,
},
{
id: "settings",
label: "My Settings",
icon: "settings-outline",
onPress: () =>
openInAppBrowser("https://app.cal.com/settings/my-account/general", "Settings page"),
external: true,
},
{
id: "outOfOffice",
label: "Out of Office",
icon: "moon-outline",
onPress: () =>
openInAppBrowser(
"https://app.cal.com/settings/my-account/out-of-office",
"Out of Office page"
),
external: true,
},
{
id: "publicPage",
label: "View public page",
icon: "globe-outline",
onPress: () => {
if (publicPageUrl) openInAppBrowser(publicPageUrl, "Public page");
},
external: true,
},
{
id: "copyPublicPage",
label: "Copy public page link",
icon: "copy-outline",
onPress: async () => {
if (publicPageUrl) {
await Clipboard.setStringAsync(publicPageUrl);
await Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
showSuccessAlert("Copied!", "Public page link copied to clipboard");
}
},
external: false,
},
{
id: "roadmap",
label: "Roadmap",
icon: "map-outline",
onPress: () => openInAppBrowser("https://cal.com/roadmap", "Roadmap page"),
external: true,
},
{
id: "help",
label: "Help",
icon: "help-circle-outline",
onPress: () => openInAppBrowser("https://cal.com/help", "Help page"),
external: true,
},
];
const handleClose = () => {
router.back();
};
return (
<>
<Stack.Screen
options={{
headerShown: true,
title: "Profile",
presentation: "modal",
contentStyle: {
backgroundColor: "#FFFFFF",
},
headerStyle: {
backgroundColor: "#FFFFFF",
},
headerLeft: () => null,
headerRight: () => (
<HeaderButtonWrapper side="right">
<TouchableOpacity onPress={handleClose} style={{ padding: 8 }}>
<Ionicons name="close" size={24} color="#000" />
</TouchableOpacity>
</HeaderButtonWrapper>
),
}}
/>
<ScrollView
style={{ flex: 1, backgroundColor: "#FFFFFF" }}
contentContainerStyle={{ paddingBottom: insets.bottom + 20 }}
>
{/* Profile Header */}
<View className="px-6 py-6">
{isLoading ? (
<View className="items-center py-8">
<ActivityIndicator size="large" color="#000" />
</View>
) : (
<View className="flex-row items-center">
{/* Avatar */}
{userProfile?.avatarUrl ? (
<Image
source={{ uri: getAvatarUrl(userProfile.avatarUrl) }}
style={{ width: 64, height: 64, borderRadius: 32 }}
/>
) : (
<View
className="items-center justify-center rounded-full bg-gray-200"
style={{ width: 64, height: 64 }}
>
<Text className="text-2xl font-semibold text-gray-600">
{userProfile?.name?.charAt(0).toUpperCase() ||
userProfile?.email?.charAt(0).toUpperCase() ||
"?"}
</Text>
</View>
)}
{/* Name and Email */}
<View className="ml-4 flex-1">
<Text className="text-xl font-semibold text-gray-900">
{userProfile?.name || "User"}
</Text>
{userProfile?.email ? (
<Text className="mt-1 text-sm text-gray-500">{userProfile.email}</Text>
) : null}
</View>
</View>
)}
</View>
{/* Menu Items */}
<View className="px-2 py-4">
{menuItems.map((item, index) => (
<TouchableOpacity
key={item.id}
className={`flex-row items-center justify-between rounded-xl px-4 py-4 active:bg-gray-100 ${
index < menuItems.length - 1 ? "mb-1" : ""
}`}
onPress={item.onPress}
>
<View className="flex-row items-center">
<Ionicons name={item.icon} size={22} color="#374151" />
<Text className="ml-4 text-base text-gray-900">{item.label}</Text>
</View>
{item.external ? (
<Ionicons name="open-outline" size={18} color="#9CA3AF" />
) : (
<Ionicons name="chevron-forward" size={18} color="#9CA3AF" />
)}
</TouchableOpacity>
))}
</View>
</ScrollView>
</>
);
}