219 lines
5.5 KiB
TypeScript
219 lines
5.5 KiB
TypeScript
import React from "react";
|
|
import {
|
|
Alert,
|
|
Platform,
|
|
ScrollView,
|
|
StyleSheet,
|
|
View,
|
|
Text,
|
|
TouchableOpacity,
|
|
} from "react-native";
|
|
import { SafeAreaView } from "react-native-safe-area-context";
|
|
import {
|
|
moderateScale,
|
|
verticalScale,
|
|
} from "react-native-size-matters";
|
|
import { router } from "expo-router";
|
|
import { Ionicons } from "@expo/vector-icons";
|
|
|
|
import { Colors } from "@/theme";
|
|
import ProfileHeader from "@/features/profile/components/ProfileHeader";
|
|
import ProfileAvatar from "@/features/profile/components/ProfileAvatar";
|
|
import ProfileOverviewCard from "@/features/profile/components/ProfileOverviewCard";
|
|
import LogoutButton from "@/features/settings/components/LogoutButton";
|
|
import { useAuthStore } from "@/store/auth.store";
|
|
|
|
export default function ProfileOverviewScreen() {
|
|
const { user, accessToken, logout } = useAuthStore();
|
|
const displayName = user?.name || "User Name";
|
|
const displayEmail = user?.email || "user@example.com";
|
|
|
|
const handleLogout = () => {
|
|
const doLogout = () => {
|
|
logout();
|
|
router.replace("/login");
|
|
};
|
|
|
|
if (Platform.OS === "web") {
|
|
const confirmed =
|
|
typeof window !== "undefined"
|
|
? window.confirm("Are you sure you want to log out?")
|
|
: true;
|
|
if (confirmed) {
|
|
doLogout();
|
|
}
|
|
} else {
|
|
Alert.alert(
|
|
"Log Out",
|
|
"Are you sure you want to log out of Acupedia?",
|
|
[
|
|
{ text: "Cancel", style: "cancel" },
|
|
{
|
|
text: "Log Out",
|
|
style: "destructive",
|
|
onPress: doLogout,
|
|
},
|
|
],
|
|
{ cancelable: true }
|
|
);
|
|
}
|
|
};
|
|
|
|
if (!accessToken) {
|
|
return (
|
|
<SafeAreaView style={styles.safeArea}>
|
|
<ScrollView
|
|
showsVerticalScrollIndicator={false}
|
|
contentContainerStyle={styles.guestContentContainer}
|
|
>
|
|
<View style={styles.guestCard}>
|
|
<View style={styles.guestIconWrapper}>
|
|
<Ionicons
|
|
name="person-circle-outline"
|
|
size={80}
|
|
color={Colors.primary}
|
|
/>
|
|
</View>
|
|
<Text style={styles.guestTitle}>Join Acupedia</Text>
|
|
<Text style={styles.guestSubtitle}>
|
|
Sign in or create an account to unlock clinical point pathways, track your learning progress, and customize your clinical references.
|
|
</Text>
|
|
|
|
<TouchableOpacity
|
|
style={styles.guestLoginButton}
|
|
onPress={() => router.push("/login")}
|
|
activeOpacity={0.85}
|
|
>
|
|
<Text style={styles.guestLoginButtonText}>Log In</Text>
|
|
</TouchableOpacity>
|
|
|
|
<TouchableOpacity
|
|
style={styles.guestSignupButton}
|
|
onPress={() => router.push("/register")}
|
|
activeOpacity={0.85}
|
|
>
|
|
<Text style={styles.guestSignupButtonText}>Create Account</Text>
|
|
</TouchableOpacity>
|
|
</View>
|
|
</ScrollView>
|
|
</SafeAreaView>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<SafeAreaView style={styles.safeArea}>
|
|
<ScrollView
|
|
showsVerticalScrollIndicator={false}
|
|
contentContainerStyle={styles.contentContainer}
|
|
>
|
|
<View style={styles.container}>
|
|
<ProfileHeader
|
|
title="My Profile"
|
|
showBackButton={false}
|
|
onSettingsPress={() => {
|
|
router.push("/settings");
|
|
}}
|
|
/>
|
|
|
|
<ProfileAvatar
|
|
name={displayName}
|
|
email={displayEmail}
|
|
/>
|
|
|
|
<ProfileOverviewCard />
|
|
|
|
<LogoutButton onPress={handleLogout} />
|
|
</View>
|
|
</ScrollView>
|
|
</SafeAreaView>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
safeArea: {
|
|
flex: 1,
|
|
backgroundColor: Colors.background,
|
|
},
|
|
|
|
contentContainer: {
|
|
flexGrow: 1,
|
|
paddingBottom: verticalScale(24),
|
|
},
|
|
|
|
container: {
|
|
flex: 1,
|
|
paddingHorizontal: moderateScale(20),
|
|
paddingTop: verticalScale(12),
|
|
},
|
|
|
|
guestContentContainer: {
|
|
flexGrow: 1,
|
|
justifyContent: "center",
|
|
paddingHorizontal: moderateScale(20),
|
|
paddingBottom: verticalScale(40),
|
|
},
|
|
|
|
guestCard: {
|
|
backgroundColor: "#FFFFFF",
|
|
borderRadius: moderateScale(20),
|
|
borderWidth: 1,
|
|
borderColor: "#E5E7EB",
|
|
padding: moderateScale(26),
|
|
alignItems: "center",
|
|
shadowColor: "#000000",
|
|
shadowOffset: { width: 0, height: 4 },
|
|
shadowOpacity: 0.05,
|
|
shadowRadius: 10,
|
|
elevation: 2,
|
|
},
|
|
|
|
guestIconWrapper: {
|
|
marginBottom: verticalScale(14),
|
|
},
|
|
|
|
guestTitle: {
|
|
fontSize: moderateScale(22),
|
|
fontWeight: "800",
|
|
color: Colors.textPrimary,
|
|
marginBottom: verticalScale(6),
|
|
},
|
|
|
|
guestSubtitle: {
|
|
fontSize: moderateScale(13),
|
|
color: Colors.textSecondary,
|
|
textAlign: "center",
|
|
lineHeight: 19,
|
|
marginBottom: verticalScale(24),
|
|
},
|
|
|
|
guestLoginButton: {
|
|
width: "100%",
|
|
backgroundColor: Colors.primary,
|
|
borderRadius: moderateScale(12),
|
|
paddingVertical: verticalScale(13),
|
|
alignItems: "center",
|
|
marginBottom: verticalScale(10),
|
|
},
|
|
|
|
guestLoginButtonText: {
|
|
fontSize: moderateScale(15),
|
|
fontWeight: "700",
|
|
color: "#FFFFFF",
|
|
},
|
|
|
|
guestSignupButton: {
|
|
width: "100%",
|
|
backgroundColor: "#FFFFFF",
|
|
borderWidth: 1.5,
|
|
borderColor: Colors.primary,
|
|
borderRadius: moderateScale(12),
|
|
paddingVertical: verticalScale(12),
|
|
alignItems: "center",
|
|
},
|
|
|
|
guestSignupButtonText: {
|
|
fontSize: moderateScale(15),
|
|
fontWeight: "700",
|
|
color: Colors.primary,
|
|
},
|
|
}); |