Merge pull request 'Updated profile, added polished settings page, added restrictions for screenshot and screen recording' (#31) from profile-settings-screenshot into main
Reviewed-on: https://10.10.0.4/AcuPedia/acupedia-mobile-ui/pulls/31 Reviewed-by: Amit Salunke <amit@noreply.localhost>
This commit is contained in:
commit
cdb6665ac7
12
.env
12
.env
|
|
@ -17,11 +17,11 @@
|
||||||
# old working .env file
|
# old working .env file
|
||||||
|
|
||||||
# Production Dev
|
# Production Dev
|
||||||
# EXPO_PUBLIC_API_URL=https://api.acupedia.in/api
|
EXPO_PUBLIC_API_URL=https://api.acupedia.in/api
|
||||||
# EXPO_PUBLIC_STOREFRONT_URL=https://acupedia.in/store
|
EXPO_PUBLIC_STOREFRONT_URL=https://acupedia.in/store
|
||||||
# EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=false
|
EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=true
|
||||||
|
|
||||||
# Local Dev
|
# Local Dev
|
||||||
EXPO_PUBLIC_API_URL=http://localhost:8000/api
|
# EXPO_PUBLIC_API_URL=http://localhost:8000/api
|
||||||
EXPO_PUBLIC_STOREFRONT_URL=http://localhost:3000
|
# EXPO_PUBLIC_STOREFRONT_URL=http://localhost:3000
|
||||||
EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=true
|
# EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=true
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
"expo-linear-gradient": "~57.0.1",
|
"expo-linear-gradient": "~57.0.1",
|
||||||
"expo-linking": "~57.0.9",
|
"expo-linking": "~57.0.9",
|
||||||
"expo-router": "~57.0.19",
|
"expo-router": "~57.0.19",
|
||||||
|
"expo-screen-capture": "~57.0.3",
|
||||||
"expo-secure-store": "~57.0.2",
|
"expo-secure-store": "~57.0.2",
|
||||||
"expo-splash-screen": "~57.0.8",
|
"expo-splash-screen": "~57.0.8",
|
||||||
"expo-status-bar": "~57.0.1",
|
"expo-status-bar": "~57.0.1",
|
||||||
|
|
@ -4114,6 +4115,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/expo-screen-capture": {
|
||||||
|
"version": "57.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/expo-screen-capture/-/expo-screen-capture-57.0.3.tgz",
|
||||||
|
"integrity": "sha512-EpTd6tBgX2nWKJUvYDIrnsC2xWGJnlOLqN48EzLwPTQlbbwDUeWwt+4RDZOyFkWCa67XiUbrzIEOJApNBVZSow==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"expo": "*",
|
||||||
|
"react": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/expo-secure-store": {
|
"node_modules/expo-secure-store": {
|
||||||
"version": "57.0.3",
|
"version": "57.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/expo-secure-store/-/expo-secure-store-57.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/expo-secure-store/-/expo-secure-store-57.0.3.tgz",
|
||||||
|
|
|
||||||
21
package.json
21
package.json
|
|
@ -3,15 +3,24 @@
|
||||||
"main": "expo-router/entry",
|
"main": "expo-router/entry",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@expo-google-fonts/inter": "^0.4.2",
|
||||||
"@expo/ui": "~57.0.16",
|
"@expo/ui": "~57.0.16",
|
||||||
|
"@expo/vector-icons": "^15.0.2",
|
||||||
|
"@react-native-async-storage/async-storage": "2.2.0",
|
||||||
|
"@react-native-community/netinfo": "12.0.1",
|
||||||
|
"@tanstack/react-query": "^5.101.2",
|
||||||
|
"axios": "^1.18.1",
|
||||||
"expo": "~57.0.20",
|
"expo": "~57.0.20",
|
||||||
"expo-constants": "~57.0.17",
|
"expo-constants": "~57.0.17",
|
||||||
"expo-device": "~57.0.1",
|
"expo-device": "~57.0.1",
|
||||||
"expo-font": "~57.0.3",
|
"expo-font": "~57.0.3",
|
||||||
"expo-glass-effect": "~57.0.1",
|
"expo-glass-effect": "~57.0.1",
|
||||||
"expo-image": "~57.0.4",
|
"expo-image": "~57.0.4",
|
||||||
|
"expo-linear-gradient": "~57.0.1",
|
||||||
"expo-linking": "~57.0.9",
|
"expo-linking": "~57.0.9",
|
||||||
"expo-router": "~57.0.19",
|
"expo-router": "~57.0.19",
|
||||||
|
"expo-screen-capture": "~57.0.3",
|
||||||
|
"expo-secure-store": "~57.0.2",
|
||||||
"expo-splash-screen": "~57.0.8",
|
"expo-splash-screen": "~57.0.8",
|
||||||
"expo-status-bar": "~57.0.1",
|
"expo-status-bar": "~57.0.1",
|
||||||
"expo-symbols": "~57.0.2",
|
"expo-symbols": "~57.0.2",
|
||||||
|
|
@ -24,18 +33,10 @@
|
||||||
"react-native-reanimated": "4.5.1",
|
"react-native-reanimated": "4.5.1",
|
||||||
"react-native-safe-area-context": "~5.7.0",
|
"react-native-safe-area-context": "~5.7.0",
|
||||||
"react-native-screens": "~4.26.0",
|
"react-native-screens": "~4.26.0",
|
||||||
"react-native-web": "~0.21.0",
|
|
||||||
"react-native-worklets": "0.10.1",
|
|
||||||
"@expo-google-fonts/inter": "^0.4.2",
|
|
||||||
"@expo/vector-icons": "^15.0.2",
|
|
||||||
"@react-native-async-storage/async-storage": "2.2.0",
|
|
||||||
"@react-native-community/netinfo": "12.0.1",
|
|
||||||
"@tanstack/react-query": "^5.101.2",
|
|
||||||
"axios": "^1.18.1",
|
|
||||||
"expo-linear-gradient": "~57.0.1",
|
|
||||||
"expo-secure-store": "~57.0.2",
|
|
||||||
"react-native-size-matters": "^0.4.2",
|
"react-native-size-matters": "^0.4.2",
|
||||||
"react-native-toast-message": "^2.3.3",
|
"react-native-toast-message": "^2.3.3",
|
||||||
|
"react-native-web": "~0.21.0",
|
||||||
|
"react-native-worklets": "0.10.1",
|
||||||
"zustand": "^4.5.7"
|
"zustand": "^4.5.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,10 @@ try {
|
||||||
// Silently ignore if module exports are immutable in web bundle environment
|
// Silently ignore if module exports are immutable in web bundle environment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import { useEffect } from "react";
|
||||||
|
import { Alert, Platform } from "react-native";
|
||||||
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
||||||
|
import * as ScreenCapture from "expo-screen-capture";
|
||||||
|
|
||||||
export default function RootLayout() {
|
export default function RootLayout() {
|
||||||
const [fontsLoaded] = useFonts({
|
const [fontsLoaded] = useFonts({
|
||||||
|
|
@ -115,6 +118,26 @@ export default function RootLayout() {
|
||||||
"Inter-Bold": Inter_700Bold,
|
"Inter-Bold": Inter_700Bold,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (Platform.OS === "web") return;
|
||||||
|
|
||||||
|
let isMounted = true;
|
||||||
|
void ScreenCapture.preventScreenCaptureAsync();
|
||||||
|
|
||||||
|
const subscription = ScreenCapture.addScreenshotListener(() => {
|
||||||
|
if (!isMounted) return;
|
||||||
|
Alert.alert(
|
||||||
|
"Confidential Clinical Content",
|
||||||
|
"Acupedia clinical reference materials and diagrams are proprietary. Capturing screenshots is restricted to protect clinical data."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
isMounted = false;
|
||||||
|
subscription?.remove();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
if (!fontsLoaded) {
|
if (!fontsLoaded) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,186 @@
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import {
|
||||||
|
KeyboardAvoidingView,
|
||||||
|
Platform,
|
||||||
|
ScrollView,
|
||||||
|
StyleSheet,
|
||||||
|
View,
|
||||||
|
Alert,
|
||||||
|
} from "react-native";
|
||||||
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
import { router } from "expo-router";
|
||||||
|
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||||
|
|
||||||
|
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||||
|
import PasswordInput from "@/components/forms/PasswordInput";
|
||||||
|
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||||
|
import FieldLabel from "@/components/forms/FieldLabel";
|
||||||
|
import { Colors } from "@/theme";
|
||||||
|
import { apiClient } from "@/api";
|
||||||
|
|
||||||
|
export default function ChangePasswordScreen() {
|
||||||
|
const [currentPassword, setCurrentPassword] = useState("");
|
||||||
|
const [newPassword, setNewPassword] = useState("");
|
||||||
|
const [confirmPassword, setConfirmPassword] = useState("");
|
||||||
|
|
||||||
|
const [currentError, setCurrentError] = useState("");
|
||||||
|
const [newError, setNewError] = useState("");
|
||||||
|
const [confirmError, setConfirmError] = useState("");
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
const handleUpdatePassword = async () => {
|
||||||
|
let hasError = false;
|
||||||
|
setCurrentError("");
|
||||||
|
setNewError("");
|
||||||
|
setConfirmError("");
|
||||||
|
|
||||||
|
if (!currentPassword) {
|
||||||
|
setCurrentError("Current password is required");
|
||||||
|
hasError = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!newPassword) {
|
||||||
|
setNewError("New password is required");
|
||||||
|
hasError = true;
|
||||||
|
} else if (newPassword.length < 8) {
|
||||||
|
setNewError("New password must be at least 8 characters");
|
||||||
|
hasError = true;
|
||||||
|
} else if (!/[A-Z]/.test(newPassword)) {
|
||||||
|
setNewError("Must contain at least one uppercase letter");
|
||||||
|
hasError = true;
|
||||||
|
} else if (!/[0-9]/.test(newPassword)) {
|
||||||
|
setNewError("Must contain at least one number");
|
||||||
|
hasError = true;
|
||||||
|
} else if (!/[^A-Za-z0-9]/.test(newPassword)) {
|
||||||
|
setNewError("Must contain at least one special character");
|
||||||
|
hasError = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!confirmPassword) {
|
||||||
|
setConfirmError("Please confirm your new password");
|
||||||
|
hasError = true;
|
||||||
|
} else if (newPassword !== confirmPassword) {
|
||||||
|
setConfirmError("Passwords do not match");
|
||||||
|
hasError = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasError) return;
|
||||||
|
|
||||||
|
setIsLoading(true);
|
||||||
|
try {
|
||||||
|
await apiClient.post("/auth/change-password", {
|
||||||
|
old_password: currentPassword,
|
||||||
|
new_password: newPassword,
|
||||||
|
});
|
||||||
|
|
||||||
|
const msg = "Password updated successfully!";
|
||||||
|
if (Platform.OS === "web") {
|
||||||
|
window.alert(msg);
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
Alert.alert("Success", msg, [
|
||||||
|
{ text: "OK", onPress: () => router.back() },
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} catch (err: any) {
|
||||||
|
const errMsg =
|
||||||
|
err?.response?.data?.detail ||
|
||||||
|
"Failed to update password. Please check your current password.";
|
||||||
|
setCurrentError(errMsg);
|
||||||
|
if (Platform.OS === "web") {
|
||||||
|
window.alert(errMsg);
|
||||||
|
} else {
|
||||||
|
Alert.alert("Error", errMsg);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SafeAreaView style={styles.safeArea}>
|
||||||
|
<KeyboardAvoidingView
|
||||||
|
style={styles.keyboardContainer}
|
||||||
|
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
||||||
|
>
|
||||||
|
<ScrollView
|
||||||
|
keyboardShouldPersistTaps="handled"
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
contentContainerStyle={styles.contentContainer}
|
||||||
|
>
|
||||||
|
<View style={styles.container}>
|
||||||
|
<SettingsHeader title="Change Password" />
|
||||||
|
|
||||||
|
<View style={styles.form}>
|
||||||
|
<View style={styles.field}>
|
||||||
|
<FieldLabel label="Current Password" required />
|
||||||
|
<PasswordInput
|
||||||
|
value={currentPassword}
|
||||||
|
onChangeText={setCurrentPassword}
|
||||||
|
placeholder="Enter current password"
|
||||||
|
error={currentError}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.field}>
|
||||||
|
<FieldLabel label="New Password" required />
|
||||||
|
<PasswordInput
|
||||||
|
value={newPassword}
|
||||||
|
onChangeText={setNewPassword}
|
||||||
|
placeholder="Min. 8 characters with numbers & symbols"
|
||||||
|
error={newError}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.field}>
|
||||||
|
<FieldLabel label="Confirm New Password" required />
|
||||||
|
<PasswordInput
|
||||||
|
value={confirmPassword}
|
||||||
|
onChangeText={setConfirmPassword}
|
||||||
|
placeholder="Re-enter new password"
|
||||||
|
error={confirmError}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.buttonSpacing}>
|
||||||
|
<PrimaryButton
|
||||||
|
title="Update Password"
|
||||||
|
loading={isLoading}
|
||||||
|
onPress={handleUpdatePassword}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
|
</SafeAreaView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
safeArea: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: Colors.background,
|
||||||
|
},
|
||||||
|
keyboardContainer: {
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
contentContainer: {
|
||||||
|
flexGrow: 1,
|
||||||
|
paddingBottom: verticalScale(32),
|
||||||
|
},
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
paddingHorizontal: moderateScale(20),
|
||||||
|
paddingTop: verticalScale(12),
|
||||||
|
},
|
||||||
|
form: {
|
||||||
|
marginTop: verticalScale(8),
|
||||||
|
},
|
||||||
|
field: {
|
||||||
|
marginBottom: verticalScale(16),
|
||||||
|
},
|
||||||
|
buttonSpacing: {
|
||||||
|
marginTop: verticalScale(12),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import EditProfileScreen from "@/screens/profile/EditProfileScreen";
|
||||||
|
|
||||||
|
export default function EditProfileRoute() {
|
||||||
|
return <EditProfileScreen />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,159 @@
|
||||||
|
import React from "react";
|
||||||
|
import {
|
||||||
|
ScrollView,
|
||||||
|
StyleSheet,
|
||||||
|
View,
|
||||||
|
Text,
|
||||||
|
} from "react-native";
|
||||||
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||||
|
|
||||||
|
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||||
|
import { Colors } from "@/theme";
|
||||||
|
|
||||||
|
export default function AboutScreen() {
|
||||||
|
return (
|
||||||
|
<SafeAreaView style={styles.safeArea}>
|
||||||
|
<ScrollView
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
contentContainerStyle={styles.contentContainer}
|
||||||
|
>
|
||||||
|
<View style={styles.container}>
|
||||||
|
<SettingsHeader title="About Acupedia" />
|
||||||
|
|
||||||
|
<View style={styles.logoSection}>
|
||||||
|
<View style={styles.logoWrapper}>
|
||||||
|
<Ionicons
|
||||||
|
name="medical"
|
||||||
|
size={moderateScale(42)}
|
||||||
|
color={Colors.primary}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<Text style={styles.appName}>Acupedia</Text>
|
||||||
|
<Text style={styles.appTagline}>
|
||||||
|
Comprehensive Clinical Acupuncture Encyclopedia
|
||||||
|
</Text>
|
||||||
|
<View style={styles.versionBadge}>
|
||||||
|
<Text style={styles.versionText}>Version 1.0.0 (Build 240)</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.card}>
|
||||||
|
<Text style={styles.infoTitle}>About This Platform</Text>
|
||||||
|
<Text style={styles.infoText}>
|
||||||
|
Acupedia is a clinical reference application developed specifically for acupuncture practitioners, researchers, and healthcare professionals. It delivers evidence-based anatomical mappings, point categories, channel pathways, and clinical safety considerations.
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<View style={styles.separator} />
|
||||||
|
|
||||||
|
<Text style={styles.infoTitle}>Publisher & Organization</Text>
|
||||||
|
<Text style={styles.infoText}>
|
||||||
|
Published by Panacea Clinical Systems Pvt Ltd. All international rights reserved.
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<View style={styles.separator} />
|
||||||
|
|
||||||
|
<Text style={styles.infoTitle}>Medical & Clinical Disclaimer</Text>
|
||||||
|
<Text style={styles.disclaimerText}>
|
||||||
|
The information provided in Acupedia is designed for accredited healthcare practitioners and educational reference only. It is not intended as a substitute for individualized clinical judgment, diagnosis, or emergency intervention.
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<Text style={styles.copyrightText}>
|
||||||
|
© {new Date().getFullYear()} Panacea Clinical Systems. All Rights Reserved.
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
</SafeAreaView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
safeArea: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: Colors.background,
|
||||||
|
},
|
||||||
|
contentContainer: {
|
||||||
|
flexGrow: 1,
|
||||||
|
paddingBottom: verticalScale(32),
|
||||||
|
},
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
paddingHorizontal: moderateScale(20),
|
||||||
|
paddingTop: verticalScale(12),
|
||||||
|
},
|
||||||
|
logoSection: {
|
||||||
|
alignItems: "center",
|
||||||
|
marginVertical: verticalScale(16),
|
||||||
|
},
|
||||||
|
logoWrapper: {
|
||||||
|
width: moderateScale(80),
|
||||||
|
height: moderateScale(80),
|
||||||
|
borderRadius: moderateScale(40),
|
||||||
|
backgroundColor: "#DCFCE7",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
marginBottom: verticalScale(12),
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "#BBF7D0",
|
||||||
|
},
|
||||||
|
appName: {
|
||||||
|
fontSize: moderateScale(22),
|
||||||
|
fontWeight: "800",
|
||||||
|
color: Colors.textPrimary,
|
||||||
|
marginBottom: verticalScale(4),
|
||||||
|
},
|
||||||
|
appTagline: {
|
||||||
|
fontSize: moderateScale(13),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
textAlign: "center",
|
||||||
|
marginBottom: verticalScale(10),
|
||||||
|
},
|
||||||
|
versionBadge: {
|
||||||
|
backgroundColor: "#F1F5F9",
|
||||||
|
paddingHorizontal: moderateScale(10),
|
||||||
|
paddingVertical: verticalScale(4),
|
||||||
|
borderRadius: moderateScale(12),
|
||||||
|
},
|
||||||
|
versionText: {
|
||||||
|
fontSize: moderateScale(11),
|
||||||
|
fontWeight: "600",
|
||||||
|
color: "#64748B",
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
backgroundColor: "#FFFFFF",
|
||||||
|
borderRadius: moderateScale(16),
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "#E5E7EB",
|
||||||
|
padding: moderateScale(18),
|
||||||
|
marginBottom: verticalScale(20),
|
||||||
|
},
|
||||||
|
infoTitle: {
|
||||||
|
fontSize: moderateScale(14),
|
||||||
|
fontWeight: "700",
|
||||||
|
color: Colors.textPrimary,
|
||||||
|
marginBottom: verticalScale(6),
|
||||||
|
},
|
||||||
|
infoText: {
|
||||||
|
fontSize: moderateScale(13),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
lineHeight: moderateScale(19),
|
||||||
|
},
|
||||||
|
disclaimerText: {
|
||||||
|
fontSize: moderateScale(12),
|
||||||
|
color: "#64748B",
|
||||||
|
lineHeight: moderateScale(18),
|
||||||
|
fontStyle: "italic",
|
||||||
|
},
|
||||||
|
separator: {
|
||||||
|
height: 1,
|
||||||
|
backgroundColor: "#F1F5F9",
|
||||||
|
marginVertical: verticalScale(14),
|
||||||
|
},
|
||||||
|
copyrightText: {
|
||||||
|
fontSize: moderateScale(11),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
textAlign: "center",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,239 @@
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import {
|
||||||
|
ScrollView,
|
||||||
|
StyleSheet,
|
||||||
|
View,
|
||||||
|
Text,
|
||||||
|
TouchableOpacity,
|
||||||
|
Alert,
|
||||||
|
Linking,
|
||||||
|
} from "react-native";
|
||||||
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||||
|
|
||||||
|
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||||
|
import { Colors } from "@/theme";
|
||||||
|
|
||||||
|
interface FAQ {
|
||||||
|
question: string;
|
||||||
|
answer: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FAQS: FAQ[] = [
|
||||||
|
{
|
||||||
|
question: "What is Acupedia?",
|
||||||
|
answer:
|
||||||
|
"Acupedia is a comprehensive clinical reference application designed for acupuncture practitioners, researchers, and students. It offers verified anatomical point mappings, therapeutic indications, needling depths, and clinical protocols.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
question: "How do I unlock additional clinical modules?",
|
||||||
|
answer:
|
||||||
|
"You can unlock full clinical libraries and specialized modules by visiting the Subscription tab or selecting any locked module to view tier plans.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
question: "How do I edit my profile information?",
|
||||||
|
answer:
|
||||||
|
"Navigate to the Profile tab or Settings > Edit Profile. You can update your Full Name, Phone Number, and Country.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
question: "Can I use Acupedia without an internet connection?",
|
||||||
|
answer:
|
||||||
|
"Yes. Once clinical modules and point definitions have been loaded, they remain cached on your device for offline reference in clinical settings.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
question: "How do I report clinical inaccuracies or suggestions?",
|
||||||
|
answer:
|
||||||
|
"We take clinical accuracy seriously. Please reach out to our editorial and clinical review team directly using the Email Support button below.",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function HelpSupportScreen() {
|
||||||
|
const [expandedIndex, setExpandedIndex] = useState<number | null>(0);
|
||||||
|
|
||||||
|
const handleContact = () => {
|
||||||
|
Linking.openURL("mailto:support@acupedia.com").catch(() => {
|
||||||
|
Alert.alert(
|
||||||
|
"Contact Support",
|
||||||
|
"Please email our support desk at support@acupedia.com"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleExpand = (index: number) => {
|
||||||
|
setExpandedIndex(expandedIndex === index ? null : index);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SafeAreaView style={styles.safeArea}>
|
||||||
|
<ScrollView
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
contentContainerStyle={styles.contentContainer}
|
||||||
|
>
|
||||||
|
<View style={styles.container}>
|
||||||
|
<SettingsHeader title="Help & Support" />
|
||||||
|
|
||||||
|
<Text style={styles.sectionSubtitle}>
|
||||||
|
Find quick answers to common clinical questions or contact our support team.
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Text style={styles.sectionTitle}>Frequently Asked Questions</Text>
|
||||||
|
|
||||||
|
<View style={styles.faqCard}>
|
||||||
|
{FAQS.map((faq, index) => {
|
||||||
|
const isExpanded = expandedIndex === index;
|
||||||
|
return (
|
||||||
|
<View key={index}>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={styles.faqHeader}
|
||||||
|
onPress={() => toggleExpand(index)}
|
||||||
|
activeOpacity={0.7}
|
||||||
|
>
|
||||||
|
<Text style={styles.questionText}>{faq.question}</Text>
|
||||||
|
<Ionicons
|
||||||
|
name={isExpanded ? "chevron-up" : "chevron-down"}
|
||||||
|
size={moderateScale(18)}
|
||||||
|
color={Colors.textSecondary}
|
||||||
|
/>
|
||||||
|
</TouchableOpacity>
|
||||||
|
|
||||||
|
{isExpanded && (
|
||||||
|
<View style={styles.answerContainer}>
|
||||||
|
<Text style={styles.answerText}>{faq.answer}</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{index < FAQS.length - 1 && <View style={styles.separator} />}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<Text style={styles.sectionTitle}>Contact Our Team</Text>
|
||||||
|
|
||||||
|
<TouchableOpacity
|
||||||
|
style={styles.contactCard}
|
||||||
|
onPress={handleContact}
|
||||||
|
activeOpacity={0.8}
|
||||||
|
>
|
||||||
|
<View style={styles.contactIconWrapper}>
|
||||||
|
<Ionicons
|
||||||
|
name="mail-outline"
|
||||||
|
size={moderateScale(22)}
|
||||||
|
color={Colors.primary}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.contactTextContainer}>
|
||||||
|
<Text style={styles.contactLabel}>Email Clinical Support</Text>
|
||||||
|
<Text style={styles.contactSubLabel}>
|
||||||
|
Response typically within 24 hours (support@acupedia.com)
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<Ionicons
|
||||||
|
name="chevron-forward"
|
||||||
|
size={moderateScale(18)}
|
||||||
|
color={Colors.textSecondary}
|
||||||
|
/>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
</SafeAreaView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
safeArea: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: Colors.background,
|
||||||
|
},
|
||||||
|
contentContainer: {
|
||||||
|
flexGrow: 1,
|
||||||
|
paddingBottom: verticalScale(32),
|
||||||
|
},
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
paddingHorizontal: moderateScale(20),
|
||||||
|
paddingTop: verticalScale(12),
|
||||||
|
},
|
||||||
|
sectionSubtitle: {
|
||||||
|
fontSize: moderateScale(13),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
marginBottom: verticalScale(16),
|
||||||
|
lineHeight: moderateScale(18),
|
||||||
|
},
|
||||||
|
sectionTitle: {
|
||||||
|
fontSize: moderateScale(13),
|
||||||
|
fontWeight: "700",
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
marginBottom: verticalScale(8),
|
||||||
|
marginLeft: moderateScale(4),
|
||||||
|
},
|
||||||
|
faqCard: {
|
||||||
|
backgroundColor: "#FFFFFF",
|
||||||
|
borderRadius: moderateScale(16),
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "#E5E7EB",
|
||||||
|
paddingHorizontal: moderateScale(16),
|
||||||
|
marginBottom: verticalScale(24),
|
||||||
|
},
|
||||||
|
faqHeader: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
paddingVertical: verticalScale(14),
|
||||||
|
},
|
||||||
|
questionText: {
|
||||||
|
fontSize: moderateScale(14),
|
||||||
|
fontWeight: "600",
|
||||||
|
color: Colors.textPrimary,
|
||||||
|
flex: 1,
|
||||||
|
marginRight: moderateScale(12),
|
||||||
|
lineHeight: moderateScale(19),
|
||||||
|
},
|
||||||
|
answerContainer: {
|
||||||
|
paddingBottom: verticalScale(14),
|
||||||
|
},
|
||||||
|
answerText: {
|
||||||
|
fontSize: moderateScale(13),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
lineHeight: moderateScale(19),
|
||||||
|
},
|
||||||
|
separator: {
|
||||||
|
height: 1,
|
||||||
|
backgroundColor: "#F1F5F9",
|
||||||
|
},
|
||||||
|
contactCard: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
backgroundColor: "#FFFFFF",
|
||||||
|
borderRadius: moderateScale(16),
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "#E5E7EB",
|
||||||
|
padding: moderateScale(16),
|
||||||
|
},
|
||||||
|
contactIconWrapper: {
|
||||||
|
width: moderateScale(40),
|
||||||
|
height: moderateScale(40),
|
||||||
|
borderRadius: moderateScale(20),
|
||||||
|
backgroundColor: "#DCFCE7",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
contactTextContainer: {
|
||||||
|
marginLeft: moderateScale(12),
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
contactLabel: {
|
||||||
|
fontSize: moderateScale(15),
|
||||||
|
fontWeight: "700",
|
||||||
|
color: Colors.textPrimary,
|
||||||
|
marginBottom: verticalScale(2),
|
||||||
|
},
|
||||||
|
contactSubLabel: {
|
||||||
|
fontSize: moderateScale(12),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
lineHeight: moderateScale(16),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import SettingsScreen from "@/screens/settings/SettingsScreen";
|
||||||
|
|
||||||
|
export default function SettingsRoute() {
|
||||||
|
return <SettingsScreen />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,232 @@
|
||||||
|
import React from "react";
|
||||||
|
import {
|
||||||
|
ScrollView,
|
||||||
|
StyleSheet,
|
||||||
|
View,
|
||||||
|
Text,
|
||||||
|
TouchableOpacity,
|
||||||
|
Alert,
|
||||||
|
Platform,
|
||||||
|
} from "react-native";
|
||||||
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
import { router } from "expo-router";
|
||||||
|
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||||
|
|
||||||
|
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||||
|
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||||
|
import { Colors } from "@/theme";
|
||||||
|
import { useSettingsStore } from "@/store/settings.store";
|
||||||
|
|
||||||
|
interface LanguageItem {
|
||||||
|
code: string;
|
||||||
|
label: string;
|
||||||
|
nativeLabel: string;
|
||||||
|
available: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const LANGUAGES: LanguageItem[] = [
|
||||||
|
{
|
||||||
|
code: "en",
|
||||||
|
label: "English",
|
||||||
|
nativeLabel: "English (US)",
|
||||||
|
available: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: "hi",
|
||||||
|
label: "Hindi",
|
||||||
|
nativeLabel: "हिन्दी",
|
||||||
|
available: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: "es",
|
||||||
|
label: "Spanish",
|
||||||
|
nativeLabel: "Español",
|
||||||
|
available: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: "zh",
|
||||||
|
label: "Chinese",
|
||||||
|
nativeLabel: "中文 (Traditional & Simplified)",
|
||||||
|
available: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: "fr",
|
||||||
|
label: "French",
|
||||||
|
nativeLabel: "Français",
|
||||||
|
available: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function LanguageScreen() {
|
||||||
|
const language = useSettingsStore((state) => state.language);
|
||||||
|
const setLanguage = useSettingsStore((state) => state.setLanguage);
|
||||||
|
|
||||||
|
const handleSelect = (lang: LanguageItem) => {
|
||||||
|
if (!lang.available) {
|
||||||
|
const msg = `${lang.label} translation is in progress and will be available in an upcoming clinical taxonomy release.`;
|
||||||
|
if (Platform.OS === "web") {
|
||||||
|
window.alert(msg);
|
||||||
|
} else {
|
||||||
|
Alert.alert("Coming Soon", msg);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setLanguage(lang.code);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSave = () => {
|
||||||
|
const selected = LANGUAGES.find((l) => l.code === language);
|
||||||
|
const msg = `Language set to ${selected?.label || "English"}.`;
|
||||||
|
if (Platform.OS === "web") {
|
||||||
|
window.alert(msg);
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
Alert.alert("Success", msg, [
|
||||||
|
{ text: "OK", onPress: () => router.back() },
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SafeAreaView style={styles.safeArea}>
|
||||||
|
<ScrollView
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
contentContainerStyle={styles.contentContainer}
|
||||||
|
>
|
||||||
|
<View style={styles.container}>
|
||||||
|
<SettingsHeader title="Language" />
|
||||||
|
|
||||||
|
<Text style={styles.sectionSubtitle}>
|
||||||
|
Choose your preferred clinical taxonomy and interface language.
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<View style={styles.card}>
|
||||||
|
{LANGUAGES.map((lang, index) => {
|
||||||
|
const isSelected = language === lang.code;
|
||||||
|
return (
|
||||||
|
<TouchableOpacity
|
||||||
|
key={lang.code}
|
||||||
|
style={[
|
||||||
|
styles.optionRow,
|
||||||
|
index < LANGUAGES.length - 1 && styles.border,
|
||||||
|
]}
|
||||||
|
onPress={() => handleSelect(lang)}
|
||||||
|
activeOpacity={0.7}
|
||||||
|
>
|
||||||
|
<View style={styles.textContainer}>
|
||||||
|
<Text style={styles.title}>{lang.label}</Text>
|
||||||
|
<Text style={styles.nativeLabel}>{lang.nativeLabel}</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{!lang.available ? (
|
||||||
|
<View style={styles.comingSoonBadge}>
|
||||||
|
<Text style={styles.comingSoonText}>Coming Soon</Text>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.radio,
|
||||||
|
isSelected && styles.radioSelected,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{isSelected && <View style={styles.radioInner} />}
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.buttonWrapper}>
|
||||||
|
<PrimaryButton title="Confirm Language" onPress={handleSave} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
</SafeAreaView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
safeArea: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: Colors.background,
|
||||||
|
},
|
||||||
|
contentContainer: {
|
||||||
|
flexGrow: 1,
|
||||||
|
paddingBottom: verticalScale(32),
|
||||||
|
},
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
paddingHorizontal: moderateScale(20),
|
||||||
|
paddingTop: verticalScale(12),
|
||||||
|
},
|
||||||
|
sectionSubtitle: {
|
||||||
|
fontSize: moderateScale(13),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
marginBottom: verticalScale(16),
|
||||||
|
lineHeight: moderateScale(18),
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
backgroundColor: "#FFFFFF",
|
||||||
|
borderRadius: moderateScale(16),
|
||||||
|
overflow: "hidden",
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "#E5E7EB",
|
||||||
|
},
|
||||||
|
optionRow: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
padding: moderateScale(16),
|
||||||
|
},
|
||||||
|
border: {
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
borderBottomColor: "#F1F5F9",
|
||||||
|
},
|
||||||
|
textContainer: {
|
||||||
|
flex: 1,
|
||||||
|
marginRight: moderateScale(12),
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
fontSize: moderateScale(14),
|
||||||
|
fontWeight: "600",
|
||||||
|
color: Colors.textPrimary,
|
||||||
|
},
|
||||||
|
nativeLabel: {
|
||||||
|
fontSize: moderateScale(12),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
marginTop: verticalScale(2),
|
||||||
|
},
|
||||||
|
comingSoonBadge: {
|
||||||
|
backgroundColor: "#F1F5F9",
|
||||||
|
paddingHorizontal: moderateScale(8),
|
||||||
|
paddingVertical: moderateScale(4),
|
||||||
|
borderRadius: moderateScale(6),
|
||||||
|
},
|
||||||
|
comingSoonText: {
|
||||||
|
fontSize: moderateScale(11),
|
||||||
|
fontWeight: "600",
|
||||||
|
color: "#64748B",
|
||||||
|
},
|
||||||
|
radio: {
|
||||||
|
width: moderateScale(20),
|
||||||
|
height: moderateScale(20),
|
||||||
|
borderRadius: moderateScale(10),
|
||||||
|
borderWidth: 2,
|
||||||
|
borderColor: "#CBD5E1",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
radioSelected: {
|
||||||
|
borderColor: Colors.primary,
|
||||||
|
},
|
||||||
|
radioInner: {
|
||||||
|
width: moderateScale(10),
|
||||||
|
height: moderateScale(10),
|
||||||
|
borderRadius: moderateScale(5),
|
||||||
|
backgroundColor: Colors.primary,
|
||||||
|
},
|
||||||
|
buttonWrapper: {
|
||||||
|
marginTop: verticalScale(24),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,144 @@
|
||||||
|
import React from "react";
|
||||||
|
import {
|
||||||
|
ScrollView,
|
||||||
|
StyleSheet,
|
||||||
|
View,
|
||||||
|
Text,
|
||||||
|
Alert,
|
||||||
|
Platform,
|
||||||
|
} from "react-native";
|
||||||
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
import { router } from "expo-router";
|
||||||
|
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||||
|
|
||||||
|
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||||
|
import ProfileMenuItem from "@/features/profile/components/ProfileMenuItem";
|
||||||
|
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||||
|
import { Colors } from "@/theme";
|
||||||
|
import { useSettingsStore } from "@/store/settings.store";
|
||||||
|
|
||||||
|
export default function NotificationSettingsScreen() {
|
||||||
|
const notifications = useSettingsStore((state) => state.notifications);
|
||||||
|
const setNotificationPreference = useSettingsStore(
|
||||||
|
(state) => state.setNotificationPreference
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleSave = () => {
|
||||||
|
const msg = "Notification preferences saved successfully!";
|
||||||
|
if (Platform.OS === "web") {
|
||||||
|
window.alert(msg);
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
Alert.alert("Success", msg, [
|
||||||
|
{ text: "OK", onPress: () => router.back() },
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SafeAreaView style={styles.safeArea}>
|
||||||
|
<ScrollView
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
contentContainerStyle={styles.contentContainer}
|
||||||
|
>
|
||||||
|
<View style={styles.container}>
|
||||||
|
<SettingsHeader title="Notification Settings" />
|
||||||
|
|
||||||
|
<Text style={styles.sectionSubtitle}>
|
||||||
|
Configure how and when you want to receive clinical notices and app updates.
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<View style={styles.card}>
|
||||||
|
<ProfileMenuItem
|
||||||
|
icon="notifications-outline"
|
||||||
|
title="Push Notifications"
|
||||||
|
subtitle="Receive alerts on mobile for key activities"
|
||||||
|
isSwitch
|
||||||
|
switchValue={notifications.push}
|
||||||
|
onSwitchChange={(val) => setNotificationPreference("push", val)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ProfileMenuItem
|
||||||
|
icon="medical-outline"
|
||||||
|
title="Clinical Updates"
|
||||||
|
subtitle="Notices about updated acupuncture points & evidence"
|
||||||
|
isSwitch
|
||||||
|
switchValue={notifications.clinicalUpdates}
|
||||||
|
onSwitchChange={(val) =>
|
||||||
|
setNotificationPreference("clinicalUpdates", val)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ProfileMenuItem
|
||||||
|
icon="newspaper-outline"
|
||||||
|
title="Weekly Digest"
|
||||||
|
subtitle="Summary of recent clinical articles and cases"
|
||||||
|
isSwitch
|
||||||
|
switchValue={notifications.weeklyDigest}
|
||||||
|
onSwitchChange={(val) =>
|
||||||
|
setNotificationPreference("weeklyDigest", val)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ProfileMenuItem
|
||||||
|
icon="volume-high-outline"
|
||||||
|
title="Sound Alerts"
|
||||||
|
subtitle="Play audio chime on arrival"
|
||||||
|
isSwitch
|
||||||
|
switchValue={notifications.sound}
|
||||||
|
onSwitchChange={(val) => setNotificationPreference("sound", val)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ProfileMenuItem
|
||||||
|
icon="phone-portrait-outline"
|
||||||
|
title="Vibrate"
|
||||||
|
subtitle="Haptic feedback on alerts"
|
||||||
|
isSwitch
|
||||||
|
isLast
|
||||||
|
switchValue={notifications.vibration}
|
||||||
|
onSwitchChange={(val) =>
|
||||||
|
setNotificationPreference("vibration", val)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.buttonWrapper}>
|
||||||
|
<PrimaryButton title="Save Preferences" onPress={handleSave} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
</SafeAreaView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
safeArea: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: Colors.background,
|
||||||
|
},
|
||||||
|
contentContainer: {
|
||||||
|
flexGrow: 1,
|
||||||
|
paddingBottom: verticalScale(32),
|
||||||
|
},
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
paddingHorizontal: moderateScale(20),
|
||||||
|
paddingTop: verticalScale(12),
|
||||||
|
},
|
||||||
|
sectionSubtitle: {
|
||||||
|
fontSize: moderateScale(13),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
marginBottom: verticalScale(16),
|
||||||
|
lineHeight: moderateScale(18),
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
backgroundColor: "#FFFFFF",
|
||||||
|
borderRadius: moderateScale(16),
|
||||||
|
overflow: "hidden",
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "#E5E7EB",
|
||||||
|
},
|
||||||
|
buttonWrapper: {
|
||||||
|
marginTop: verticalScale(24),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,171 @@
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import {
|
||||||
|
ScrollView,
|
||||||
|
StyleSheet,
|
||||||
|
View,
|
||||||
|
Text,
|
||||||
|
Alert,
|
||||||
|
Platform,
|
||||||
|
} from "react-native";
|
||||||
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
import { router } from "expo-router";
|
||||||
|
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||||
|
|
||||||
|
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||||
|
import ProfileMenuItem from "@/features/profile/components/ProfileMenuItem";
|
||||||
|
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||||
|
import { Colors } from "@/theme";
|
||||||
|
|
||||||
|
export default function PrivacySettingsScreen() {
|
||||||
|
const [analyticsEnabled, setAnalyticsEnabled] = useState(true);
|
||||||
|
const [offlineCacheEnabled, setOfflineCacheEnabled] = useState(true);
|
||||||
|
|
||||||
|
const handleClearHistory = () => {
|
||||||
|
const doClear = () => {
|
||||||
|
const msg = "Search and navigation history cleared.";
|
||||||
|
if (Platform.OS === "web") {
|
||||||
|
window.alert(msg);
|
||||||
|
} else {
|
||||||
|
Alert.alert("Success", msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Platform.OS === "web") {
|
||||||
|
if (window.confirm("Clear all local search history? This cannot be undone.")) {
|
||||||
|
doClear();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Alert.alert(
|
||||||
|
"Clear Search History",
|
||||||
|
"Are you sure you want to clear your local search history?",
|
||||||
|
[
|
||||||
|
{ text: "Cancel", style: "cancel" },
|
||||||
|
{ text: "Clear", style: "destructive", onPress: doClear },
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSave = () => {
|
||||||
|
const msg = "Privacy preferences updated!";
|
||||||
|
if (Platform.OS === "web") {
|
||||||
|
window.alert(msg);
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
Alert.alert("Success", msg, [
|
||||||
|
{ text: "OK", onPress: () => router.back() },
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SafeAreaView style={styles.safeArea}>
|
||||||
|
<ScrollView
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
contentContainerStyle={styles.contentContainer}
|
||||||
|
>
|
||||||
|
<View style={styles.container}>
|
||||||
|
<SettingsHeader title="Privacy & Data" />
|
||||||
|
|
||||||
|
<Text style={styles.sectionSubtitle}>
|
||||||
|
Manage your personal data storage, local history, and anonymized metrics.
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<View style={styles.card}>
|
||||||
|
<ProfileMenuItem
|
||||||
|
icon="analytics-outline"
|
||||||
|
title="Share Anonymous Diagnostics"
|
||||||
|
subtitle="Helps Acupedia improve performance & stability"
|
||||||
|
isSwitch
|
||||||
|
switchValue={analyticsEnabled}
|
||||||
|
onSwitchChange={setAnalyticsEnabled}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ProfileMenuItem
|
||||||
|
icon="server-outline"
|
||||||
|
title="Offline Content Caching"
|
||||||
|
subtitle="Cache accessed modules for offline clinical reading"
|
||||||
|
isSwitch
|
||||||
|
switchValue={offlineCacheEnabled}
|
||||||
|
onSwitchChange={setOfflineCacheEnabled}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ProfileMenuItem
|
||||||
|
icon="trash-outline"
|
||||||
|
title="Clear Search History"
|
||||||
|
subtitle="Remove cached search queries & recents"
|
||||||
|
showArrow
|
||||||
|
isLast
|
||||||
|
onPress={handleClearHistory}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.infoBox}>
|
||||||
|
<Text style={styles.infoTitle}>Clinical Privacy & Content Protection</Text>
|
||||||
|
<Text style={styles.infoText}>
|
||||||
|
Acupedia is strictly compliant with privacy principles. We never sell your clinical search data, bookmarks, or account information to third parties.
|
||||||
|
</Text>
|
||||||
|
<Text style={[styles.infoText, { marginTop: 6 }]}>
|
||||||
|
Proprietary anatomical charts, point coordinates, and clinical needling depths are protected by hardware screen-capture and recording prevention on native mobile devices.
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.buttonWrapper}>
|
||||||
|
<PrimaryButton title="Save Preferences" onPress={handleSave} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
</SafeAreaView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
safeArea: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: Colors.background,
|
||||||
|
},
|
||||||
|
contentContainer: {
|
||||||
|
flexGrow: 1,
|
||||||
|
paddingBottom: verticalScale(32),
|
||||||
|
},
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
paddingHorizontal: moderateScale(20),
|
||||||
|
paddingTop: verticalScale(12),
|
||||||
|
},
|
||||||
|
sectionSubtitle: {
|
||||||
|
fontSize: moderateScale(13),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
marginBottom: verticalScale(16),
|
||||||
|
lineHeight: moderateScale(18),
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
backgroundColor: "#FFFFFF",
|
||||||
|
borderRadius: moderateScale(16),
|
||||||
|
overflow: "hidden",
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "#E5E7EB",
|
||||||
|
marginBottom: verticalScale(20),
|
||||||
|
},
|
||||||
|
infoBox: {
|
||||||
|
backgroundColor: "#F8FAFC",
|
||||||
|
borderRadius: moderateScale(14),
|
||||||
|
padding: moderateScale(16),
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "#E2E8F0",
|
||||||
|
},
|
||||||
|
infoTitle: {
|
||||||
|
fontSize: moderateScale(14),
|
||||||
|
fontWeight: "700",
|
||||||
|
color: Colors.textPrimary,
|
||||||
|
marginBottom: verticalScale(4),
|
||||||
|
},
|
||||||
|
infoText: {
|
||||||
|
fontSize: moderateScale(12),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
lineHeight: moderateScale(18),
|
||||||
|
},
|
||||||
|
buttonWrapper: {
|
||||||
|
marginTop: verticalScale(24),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { type PropsWithChildren, useMemo, useState } from "react";
|
import React, { type PropsWithChildren, useEffect, useMemo, useState } from "react";
|
||||||
import {
|
import {
|
||||||
LayoutAnimation,
|
LayoutAnimation,
|
||||||
Platform,
|
Platform,
|
||||||
|
|
@ -30,6 +30,10 @@ export function AccordionSection({
|
||||||
const [expanded, setExpanded] = useState(defaultExpanded);
|
const [expanded, setExpanded] = useState(defaultExpanded);
|
||||||
const tone = useMemo(() => readingToneForTitle(title), [title]);
|
const tone = useMemo(() => readingToneForTitle(title), [title]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setExpanded(defaultExpanded);
|
||||||
|
}, [defaultExpanded]);
|
||||||
|
|
||||||
const toggle = () => {
|
const toggle = () => {
|
||||||
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
||||||
setExpanded((value) => !value);
|
setExpanded((value) => !value);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import React, { type PropsWithChildren, isValidElement } from "react";
|
||||||
|
|
||||||
import { isEmptyValue } from "../../utils/attribute-presentation";
|
import { isEmptyValue } from "../../utils/attribute-presentation";
|
||||||
import { AccordionSection } from "./AccordionSection";
|
import { AccordionSection } from "./AccordionSection";
|
||||||
|
import { useSettingsStore } from "@/store/settings.store";
|
||||||
|
|
||||||
export interface SectionCardProps {
|
export interface SectionCardProps {
|
||||||
title: string;
|
title: string;
|
||||||
|
|
@ -35,13 +36,20 @@ function hasRenderableContent(node: React.ReactNode): boolean {
|
||||||
|
|
||||||
export function SectionCard({
|
export function SectionCard({
|
||||||
title,
|
title,
|
||||||
defaultExpanded = true,
|
defaultExpanded,
|
||||||
children,
|
children,
|
||||||
}: PropsWithChildren<SectionCardProps>) {
|
}: PropsWithChildren<SectionCardProps>) {
|
||||||
if (!hasRenderableContent(children)) return null;
|
if (!hasRenderableContent(children)) return null;
|
||||||
|
|
||||||
|
const accordionDefaultExpanded = useSettingsStore(
|
||||||
|
(state) => state.accordionDefaultExpanded
|
||||||
|
);
|
||||||
|
|
||||||
|
const isExpanded =
|
||||||
|
defaultExpanded !== undefined ? defaultExpanded : accordionDefaultExpanded;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AccordionSection title={title} defaultExpanded={defaultExpanded}>
|
<AccordionSection title={title} defaultExpanded={isExpanded}>
|
||||||
{children}
|
{children}
|
||||||
</AccordionSection>
|
</AccordionSection>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {
|
import {
|
||||||
Pressable,
|
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
|
Text,
|
||||||
View,
|
View,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { Image } from "expo-image";
|
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
|
||||||
import {
|
import {
|
||||||
moderateScale,
|
moderateScale,
|
||||||
scale,
|
scale,
|
||||||
|
|
@ -13,46 +11,25 @@ import {
|
||||||
} from "react-native-size-matters";
|
} from "react-native-size-matters";
|
||||||
|
|
||||||
interface EditProfileAvatarProps {
|
interface EditProfileAvatarProps {
|
||||||
imageUri?: string;
|
name?: string;
|
||||||
onPress?: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function EditProfileAvatar({
|
function getInitials(nameString?: string): string {
|
||||||
imageUri,
|
if (!nameString || !nameString.trim()) return "U";
|
||||||
onPress,
|
const parts = nameString.trim().split(/\s+/);
|
||||||
}: EditProfileAvatarProps) {
|
if (parts.length === 1) {
|
||||||
|
return parts[0].slice(0, 2).toUpperCase();
|
||||||
|
}
|
||||||
|
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function EditProfileAvatar({ name }: EditProfileAvatarProps) {
|
||||||
|
const initials = getInitials(name);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View style={styles.avatarWrapper}>
|
<View style={styles.initialsContainer}>
|
||||||
{imageUri ? (
|
<Text style={styles.initialsText}>{initials}</Text>
|
||||||
<Image
|
|
||||||
source={{ uri: imageUri }}
|
|
||||||
style={styles.avatar}
|
|
||||||
contentFit="cover"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<View style={styles.avatar}>
|
|
||||||
<Ionicons
|
|
||||||
name="person"
|
|
||||||
size={moderateScale(56)}
|
|
||||||
color="#B8B8B8"
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Pressable
|
|
||||||
accessibilityRole="button"
|
|
||||||
accessibilityLabel="Change Profile Picture"
|
|
||||||
hitSlop={10}
|
|
||||||
onPress={onPress}
|
|
||||||
style={styles.cameraButton}
|
|
||||||
>
|
|
||||||
<Ionicons
|
|
||||||
name="camera"
|
|
||||||
size={moderateScale(15)}
|
|
||||||
color="#FFFFFF"
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
@ -61,37 +38,24 @@ export default function EditProfileAvatar({
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
marginBottom: verticalScale(28),
|
marginBottom: verticalScale(16),
|
||||||
},
|
},
|
||||||
|
|
||||||
avatarWrapper: {
|
initialsContainer: {
|
||||||
position: "relative",
|
width: scale(88),
|
||||||
},
|
height: scale(88),
|
||||||
|
borderRadius: scale(44),
|
||||||
avatar: {
|
backgroundColor: "#DCFCE7",
|
||||||
width: scale(108),
|
|
||||||
height: scale(108),
|
|
||||||
borderRadius: scale(54),
|
|
||||||
backgroundColor: "#F2F3F7",
|
|
||||||
justifyContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
},
|
|
||||||
|
|
||||||
cameraButton: {
|
|
||||||
position: "absolute",
|
|
||||||
right: scale(0),
|
|
||||||
bottom: scale(2),
|
|
||||||
|
|
||||||
width: scale(32),
|
|
||||||
height: scale(32),
|
|
||||||
borderRadius: scale(16),
|
|
||||||
|
|
||||||
backgroundColor: "#5B3DF5",
|
|
||||||
|
|
||||||
justifyContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
|
|
||||||
borderWidth: 2,
|
borderWidth: 2,
|
||||||
borderColor: "#FFFFFF",
|
borderColor: "#BBF7D0",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
|
||||||
|
initialsText: {
|
||||||
|
fontSize: moderateScale(28),
|
||||||
|
fontWeight: "800",
|
||||||
|
color: "#15803D",
|
||||||
|
letterSpacing: 1,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -1,9 +1,16 @@
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import {
|
import {
|
||||||
|
Modal,
|
||||||
|
Pressable,
|
||||||
|
ScrollView,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
|
Text,
|
||||||
View,
|
View,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import {
|
import {
|
||||||
|
moderateScale,
|
||||||
|
scale,
|
||||||
verticalScale,
|
verticalScale,
|
||||||
} from "react-native-size-matters";
|
} from "react-native-size-matters";
|
||||||
|
|
||||||
|
|
@ -11,26 +18,48 @@ import BaseTextInput from "@/components/forms/BaseTextInput";
|
||||||
import DropdownField from "@/components/forms/DropdownField";
|
import DropdownField from "@/components/forms/DropdownField";
|
||||||
import FieldLabel from "@/components/forms/FieldLabel";
|
import FieldLabel from "@/components/forms/FieldLabel";
|
||||||
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||||
|
import { Colors } from "@/theme";
|
||||||
|
|
||||||
interface EditProfileFormProps {
|
interface EditProfileFormProps {
|
||||||
initialName?: string;
|
initialName?: string;
|
||||||
initialEmail?: string;
|
initialEmail?: string;
|
||||||
initialPhone?: string;
|
initialPhone?: string;
|
||||||
initialProfession?: string;
|
|
||||||
initialCountry?: string;
|
initialCountry?: string;
|
||||||
onSave?: (updatedName: string, updatedPhone: string) => void;
|
onSave?: (updatedName: string, updatedPhone: string, updatedCountry: string) => void;
|
||||||
|
isLoading?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const COMMON_COUNTRIES = [
|
||||||
|
"India",
|
||||||
|
"United States",
|
||||||
|
"United Kingdom",
|
||||||
|
"Canada",
|
||||||
|
"Australia",
|
||||||
|
"Germany",
|
||||||
|
"Singapore",
|
||||||
|
"Malaysia",
|
||||||
|
"New Zealand",
|
||||||
|
"United Arab Emirates",
|
||||||
|
"South Africa",
|
||||||
|
"Ireland",
|
||||||
|
"Netherlands",
|
||||||
|
"Switzerland",
|
||||||
|
"France",
|
||||||
|
"Spain",
|
||||||
|
];
|
||||||
|
|
||||||
export default function EditProfileForm({
|
export default function EditProfileForm({
|
||||||
initialName = "User Name",
|
initialName = "User Name",
|
||||||
initialEmail = "user@example.com",
|
initialEmail = "user@example.com",
|
||||||
initialPhone = "",
|
initialPhone = "",
|
||||||
initialProfession = "Practitioner",
|
|
||||||
initialCountry = "India",
|
initialCountry = "India",
|
||||||
onSave,
|
onSave,
|
||||||
|
isLoading = false,
|
||||||
}: EditProfileFormProps) {
|
}: EditProfileFormProps) {
|
||||||
const [fullName, setFullName] = useState(initialName);
|
const [fullName, setFullName] = useState(initialName);
|
||||||
const [phone, setPhone] = useState(initialPhone);
|
const [phone, setPhone] = useState(initialPhone);
|
||||||
|
const [country, setCountry] = useState(initialCountry);
|
||||||
|
const [showCountryModal, setShowCountryModal] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setFullName(initialName);
|
setFullName(initialName);
|
||||||
|
|
@ -40,35 +69,25 @@ export default function EditProfileForm({
|
||||||
setPhone(initialPhone);
|
setPhone(initialPhone);
|
||||||
}, [initialPhone]);
|
}, [initialPhone]);
|
||||||
|
|
||||||
const [profession, setProfession] =
|
useEffect(() => {
|
||||||
useState(initialProfession);
|
setCountry(initialCountry);
|
||||||
|
}, [initialCountry]);
|
||||||
const [country] =
|
|
||||||
useState(initialCountry);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View style={styles.field}>
|
<View style={styles.field}>
|
||||||
<FieldLabel
|
<FieldLabel label="Full Name" required />
|
||||||
label="Full Name"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
|
|
||||||
<BaseTextInput
|
<BaseTextInput
|
||||||
value={fullName}
|
value={fullName}
|
||||||
onChangeText={setFullName}
|
onChangeText={setFullName}
|
||||||
placeholder="User Name"
|
placeholder="Your full name"
|
||||||
autoCapitalize="words"
|
autoCapitalize="words"
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.field}>
|
<View style={styles.field}>
|
||||||
<FieldLabel
|
<FieldLabel label="Email" required />
|
||||||
label="Email"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
|
|
||||||
<BaseTextInput
|
<BaseTextInput
|
||||||
value={initialEmail}
|
value={initialEmail}
|
||||||
editable={false}
|
editable={false}
|
||||||
|
|
@ -77,17 +96,17 @@ export default function EditProfileForm({
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
/>
|
/>
|
||||||
|
<Text style={styles.helperText}>
|
||||||
|
Email address is tied to your account identity and subscriptions.
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.field}>
|
<View style={styles.field}>
|
||||||
<FieldLabel
|
<FieldLabel label="Phone Number" />
|
||||||
label="Phone Number"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<BaseTextInput
|
<BaseTextInput
|
||||||
value={phone}
|
value={phone}
|
||||||
onChangeText={setPhone}
|
onChangeText={setPhone}
|
||||||
placeholder="Phone Number"
|
placeholder="e.g. +91 9876543210"
|
||||||
keyboardType="phone-pad"
|
keyboardType="phone-pad"
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
|
|
@ -95,50 +114,176 @@ export default function EditProfileForm({
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.field}>
|
<View style={styles.field}>
|
||||||
<FieldLabel
|
<FieldLabel label="Country / Region" required />
|
||||||
label="Profession (Optional)"
|
<DropdownField
|
||||||
/>
|
value={country}
|
||||||
|
placeholder="Select country"
|
||||||
<BaseTextInput
|
onPress={() => setShowCountryModal(true)}
|
||||||
value={profession}
|
|
||||||
onChangeText={setProfession}
|
|
||||||
placeholder="Practitioner"
|
|
||||||
autoCapitalize="words"
|
|
||||||
autoCorrect={false}
|
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.field}>
|
<View style={styles.buttonWrapper}>
|
||||||
<FieldLabel
|
<PrimaryButton
|
||||||
label="Country / Region"
|
title="Save Changes"
|
||||||
required
|
loading={isLoading}
|
||||||
/>
|
|
||||||
|
|
||||||
<DropdownField
|
|
||||||
value={country}
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
// TODO:
|
onSave?.(fullName, phone, country);
|
||||||
// Open Country Picker
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<PrimaryButton
|
{/* Country Selection Modal */}
|
||||||
title="Save Changes"
|
<Modal
|
||||||
onPress={() => {
|
visible={showCountryModal}
|
||||||
onSave?.(fullName, phone);
|
transparent
|
||||||
}}
|
animationType="slide"
|
||||||
/>
|
onRequestClose={() => setShowCountryModal(false)}
|
||||||
|
>
|
||||||
|
<Pressable
|
||||||
|
style={styles.modalOverlay}
|
||||||
|
onPress={() => setShowCountryModal(false)}
|
||||||
|
>
|
||||||
|
<View style={styles.modalSheet}>
|
||||||
|
<View style={styles.modalHeader}>
|
||||||
|
<Text style={styles.modalTitle}>Select Country</Text>
|
||||||
|
<Pressable
|
||||||
|
hitSlop={8}
|
||||||
|
onPress={() => setShowCountryModal(false)}
|
||||||
|
>
|
||||||
|
<Ionicons
|
||||||
|
name="close"
|
||||||
|
size={moderateScale(22)}
|
||||||
|
color={Colors.textSecondary}
|
||||||
|
/>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
contentContainerStyle={styles.countryList}
|
||||||
|
>
|
||||||
|
{COMMON_COUNTRIES.map((c) => {
|
||||||
|
const isSelected = country === c;
|
||||||
|
return (
|
||||||
|
<Pressable
|
||||||
|
key={c}
|
||||||
|
style={({ pressed }) => [
|
||||||
|
styles.countryItem,
|
||||||
|
isSelected && styles.countryItemSelected,
|
||||||
|
pressed && styles.countryItemPressed,
|
||||||
|
]}
|
||||||
|
onPress={() => {
|
||||||
|
setCountry(c);
|
||||||
|
setShowCountryModal(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
styles.countryName,
|
||||||
|
isSelected && styles.countryNameSelected,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{c}
|
||||||
|
</Text>
|
||||||
|
{isSelected && (
|
||||||
|
<Ionicons
|
||||||
|
name="checkmark"
|
||||||
|
size={moderateScale(18)}
|
||||||
|
color={Colors.primary}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ScrollView>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
</Modal>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
marginTop: verticalScale(8),
|
marginTop: verticalScale(4),
|
||||||
},
|
},
|
||||||
|
|
||||||
field: {
|
field: {
|
||||||
marginBottom: verticalScale(18),
|
marginBottom: verticalScale(16),
|
||||||
|
},
|
||||||
|
|
||||||
|
helperText: {
|
||||||
|
marginTop: verticalScale(4),
|
||||||
|
fontSize: moderateScale(11),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
lineHeight: moderateScale(15),
|
||||||
|
},
|
||||||
|
|
||||||
|
buttonWrapper: {
|
||||||
|
marginTop: verticalScale(10),
|
||||||
|
},
|
||||||
|
|
||||||
|
modalOverlay: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: "rgba(0, 0, 0, 0.4)",
|
||||||
|
justifyContent: "flex-end",
|
||||||
|
},
|
||||||
|
|
||||||
|
modalSheet: {
|
||||||
|
backgroundColor: "#FFFFFF",
|
||||||
|
borderTopLeftRadius: moderateScale(20),
|
||||||
|
borderTopRightRadius: moderateScale(20),
|
||||||
|
maxHeight: "70%",
|
||||||
|
paddingTop: verticalScale(16),
|
||||||
|
paddingBottom: verticalScale(32),
|
||||||
|
},
|
||||||
|
|
||||||
|
modalHeader: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
paddingHorizontal: scale(20),
|
||||||
|
paddingBottom: verticalScale(12),
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
borderBottomColor: "#F1F5F9",
|
||||||
|
},
|
||||||
|
|
||||||
|
modalTitle: {
|
||||||
|
fontSize: moderateScale(17),
|
||||||
|
fontWeight: "700",
|
||||||
|
color: Colors.textPrimary,
|
||||||
|
},
|
||||||
|
|
||||||
|
countryList: {
|
||||||
|
paddingHorizontal: scale(16),
|
||||||
|
paddingTop: verticalScale(8),
|
||||||
|
},
|
||||||
|
|
||||||
|
countryItem: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
paddingVertical: verticalScale(12),
|
||||||
|
paddingHorizontal: scale(12),
|
||||||
|
borderRadius: moderateScale(10),
|
||||||
|
},
|
||||||
|
|
||||||
|
countryItemSelected: {
|
||||||
|
backgroundColor: "#DCFCE7",
|
||||||
|
},
|
||||||
|
|
||||||
|
countryItemPressed: {
|
||||||
|
backgroundColor: "#F1F5F9",
|
||||||
|
},
|
||||||
|
|
||||||
|
countryName: {
|
||||||
|
fontSize: moderateScale(14),
|
||||||
|
color: Colors.textPrimary,
|
||||||
|
fontWeight: "500",
|
||||||
|
},
|
||||||
|
|
||||||
|
countryNameSelected: {
|
||||||
|
fontWeight: "700",
|
||||||
|
color: "#15803D",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -1,13 +1,9 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {
|
import {
|
||||||
Pressable,
|
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { Image } from "expo-image";
|
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
|
||||||
import { useRouter } from "expo-router";
|
|
||||||
import {
|
import {
|
||||||
moderateScale,
|
moderateScale,
|
||||||
scale,
|
scale,
|
||||||
|
|
@ -19,71 +15,31 @@ import { Colors } from "@/theme";
|
||||||
interface ProfileAvatarProps {
|
interface ProfileAvatarProps {
|
||||||
name: string;
|
name: string;
|
||||||
email: string;
|
email: string;
|
||||||
imageUri?: string;
|
}
|
||||||
onEditPress?: () => void;
|
|
||||||
|
function getInitials(nameString: string): string {
|
||||||
|
if (!nameString || !nameString.trim()) return "U";
|
||||||
|
const parts = nameString.trim().split(/\s+/);
|
||||||
|
if (parts.length === 1) {
|
||||||
|
return parts[0].slice(0, 2).toUpperCase();
|
||||||
|
}
|
||||||
|
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ProfileAvatar({
|
export default function ProfileAvatar({
|
||||||
name,
|
name,
|
||||||
email,
|
email,
|
||||||
imageUri,
|
|
||||||
onEditPress,
|
|
||||||
}: ProfileAvatarProps) {
|
}: ProfileAvatarProps) {
|
||||||
const router = useRouter();
|
const initials = getInitials(name);
|
||||||
|
|
||||||
const handleEditProfile = () => {
|
|
||||||
onEditPress?.();
|
|
||||||
router.push("/profile/edit");
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View style={styles.avatarWrapper}>
|
<View style={styles.initialsContainer}>
|
||||||
{imageUri ? (
|
<Text style={styles.initialsText}>{initials}</Text>
|
||||||
<Image
|
|
||||||
source={{ uri: imageUri }}
|
|
||||||
style={styles.avatar}
|
|
||||||
contentFit="cover"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<View style={styles.avatar}>
|
|
||||||
<Ionicons
|
|
||||||
name="person"
|
|
||||||
size={moderateScale(52)}
|
|
||||||
color="#B8B8B8"
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Pressable
|
|
||||||
accessibilityRole="button"
|
|
||||||
accessibilityLabel="Edit Profile Picture"
|
|
||||||
hitSlop={10}
|
|
||||||
onPress={handleEditProfile}
|
|
||||||
style={styles.editButton}
|
|
||||||
>
|
|
||||||
<Ionicons
|
|
||||||
name="camera"
|
|
||||||
size={moderateScale(14)}
|
|
||||||
color="#FFFFFF"
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Pressable
|
<Text style={styles.name}>{name}</Text>
|
||||||
accessibilityRole="button"
|
<Text style={styles.email}>{email}</Text>
|
||||||
accessibilityLabel="Edit Profile"
|
|
||||||
hitSlop={10}
|
|
||||||
onPress={handleEditProfile}
|
|
||||||
>
|
|
||||||
<Text style={styles.name}>
|
|
||||||
{name}
|
|
||||||
</Text>
|
|
||||||
</Pressable>
|
|
||||||
|
|
||||||
<Text style={styles.email}>
|
|
||||||
{email}
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -91,51 +47,40 @@ export default function ProfileAvatar({
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
marginTop: verticalScale(10),
|
marginTop: verticalScale(4),
|
||||||
marginBottom: verticalScale(28),
|
|
||||||
},
|
|
||||||
|
|
||||||
avatarWrapper: {
|
|
||||||
position: "relative",
|
|
||||||
marginBottom: verticalScale(16),
|
marginBottom: verticalScale(16),
|
||||||
},
|
},
|
||||||
|
|
||||||
avatar: {
|
initialsContainer: {
|
||||||
width: scale(96),
|
width: scale(88),
|
||||||
height: scale(96),
|
height: scale(88),
|
||||||
borderRadius: scale(48),
|
borderRadius: scale(44),
|
||||||
backgroundColor: "#F2F3F7",
|
backgroundColor: "#DCFCE7",
|
||||||
|
borderWidth: 2,
|
||||||
|
borderColor: "#BBF7D0",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
marginBottom: verticalScale(12),
|
||||||
},
|
},
|
||||||
|
|
||||||
editButton: {
|
initialsText: {
|
||||||
position: "absolute",
|
fontSize: moderateScale(28),
|
||||||
right: scale(-2),
|
fontWeight: "800",
|
||||||
bottom: scale(-2),
|
color: "#15803D",
|
||||||
|
letterSpacing: 1,
|
||||||
width: scale(30),
|
|
||||||
height: scale(30),
|
|
||||||
borderRadius: scale(15),
|
|
||||||
|
|
||||||
backgroundColor: "#5B3DF5",
|
|
||||||
|
|
||||||
justifyContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
|
|
||||||
borderWidth: 2,
|
|
||||||
borderColor: "#FFFFFF",
|
|
||||||
},
|
},
|
||||||
|
|
||||||
name: {
|
name: {
|
||||||
fontSize: moderateScale(18),
|
fontSize: moderateScale(18),
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: Colors.text,
|
color: Colors.textPrimary,
|
||||||
|
textAlign: "center",
|
||||||
},
|
},
|
||||||
|
|
||||||
email: {
|
email: {
|
||||||
marginTop: verticalScale(6),
|
marginTop: verticalScale(3),
|
||||||
fontSize: moderateScale(14),
|
fontSize: moderateScale(13),
|
||||||
color: "#7A7A7A",
|
color: Colors.textSecondary,
|
||||||
|
textAlign: "center",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -17,55 +17,64 @@ import { Colors } from "@/theme";
|
||||||
|
|
||||||
interface ProfileHeaderProps {
|
interface ProfileHeaderProps {
|
||||||
title?: string;
|
title?: string;
|
||||||
|
showBackButton?: boolean;
|
||||||
onSettingsPress?: () => void;
|
onSettingsPress?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ProfileHeader({
|
export default function ProfileHeader({
|
||||||
title = "My Profile",
|
title = "My Profile",
|
||||||
|
showBackButton = false,
|
||||||
onSettingsPress,
|
onSettingsPress,
|
||||||
}: ProfileHeaderProps) {
|
}: ProfileHeaderProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Pressable
|
{showBackButton ? (
|
||||||
accessibilityRole="button"
|
<Pressable
|
||||||
accessibilityLabel="Go Back"
|
accessibilityRole="button"
|
||||||
hitSlop={10}
|
accessibilityLabel="Go Back"
|
||||||
style={styles.iconButton}
|
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
||||||
onPress={() => {
|
style={({ pressed }) => [
|
||||||
if (router.canGoBack()) {
|
styles.iconButton,
|
||||||
router.back();
|
pressed && styles.iconButtonPressed,
|
||||||
} else {
|
]}
|
||||||
router.replace("/");
|
onPress={() => {
|
||||||
}
|
if (router.canGoBack()) {
|
||||||
}}
|
router.back();
|
||||||
>
|
} else {
|
||||||
<Ionicons
|
router.replace("/");
|
||||||
name="arrow-back"
|
}
|
||||||
size={moderateScale(22)}
|
}}
|
||||||
color={Colors.text}
|
>
|
||||||
/>
|
<Ionicons
|
||||||
</Pressable>
|
name="chevron-back"
|
||||||
|
size={moderateScale(24)}
|
||||||
|
color={Colors.textPrimary}
|
||||||
|
/>
|
||||||
|
</Pressable>
|
||||||
|
) : (
|
||||||
|
<View style={styles.placeholder} />
|
||||||
|
)}
|
||||||
|
|
||||||
<Text
|
<Text numberOfLines={1} style={styles.title}>
|
||||||
numberOfLines={1}
|
|
||||||
style={styles.title}
|
|
||||||
>
|
|
||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
accessibilityLabel="Settings"
|
accessibilityLabel="Settings"
|
||||||
hitSlop={10}
|
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
||||||
style={styles.iconButton}
|
style={({ pressed }) => [
|
||||||
|
styles.iconButton,
|
||||||
|
pressed && styles.iconButtonPressed,
|
||||||
|
]}
|
||||||
onPress={onSettingsPress}
|
onPress={onSettingsPress}
|
||||||
>
|
>
|
||||||
<Ionicons
|
<Ionicons
|
||||||
name="settings-outline"
|
name="settings-outline"
|
||||||
size={moderateScale(22)}
|
size={moderateScale(21)}
|
||||||
color={Colors.text}
|
color={Colors.textPrimary}
|
||||||
/>
|
/>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -74,36 +83,36 @@ export default function ProfileHeader({
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
height: verticalScale(56),
|
height: verticalScale(50),
|
||||||
|
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
|
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
|
marginBottom: verticalScale(16),
|
||||||
marginBottom: verticalScale(24),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
iconButton: {
|
iconButton: {
|
||||||
width: scale(40),
|
width: scale(38),
|
||||||
|
height: scale(38),
|
||||||
height: scale(40),
|
borderRadius: scale(19),
|
||||||
|
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
|
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
backgroundColor: "#F1F5F9",
|
||||||
|
},
|
||||||
|
|
||||||
|
iconButtonPressed: {
|
||||||
|
backgroundColor: "#E2E8F0",
|
||||||
},
|
},
|
||||||
|
|
||||||
title: {
|
title: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
|
|
||||||
fontSize: moderateScale(18),
|
fontSize: moderateScale(18),
|
||||||
|
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
|
color: Colors.textPrimary,
|
||||||
|
},
|
||||||
|
|
||||||
color: Colors.text,
|
placeholder: {
|
||||||
|
width: scale(38),
|
||||||
|
height: scale(38),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -96,12 +96,14 @@ export default function ProfileMenuItem({
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isSwitch ? (
|
{isSwitch ? (
|
||||||
<Switch
|
<View style={{ pointerEvents: "none" }}>
|
||||||
value={switchValue}
|
<Switch
|
||||||
onValueChange={onSwitchChange}
|
value={switchValue}
|
||||||
trackColor={{ false: "#CBD5E1", true: "#2563EB" }}
|
onValueChange={onSwitchChange}
|
||||||
thumbColor="#FFFFFF"
|
trackColor={{ false: "#E2E8F0", true: Colors.primary }}
|
||||||
/>
|
thumbColor="#FFFFFF"
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
) : showArrow ? (
|
) : showArrow ? (
|
||||||
<Ionicons
|
<Ionicons
|
||||||
name="chevron-forward"
|
name="chevron-forward"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import { StyleSheet, Text, View } from "react-native";
|
import { StyleSheet, Text, View } from "react-native";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
import { moderateScale, scale, verticalScale } from "react-native-size-matters";
|
||||||
|
|
||||||
import ProfileMenuItem from "./ProfileMenuItem";
|
import ProfileMenuItem from "./ProfileMenuItem";
|
||||||
import { useAuthStore } from "@/store/auth.store";
|
import { useAuthStore } from "@/store/auth.store";
|
||||||
|
import { Colors } from "@/theme";
|
||||||
|
|
||||||
function formatDate(value?: string | null): string {
|
function formatDate(value?: string | null): string {
|
||||||
if (!value) return "Lifetime Access";
|
if (!value) return "Lifetime Access";
|
||||||
|
|
@ -36,7 +37,9 @@ export default function ProfileOverviewCard() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
void refreshAccess().catch((error) => console.warn("Unable to refresh profile access:", error));
|
void refreshAccess().catch((error) =>
|
||||||
|
console.warn("Unable to refresh profile access:", error)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [accessToken, refreshAccess]);
|
}, [accessToken, refreshAccess]);
|
||||||
|
|
||||||
|
|
@ -81,23 +84,17 @@ export default function ProfileOverviewCard() {
|
||||||
icon={item.icon}
|
icon={item.icon}
|
||||||
title={item.title}
|
title={item.title}
|
||||||
value={item.value}
|
value={item.value}
|
||||||
|
showArrow={false}
|
||||||
isLast={index === accountOverviewItems.length - 1}
|
isLast={index === accountOverviewItems.length - 1}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.section}>
|
{activeSubscriptions.length > 0 && (
|
||||||
<Text style={styles.heading}>Subscriptions</Text>
|
<View style={styles.section}>
|
||||||
<View style={styles.card}>
|
<Text style={styles.heading}>Active Subscriptions</Text>
|
||||||
{activeSubscriptions.length === 0 ? (
|
<View style={styles.card}>
|
||||||
<View style={styles.emptyRow}>
|
{activeSubscriptions.map((subscription, index) => (
|
||||||
<Text style={styles.emptyTitle}>No active paid subscription</Text>
|
|
||||||
<Text style={styles.emptyText}>
|
|
||||||
Free modules remain available. Paid access will appear here after checkout is verified.
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
) : (
|
|
||||||
activeSubscriptions.map((subscription, index) => (
|
|
||||||
<View
|
<View
|
||||||
key={subscription.id}
|
key={subscription.id}
|
||||||
style={[
|
style={[
|
||||||
|
|
@ -106,7 +103,9 @@ export default function ProfileOverviewCard() {
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<View style={styles.subLeft}>
|
<View style={styles.subLeft}>
|
||||||
<Text style={styles.subTitle}>{planLabel(subscription.plan_code)}</Text>
|
<Text style={styles.subTitle}>
|
||||||
|
{planLabel(subscription.plan_code)}
|
||||||
|
</Text>
|
||||||
<Text style={styles.subDateText}>
|
<Text style={styles.subDateText}>
|
||||||
Started: {formatDate(subscription.started_at)}
|
Started: {formatDate(subscription.started_at)}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
@ -118,10 +117,10 @@ export default function ProfileOverviewCard() {
|
||||||
<Text style={styles.statusText}>{subscription.status}</Text>
|
<Text style={styles.statusText}>{subscription.status}</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
))
|
))}
|
||||||
)}
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
)}
|
||||||
|
|
||||||
{activeEntitlements.length > 0 ? (
|
{activeEntitlements.length > 0 ? (
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
|
|
@ -154,45 +153,68 @@ export default function ProfileOverviewCard() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: { marginTop: verticalScale(8) },
|
container: { marginTop: verticalScale(4) },
|
||||||
section: { marginTop: verticalScale(24) },
|
section: { marginTop: verticalScale(20) },
|
||||||
heading: {
|
|
||||||
fontSize: moderateScale(16),
|
sectionHeaderRow: {
|
||||||
fontWeight: "700",
|
flexDirection: "row",
|
||||||
color: "#171717",
|
justifyContent: "space-between",
|
||||||
marginBottom: verticalScale(12),
|
alignItems: "center",
|
||||||
|
marginBottom: verticalScale(8),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
heading: {
|
||||||
|
fontSize: moderateScale(13),
|
||||||
|
fontWeight: "700",
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
marginLeft: moderateScale(4),
|
||||||
|
},
|
||||||
|
|
||||||
|
manageText: {
|
||||||
|
fontSize: moderateScale(13),
|
||||||
|
fontWeight: "600",
|
||||||
|
color: Colors.primary,
|
||||||
|
},
|
||||||
|
|
||||||
card: {
|
card: {
|
||||||
backgroundColor: "#FFFFFF",
|
backgroundColor: "#FFFFFF",
|
||||||
borderRadius: moderateScale(16),
|
borderRadius: moderateScale(16),
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: "#ECECEC",
|
borderColor: "#E5E7EB",
|
||||||
},
|
},
|
||||||
|
|
||||||
subRow: {
|
subRow: {
|
||||||
padding: moderateScale(16),
|
padding: moderateScale(16),
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
},
|
},
|
||||||
|
|
||||||
entitlementRow: {
|
entitlementRow: {
|
||||||
padding: moderateScale(16),
|
padding: moderateScale(16),
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
|
|
||||||
entitlementIcon: { marginRight: moderateScale(10) },
|
entitlementIcon: { marginRight: moderateScale(10) },
|
||||||
subLeft: { flex: 1 },
|
subLeft: { flex: 1 },
|
||||||
|
|
||||||
subTitle: {
|
subTitle: {
|
||||||
fontSize: moderateScale(14),
|
fontSize: moderateScale(14),
|
||||||
fontWeight: "600",
|
fontWeight: "600",
|
||||||
color: "#171717",
|
color: Colors.textPrimary,
|
||||||
marginBottom: verticalScale(4),
|
marginBottom: verticalScale(2),
|
||||||
},
|
},
|
||||||
|
|
||||||
subDateText: {
|
subDateText: {
|
||||||
fontSize: moderateScale(12),
|
fontSize: moderateScale(12),
|
||||||
color: "#737373",
|
color: Colors.textSecondary,
|
||||||
marginTop: verticalScale(2),
|
marginTop: verticalScale(2),
|
||||||
},
|
},
|
||||||
|
|
||||||
statusBadge: {
|
statusBadge: {
|
||||||
backgroundColor: "#DCFCE7",
|
backgroundColor: "#DCFCE7",
|
||||||
paddingHorizontal: moderateScale(10),
|
paddingHorizontal: moderateScale(10),
|
||||||
|
|
@ -200,23 +222,13 @@ const styles = StyleSheet.create({
|
||||||
borderRadius: moderateScale(12),
|
borderRadius: moderateScale(12),
|
||||||
marginLeft: moderateScale(12),
|
marginLeft: moderateScale(12),
|
||||||
},
|
},
|
||||||
|
|
||||||
statusText: {
|
statusText: {
|
||||||
fontSize: moderateScale(11),
|
fontSize: moderateScale(11),
|
||||||
fontWeight: "600",
|
fontWeight: "700",
|
||||||
color: "#15803D",
|
color: "#15803D",
|
||||||
textTransform: "capitalize",
|
textTransform: "capitalize",
|
||||||
},
|
},
|
||||||
separator: { borderBottomWidth: 1, borderBottomColor: "#ECECEC" },
|
|
||||||
emptyRow: { padding: moderateScale(16) },
|
separator: { borderBottomWidth: 1, borderBottomColor: "#F1F5F9" },
|
||||||
emptyTitle: {
|
|
||||||
fontSize: moderateScale(14),
|
|
||||||
fontWeight: "600",
|
|
||||||
color: "#171717",
|
|
||||||
},
|
|
||||||
emptyText: {
|
|
||||||
marginTop: verticalScale(5),
|
|
||||||
fontSize: moderateScale(12),
|
|
||||||
color: "#737373",
|
|
||||||
lineHeight: moderateScale(18),
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
import React from "react";
|
||||||
|
import {
|
||||||
|
Pressable,
|
||||||
|
StyleSheet,
|
||||||
|
Text,
|
||||||
|
} from "react-native";
|
||||||
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
import {
|
||||||
|
moderateScale,
|
||||||
|
scale,
|
||||||
|
verticalScale,
|
||||||
|
} from "react-native-size-matters";
|
||||||
|
|
||||||
|
interface LogoutButtonProps {
|
||||||
|
onPress: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function LogoutButton({ onPress }: LogoutButtonProps) {
|
||||||
|
return (
|
||||||
|
<Pressable
|
||||||
|
accessibilityRole="button"
|
||||||
|
accessibilityLabel="Log Out"
|
||||||
|
onPress={onPress}
|
||||||
|
style={({ pressed }) => [
|
||||||
|
styles.container,
|
||||||
|
pressed && styles.pressed,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Ionicons
|
||||||
|
name="log-out-outline"
|
||||||
|
size={moderateScale(20)}
|
||||||
|
color="#DC2626"
|
||||||
|
/>
|
||||||
|
<Text style={styles.text}>Log Out</Text>
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
height: verticalScale(50),
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
marginTop: verticalScale(8),
|
||||||
|
marginBottom: verticalScale(24),
|
||||||
|
borderRadius: moderateScale(14),
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "#FECACA",
|
||||||
|
backgroundColor: "#FEF2F2",
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
marginLeft: scale(8),
|
||||||
|
fontSize: moderateScale(15),
|
||||||
|
fontWeight: "700",
|
||||||
|
color: "#DC2626",
|
||||||
|
},
|
||||||
|
pressed: {
|
||||||
|
opacity: 0.8,
|
||||||
|
backgroundColor: "#FEE2E2",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
import React from "react";
|
||||||
|
import {
|
||||||
|
Pressable,
|
||||||
|
StyleSheet,
|
||||||
|
Text,
|
||||||
|
View,
|
||||||
|
} from "react-native";
|
||||||
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
import { useRouter } from "expo-router";
|
||||||
|
import {
|
||||||
|
moderateScale,
|
||||||
|
scale,
|
||||||
|
verticalScale,
|
||||||
|
} from "react-native-size-matters";
|
||||||
|
|
||||||
|
import { Colors } from "@/theme";
|
||||||
|
|
||||||
|
interface SettingsHeaderProps {
|
||||||
|
title?: string;
|
||||||
|
onBackPress?: () => void;
|
||||||
|
rightAction?: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function SettingsHeader({
|
||||||
|
title = "Settings",
|
||||||
|
onBackPress,
|
||||||
|
rightAction,
|
||||||
|
}: SettingsHeaderProps) {
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const handleBack = () => {
|
||||||
|
if (onBackPress) {
|
||||||
|
onBackPress();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (router.canGoBack()) {
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
router.replace("/(tabs)/profile");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<Pressable
|
||||||
|
accessibilityRole="button"
|
||||||
|
accessibilityLabel="Go Back"
|
||||||
|
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
||||||
|
style={({ pressed }) => [
|
||||||
|
styles.backButton,
|
||||||
|
pressed && styles.backButtonPressed,
|
||||||
|
]}
|
||||||
|
onPress={handleBack}
|
||||||
|
>
|
||||||
|
<Ionicons
|
||||||
|
name="chevron-back"
|
||||||
|
size={moderateScale(24)}
|
||||||
|
color={Colors.textPrimary}
|
||||||
|
/>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<Text numberOfLines={1} style={styles.title}>
|
||||||
|
{title}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
{rightAction ? (
|
||||||
|
<View style={styles.rightActionContainer}>{rightAction}</View>
|
||||||
|
) : (
|
||||||
|
<View style={styles.placeholder} />
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
height: verticalScale(50),
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
marginBottom: verticalScale(16),
|
||||||
|
},
|
||||||
|
|
||||||
|
backButton: {
|
||||||
|
width: scale(38),
|
||||||
|
height: scale(38),
|
||||||
|
borderRadius: scale(19),
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
backgroundColor: "#F1F5F9",
|
||||||
|
},
|
||||||
|
|
||||||
|
backButtonPressed: {
|
||||||
|
backgroundColor: "#E2E8F0",
|
||||||
|
},
|
||||||
|
|
||||||
|
title: {
|
||||||
|
flex: 1,
|
||||||
|
textAlign: "center",
|
||||||
|
fontSize: moderateScale(17),
|
||||||
|
fontWeight: "700",
|
||||||
|
color: Colors.textPrimary,
|
||||||
|
marginHorizontal: scale(8),
|
||||||
|
},
|
||||||
|
|
||||||
|
placeholder: {
|
||||||
|
width: scale(38),
|
||||||
|
height: scale(38),
|
||||||
|
},
|
||||||
|
|
||||||
|
rightActionContainer: {
|
||||||
|
width: scale(38),
|
||||||
|
height: scale(38),
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
import React from "react";
|
||||||
|
import { StyleSheet, Text, View } from "react-native";
|
||||||
|
import { useRouter } from "expo-router";
|
||||||
|
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||||
|
|
||||||
|
import ProfileMenuItem from "@/features/profile/components/ProfileMenuItem";
|
||||||
|
import { Colors } from "@/theme";
|
||||||
|
import { SettingsSectionProps, SettingsItem } from "../types";
|
||||||
|
|
||||||
|
export default function SettingsSection({
|
||||||
|
title,
|
||||||
|
items,
|
||||||
|
}: SettingsSectionProps) {
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const handlePress = (item: SettingsItem) => {
|
||||||
|
if (item.onPress) {
|
||||||
|
item.onPress();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (item.route) {
|
||||||
|
router.push(item.route as never);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!items || items.length === 0) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<Text style={styles.sectionTitle}>{title}</Text>
|
||||||
|
|
||||||
|
<View style={styles.card}>
|
||||||
|
{items.map((item, index) => (
|
||||||
|
<ProfileMenuItem
|
||||||
|
key={item.id}
|
||||||
|
icon={item.icon}
|
||||||
|
title={item.title}
|
||||||
|
subtitle={item.subtitle}
|
||||||
|
value={item.value}
|
||||||
|
showArrow={!item.isSwitch}
|
||||||
|
isLast={index === items.length - 1}
|
||||||
|
isSwitch={item.isSwitch}
|
||||||
|
switchValue={item.switchValue}
|
||||||
|
onSwitchChange={item.onSwitchChange}
|
||||||
|
onPress={() => handlePress(item)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
marginBottom: verticalScale(20),
|
||||||
|
},
|
||||||
|
|
||||||
|
sectionTitle: {
|
||||||
|
fontSize: moderateScale(13),
|
||||||
|
fontWeight: "700",
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
textTransform: "uppercase",
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
marginBottom: verticalScale(8),
|
||||||
|
marginLeft: moderateScale(4),
|
||||||
|
},
|
||||||
|
|
||||||
|
card: {
|
||||||
|
backgroundColor: "#FFFFFF",
|
||||||
|
borderRadius: moderateScale(16),
|
||||||
|
overflow: "hidden",
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: "#E5E7EB",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
import { SettingsItem } from "../types";
|
||||||
|
|
||||||
|
export const ACCOUNT_SETTINGS: SettingsItem[] = [
|
||||||
|
{
|
||||||
|
id: "edit-profile",
|
||||||
|
title: "Edit Profile",
|
||||||
|
subtitle: "Update name, phone number & country",
|
||||||
|
icon: "person-outline" as keyof typeof Ionicons.glyphMap,
|
||||||
|
route: "/profile/edit",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "change-password",
|
||||||
|
title: "Change Password",
|
||||||
|
subtitle: "Manage login credentials & security",
|
||||||
|
icon: "lock-closed-outline" as keyof typeof Ionicons.glyphMap,
|
||||||
|
route: "/profile/change-password",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "notification-settings",
|
||||||
|
title: "Notification Settings",
|
||||||
|
subtitle: "Clinical updates & reminder alerts",
|
||||||
|
icon: "notifications-outline" as keyof typeof Ionicons.glyphMap,
|
||||||
|
route: "/settings/notifications",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "privacy-settings",
|
||||||
|
title: "Privacy & Data",
|
||||||
|
subtitle: "Search cache & data governance",
|
||||||
|
icon: "shield-checkmark-outline" as keyof typeof Ionicons.glyphMap,
|
||||||
|
route: "/settings/privacy",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const PREFERENCE_SETTINGS: SettingsItem[] = [
|
||||||
|
{
|
||||||
|
id: "language",
|
||||||
|
title: "Language",
|
||||||
|
subtitle: "Interface localized language",
|
||||||
|
icon: "language-outline" as keyof typeof Ionicons.glyphMap,
|
||||||
|
value: "English",
|
||||||
|
route: "/settings/language",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const SUPPORT_SETTINGS: SettingsItem[] = [
|
||||||
|
{
|
||||||
|
id: "help-support",
|
||||||
|
title: "Help & Support",
|
||||||
|
subtitle: "FAQs, user guide & clinical inquiries",
|
||||||
|
icon: "help-circle-outline" as keyof typeof Ionicons.glyphMap,
|
||||||
|
route: "/settings/help-support",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "about-acupedia",
|
||||||
|
title: "About Acupedia",
|
||||||
|
subtitle: "Version, disclaimer & publisher info",
|
||||||
|
icon: "information-circle-outline" as keyof typeof Ionicons.glyphMap,
|
||||||
|
route: "/settings/about",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
|
||||||
|
export interface SettingsItem {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
subtitle?: string;
|
||||||
|
icon: keyof typeof Ionicons.glyphMap;
|
||||||
|
route?: string;
|
||||||
|
value?: string;
|
||||||
|
isSwitch?: boolean;
|
||||||
|
switchValue?: boolean;
|
||||||
|
onSwitchChange?: (val: boolean) => void;
|
||||||
|
onPress?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SettingsSectionProps {
|
||||||
|
title: string;
|
||||||
|
items: SettingsItem[];
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import {
|
import {
|
||||||
|
Alert,
|
||||||
KeyboardAvoidingView,
|
KeyboardAvoidingView,
|
||||||
Platform,
|
Platform,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
|
|
@ -12,7 +13,8 @@ import {
|
||||||
verticalScale,
|
verticalScale,
|
||||||
} from "react-native-size-matters";
|
} from "react-native-size-matters";
|
||||||
import { router } from "expo-router";
|
import { router } from "expo-router";
|
||||||
import EditProfileHeader from "@/features/profile/components/EditProfileHeader";
|
|
||||||
|
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||||
import { Colors } from "@/theme";
|
import { Colors } from "@/theme";
|
||||||
import EditProfileForm from "@/features/profile/components/EditProfileForm";
|
import EditProfileForm from "@/features/profile/components/EditProfileForm";
|
||||||
import EditProfileAvatar from "@/features/profile/components/EditProfileAvatar";
|
import EditProfileAvatar from "@/features/profile/components/EditProfileAvatar";
|
||||||
|
|
@ -22,22 +24,51 @@ import { apiClient } from "@/api";
|
||||||
export default function EditProfileScreen() {
|
export default function EditProfileScreen() {
|
||||||
const user = useAuthStore((state) => state.user);
|
const user = useAuthStore((state) => state.user);
|
||||||
const refreshIdentity = useAuthStore((state) => state.refreshIdentity);
|
const refreshIdentity = useAuthStore((state) => state.refreshIdentity);
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
|
||||||
const handleSave = async (updatedName: string, updatedPhone: string) => {
|
const handleSave = async (
|
||||||
if (user) {
|
updatedName: string,
|
||||||
try {
|
updatedPhone: string,
|
||||||
await apiClient.put("/auth/profile", {
|
updatedCountry: string
|
||||||
full_name: updatedName,
|
) => {
|
||||||
phone_number: updatedPhone,
|
if (!user) {
|
||||||
});
|
router.back();
|
||||||
|
return;
|
||||||
await refreshIdentity();
|
}
|
||||||
} catch (err: any) {
|
|
||||||
console.warn("Failed to update profile:", err);
|
setSaving(true);
|
||||||
alert("Failed to save changes. Please try again.");
|
try {
|
||||||
}
|
await apiClient.put("/auth/profile", {
|
||||||
|
full_name: updatedName.trim(),
|
||||||
|
phone_number: updatedPhone.trim() || null,
|
||||||
|
country: updatedCountry.trim() || null,
|
||||||
|
});
|
||||||
|
|
||||||
|
await refreshIdentity();
|
||||||
|
|
||||||
|
const successMsg = "Profile updated successfully!";
|
||||||
|
if (Platform.OS === "web") {
|
||||||
|
window.alert(successMsg);
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
Alert.alert("Success", successMsg, [
|
||||||
|
{ text: "OK", onPress: () => router.back() },
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} catch (err: any) {
|
||||||
|
const errMsg =
|
||||||
|
err?.response?.data?.detail ||
|
||||||
|
err?.message ||
|
||||||
|
"Failed to save profile changes. Please try again.";
|
||||||
|
console.warn("Failed to update profile:", err);
|
||||||
|
if (Platform.OS === "web") {
|
||||||
|
window.alert(errMsg);
|
||||||
|
} else {
|
||||||
|
Alert.alert("Error", errMsg);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
}
|
}
|
||||||
router.back();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -52,27 +83,18 @@ export default function EditProfileScreen() {
|
||||||
contentContainerStyle={styles.contentContainer}
|
contentContainerStyle={styles.contentContainer}
|
||||||
>
|
>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
|
<SettingsHeader title="Edit Profile" />
|
||||||
|
|
||||||
<EditProfileHeader />
|
<EditProfileAvatar name={user?.name || "User Name"} />
|
||||||
|
|
||||||
<EditProfileAvatar
|
|
||||||
onPress={() => {
|
|
||||||
// TODO: Open image picker
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<EditProfileForm
|
<EditProfileForm
|
||||||
initialName={user?.name || "User Name"}
|
initialName={user?.name || ""}
|
||||||
initialEmail={user?.email || "user@example.com"}
|
initialEmail={user?.email || ""}
|
||||||
initialPhone={user?.phone_number || ""}
|
initialPhone={user?.phone_number || ""}
|
||||||
|
initialCountry={user?.country || "India"}
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
|
isLoading={saving}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Step 4 */}
|
|
||||||
{/* EditProfileForm */}
|
|
||||||
|
|
||||||
{/* Step 5 */}
|
|
||||||
{/* Save Button */}
|
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</KeyboardAvoidingView>
|
</KeyboardAvoidingView>
|
||||||
|
|
@ -92,12 +114,12 @@ const styles = StyleSheet.create({
|
||||||
|
|
||||||
contentContainer: {
|
contentContainer: {
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
paddingBottom: verticalScale(24),
|
paddingBottom: verticalScale(32),
|
||||||
},
|
},
|
||||||
|
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
paddingHorizontal: moderateScale(24),
|
paddingHorizontal: moderateScale(20),
|
||||||
paddingTop: verticalScale(20),
|
paddingTop: verticalScale(12),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -17,10 +17,10 @@ import { router } from "expo-router";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
|
||||||
import { Colors } from "@/theme";
|
import { Colors } from "@/theme";
|
||||||
|
|
||||||
import ProfileHeader from "@/features/profile/components/ProfileHeader";
|
import ProfileHeader from "@/features/profile/components/ProfileHeader";
|
||||||
import ProfileAvatar from "@/features/profile/components/ProfileAvatar";
|
import ProfileAvatar from "@/features/profile/components/ProfileAvatar";
|
||||||
import ProfileOverviewCard from "@/features/profile/components/ProfileOverviewCard";
|
import ProfileOverviewCard from "@/features/profile/components/ProfileOverviewCard";
|
||||||
|
import LogoutButton from "@/features/settings/components/LogoutButton";
|
||||||
import { useAuthStore } from "@/store/auth.store";
|
import { useAuthStore } from "@/store/auth.store";
|
||||||
|
|
||||||
export default function ProfileOverviewScreen() {
|
export default function ProfileOverviewScreen() {
|
||||||
|
|
@ -45,7 +45,7 @@ export default function ProfileOverviewScreen() {
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
"Log Out",
|
"Log Out",
|
||||||
"Are you sure you want to log out?",
|
"Are you sure you want to log out of Acupedia?",
|
||||||
[
|
[
|
||||||
{ text: "Cancel", style: "cancel" },
|
{ text: "Cancel", style: "cancel" },
|
||||||
{
|
{
|
||||||
|
|
@ -54,7 +54,7 @@ export default function ProfileOverviewScreen() {
|
||||||
onPress: doLogout,
|
onPress: doLogout,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
{ cancelable: true },
|
{ cancelable: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -68,16 +68,21 @@ export default function ProfileOverviewScreen() {
|
||||||
>
|
>
|
||||||
<View style={styles.guestCard}>
|
<View style={styles.guestCard}>
|
||||||
<View style={styles.guestIconWrapper}>
|
<View style={styles.guestIconWrapper}>
|
||||||
<Ionicons name="person-circle-outline" size={80} color={Colors.primary} />
|
<Ionicons
|
||||||
|
name="person-circle-outline"
|
||||||
|
size={80}
|
||||||
|
color={Colors.primary}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.guestTitle}>Join AcuPedia</Text>
|
<Text style={styles.guestTitle}>Join Acupedia</Text>
|
||||||
<Text style={styles.guestSubtitle}>
|
<Text style={styles.guestSubtitle}>
|
||||||
Sign in or create an account to unlock premium clinical modules, track your learning progress, and customize your profile references.
|
Sign in or create an account to unlock clinical point pathways, track your learning progress, and customize your clinical references.
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.guestLoginButton}
|
style={styles.guestLoginButton}
|
||||||
onPress={() => router.push("/login")}
|
onPress={() => router.push("/login")}
|
||||||
|
activeOpacity={0.85}
|
||||||
>
|
>
|
||||||
<Text style={styles.guestLoginButtonText}>Log In</Text>
|
<Text style={styles.guestLoginButtonText}>Log In</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
@ -85,6 +90,7 @@ export default function ProfileOverviewScreen() {
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.guestSignupButton}
|
style={styles.guestSignupButton}
|
||||||
onPress={() => router.push("/register")}
|
onPress={() => router.push("/register")}
|
||||||
|
activeOpacity={0.85}
|
||||||
>
|
>
|
||||||
<Text style={styles.guestSignupButtonText}>Create Account</Text>
|
<Text style={styles.guestSignupButtonText}>Create Account</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
@ -102,6 +108,8 @@ export default function ProfileOverviewScreen() {
|
||||||
>
|
>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<ProfileHeader
|
<ProfileHeader
|
||||||
|
title="My Profile"
|
||||||
|
showBackButton={false}
|
||||||
onSettingsPress={() => {
|
onSettingsPress={() => {
|
||||||
router.push("/settings");
|
router.push("/settings");
|
||||||
}}
|
}}
|
||||||
|
|
@ -110,21 +118,11 @@ export default function ProfileOverviewScreen() {
|
||||||
<ProfileAvatar
|
<ProfileAvatar
|
||||||
name={displayName}
|
name={displayName}
|
||||||
email={displayEmail}
|
email={displayEmail}
|
||||||
onEditPress={() => {
|
|
||||||
router.push("/profile/edit");
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ProfileOverviewCard />
|
<ProfileOverviewCard />
|
||||||
|
|
||||||
<TouchableOpacity
|
<LogoutButton onPress={handleLogout} />
|
||||||
style={styles.logoutButton}
|
|
||||||
onPress={handleLogout}
|
|
||||||
activeOpacity={0.8}
|
|
||||||
>
|
|
||||||
<Ionicons name="log-out-outline" size={20} color="#DC2626" />
|
|
||||||
<Text style={styles.logoutButtonText}>Log Out</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
|
|
@ -142,40 +140,25 @@ const styles = StyleSheet.create({
|
||||||
paddingBottom: verticalScale(24),
|
paddingBottom: verticalScale(24),
|
||||||
},
|
},
|
||||||
|
|
||||||
logoutButton: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
gap: moderateScale(8),
|
|
||||||
backgroundColor: "#FEE2E2",
|
|
||||||
borderRadius: moderateScale(14),
|
|
||||||
paddingVertical: verticalScale(14),
|
|
||||||
marginTop: verticalScale(24),
|
|
||||||
},
|
|
||||||
logoutButtonText: {
|
|
||||||
fontSize: moderateScale(15),
|
|
||||||
fontWeight: "700",
|
|
||||||
color: "#DC2626",
|
|
||||||
},
|
|
||||||
|
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
paddingHorizontal: moderateScale(24),
|
paddingHorizontal: moderateScale(20),
|
||||||
paddingTop: verticalScale(20),
|
paddingTop: verticalScale(12),
|
||||||
},
|
},
|
||||||
|
|
||||||
guestContentContainer: {
|
guestContentContainer: {
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
paddingHorizontal: moderateScale(24),
|
paddingHorizontal: moderateScale(20),
|
||||||
paddingBottom: verticalScale(40),
|
paddingBottom: verticalScale(40),
|
||||||
},
|
},
|
||||||
|
|
||||||
guestCard: {
|
guestCard: {
|
||||||
backgroundColor: "#FFFFFF",
|
backgroundColor: "#FFFFFF",
|
||||||
borderRadius: moderateScale(24),
|
borderRadius: moderateScale(20),
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: "#E5E7EB",
|
borderColor: "#E5E7EB",
|
||||||
padding: moderateScale(28),
|
padding: moderateScale(26),
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
shadowColor: "#000000",
|
shadowColor: "#000000",
|
||||||
shadowOffset: { width: 0, height: 4 },
|
shadowOffset: { width: 0, height: 4 },
|
||||||
|
|
@ -183,44 +166,51 @@ const styles = StyleSheet.create({
|
||||||
shadowRadius: 10,
|
shadowRadius: 10,
|
||||||
elevation: 2,
|
elevation: 2,
|
||||||
},
|
},
|
||||||
|
|
||||||
guestIconWrapper: {
|
guestIconWrapper: {
|
||||||
marginBottom: verticalScale(16),
|
marginBottom: verticalScale(14),
|
||||||
},
|
},
|
||||||
|
|
||||||
guestTitle: {
|
guestTitle: {
|
||||||
fontSize: moderateScale(22),
|
fontSize: moderateScale(22),
|
||||||
fontWeight: "800",
|
fontWeight: "800",
|
||||||
color: Colors.textPrimary,
|
color: Colors.textPrimary,
|
||||||
marginBottom: verticalScale(8),
|
marginBottom: verticalScale(6),
|
||||||
},
|
},
|
||||||
|
|
||||||
guestSubtitle: {
|
guestSubtitle: {
|
||||||
fontSize: moderateScale(14),
|
fontSize: moderateScale(13),
|
||||||
color: Colors.textSecondary,
|
color: Colors.textSecondary,
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
lineHeight: 20,
|
lineHeight: 19,
|
||||||
marginBottom: verticalScale(28),
|
marginBottom: verticalScale(24),
|
||||||
},
|
},
|
||||||
|
|
||||||
guestLoginButton: {
|
guestLoginButton: {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
backgroundColor: Colors.primary,
|
backgroundColor: Colors.primary,
|
||||||
borderRadius: moderateScale(14),
|
borderRadius: moderateScale(12),
|
||||||
paddingVertical: verticalScale(13),
|
paddingVertical: verticalScale(13),
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
marginBottom: verticalScale(12),
|
marginBottom: verticalScale(10),
|
||||||
},
|
},
|
||||||
|
|
||||||
guestLoginButtonText: {
|
guestLoginButtonText: {
|
||||||
fontSize: moderateScale(15),
|
fontSize: moderateScale(15),
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: "#FFFFFF",
|
color: "#FFFFFF",
|
||||||
},
|
},
|
||||||
|
|
||||||
guestSignupButton: {
|
guestSignupButton: {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
backgroundColor: "#FFFFFF",
|
backgroundColor: "#FFFFFF",
|
||||||
borderWidth: 2,
|
borderWidth: 1.5,
|
||||||
borderColor: Colors.primary,
|
borderColor: Colors.primary,
|
||||||
borderRadius: moderateScale(14),
|
borderRadius: moderateScale(12),
|
||||||
paddingVertical: verticalScale(12),
|
paddingVertical: verticalScale(12),
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
|
|
||||||
guestSignupButtonText: {
|
guestSignupButtonText: {
|
||||||
fontSize: moderateScale(15),
|
fontSize: moderateScale(15),
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,150 @@
|
||||||
|
import React from "react";
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Platform,
|
||||||
|
ScrollView,
|
||||||
|
StyleSheet,
|
||||||
|
View,
|
||||||
|
} from "react-native";
|
||||||
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
import { router } from "expo-router";
|
||||||
|
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||||
|
|
||||||
|
import { Colors } from "@/theme";
|
||||||
|
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||||
|
import SettingsSection from "@/features/settings/components/SettingsSection";
|
||||||
|
import LogoutButton from "@/features/settings/components/LogoutButton";
|
||||||
|
import {
|
||||||
|
ACCOUNT_SETTINGS,
|
||||||
|
PREFERENCE_SETTINGS,
|
||||||
|
SUPPORT_SETTINGS,
|
||||||
|
} from "@/features/settings/constants/settingsData";
|
||||||
|
import { SettingsItem } from "@/features/settings/types";
|
||||||
|
import { useAuthStore } from "@/store/auth.store";
|
||||||
|
import { useSettingsStore } from "@/store/settings.store";
|
||||||
|
|
||||||
|
export default function SettingsScreen() {
|
||||||
|
const user = useAuthStore((state) => state.user);
|
||||||
|
const logout = useAuthStore((state) => state.logout);
|
||||||
|
|
||||||
|
const accordionDefaultExpanded = useSettingsStore(
|
||||||
|
(state) => state.accordionDefaultExpanded
|
||||||
|
);
|
||||||
|
const setAccordionDefaultExpanded = useSettingsStore(
|
||||||
|
(state) => state.setAccordionDefaultExpanded
|
||||||
|
);
|
||||||
|
|
||||||
|
const contentPreviewEnabled = useSettingsStore(
|
||||||
|
(state) => state.contentPreviewEnabled
|
||||||
|
);
|
||||||
|
const setContentPreviewEnabled = useSettingsStore(
|
||||||
|
(state) => state.setContentPreviewEnabled
|
||||||
|
);
|
||||||
|
|
||||||
|
// Clinical Preview Mode is strictly gated to admin role
|
||||||
|
const isAdmin = user?.roles?.includes("admin") ?? false;
|
||||||
|
|
||||||
|
const appPreferenceItems: SettingsItem[] = [
|
||||||
|
{
|
||||||
|
id: "expand-accordions",
|
||||||
|
title: "Expand Sections by Default",
|
||||||
|
subtitle: "Keep all detail accordions open while reading",
|
||||||
|
icon: "list-outline",
|
||||||
|
isSwitch: true,
|
||||||
|
switchValue: accordionDefaultExpanded,
|
||||||
|
onSwitchChange: (val) => setAccordionDefaultExpanded(val),
|
||||||
|
},
|
||||||
|
...(isAdmin
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
id: "clinical-preview",
|
||||||
|
title: "Clinical Draft / Preview Mode",
|
||||||
|
subtitle: "View unpublished modules & draft revisions",
|
||||||
|
icon: "flask-outline" as const,
|
||||||
|
isSwitch: true,
|
||||||
|
switchValue: contentPreviewEnabled,
|
||||||
|
onSwitchChange: (val: boolean) => setContentPreviewEnabled(val),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
...PREFERENCE_SETTINGS,
|
||||||
|
];
|
||||||
|
|
||||||
|
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 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SafeAreaView style={styles.safeArea}>
|
||||||
|
<ScrollView
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
contentContainerStyle={styles.contentContainer}
|
||||||
|
keyboardShouldPersistTaps="handled"
|
||||||
|
>
|
||||||
|
<View style={styles.container}>
|
||||||
|
<SettingsHeader title="Settings" />
|
||||||
|
|
||||||
|
<SettingsSection
|
||||||
|
title="Account Settings"
|
||||||
|
items={ACCOUNT_SETTINGS}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<SettingsSection
|
||||||
|
title="App Preferences"
|
||||||
|
items={appPreferenceItems}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<SettingsSection
|
||||||
|
title="Support & Info"
|
||||||
|
items={SUPPORT_SETTINGS}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<LogoutButton onPress={handleLogout} />
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
</SafeAreaView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
safeArea: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: Colors.background,
|
||||||
|
},
|
||||||
|
contentContainer: {
|
||||||
|
flexGrow: 1,
|
||||||
|
paddingBottom: verticalScale(32),
|
||||||
|
},
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
paddingHorizontal: moderateScale(20),
|
||||||
|
paddingTop: verticalScale(12),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -7,7 +7,7 @@ import {
|
||||||
setApiAccessToken,
|
setApiAccessToken,
|
||||||
} from "@/api/access-token";
|
} from "@/api/access-token";
|
||||||
import { getAccessMe } from "@/features/access/api/access.api";
|
import { getAccessMe } from "@/features/access/api/access.api";
|
||||||
import { isUnauthorizedApiError } from "@/api/error-utils";
|
import { getApiErrorStatus, isUnauthorizedApiError } from "@/api/error-utils";
|
||||||
import { setUnauthorizedHandler } from "@/api/session-events";
|
import { setUnauthorizedHandler } from "@/api/session-events";
|
||||||
import { getMe } from "@/features/auth/api/auth.api";
|
import { getMe } from "@/features/auth/api/auth.api";
|
||||||
|
|
||||||
|
|
@ -167,8 +167,11 @@ export const useAuthStore = create<AuthStore>()(
|
||||||
get().refreshAccess(),
|
get().refreshAccess(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const isSessionInvalid = (reason: unknown) =>
|
||||||
|
isUnauthorizedApiError(reason) || getApiErrorStatus(reason) === 404;
|
||||||
|
|
||||||
const unauthorized =
|
const unauthorized =
|
||||||
(identityResult.status === "rejected" && isUnauthorizedApiError(identityResult.reason)) ||
|
(identityResult.status === "rejected" && isSessionInvalid(identityResult.reason)) ||
|
||||||
(accessResult.status === "rejected" && isUnauthorizedApiError(accessResult.reason));
|
(accessResult.status === "rejected" && isUnauthorizedApiError(accessResult.reason));
|
||||||
|
|
||||||
if (unauthorized) {
|
if (unauthorized) {
|
||||||
|
|
@ -223,10 +226,14 @@ export const useAuthStore = create<AuthStore>()(
|
||||||
get().refreshAccess(),
|
get().refreshAccess(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Identity 401/invalid-token is handled conservatively by clearing the
|
// Identity 401/404/invalid-token is handled conservatively by clearing the
|
||||||
// local session. Access failures are non-fatal and leave prior access
|
// local session. Access failures are non-fatal and leave prior access
|
||||||
// state intact for transient-network resilience.
|
// state intact for transient-network resilience.
|
||||||
if (identityResult.status === "rejected" && isUnauthorizedApiError(identityResult.reason)) {
|
if (
|
||||||
|
identityResult.status === "rejected" &&
|
||||||
|
(isUnauthorizedApiError(identityResult.reason) ||
|
||||||
|
getApiErrorStatus(identityResult.reason) === 404)
|
||||||
|
) {
|
||||||
get().logout();
|
get().logout();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,71 @@
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
|
import { createJSONStorage, persist } from "zustand/middleware";
|
||||||
|
|
||||||
import { SettingsState } from "./types";
|
import { NotificationPreferences, SettingsState } from "./types";
|
||||||
|
|
||||||
interface SettingsStore extends SettingsState {
|
interface SettingsStore extends SettingsState {
|
||||||
setTheme: (theme: "light" | "dark") => void;
|
setTheme: (theme: "light" | "dark" | "system") => void;
|
||||||
setContentPreviewEnabled: (enabled: boolean) => void;
|
setContentPreviewEnabled: (enabled: boolean) => void;
|
||||||
|
setAccordionDefaultExpanded: (expanded: boolean) => void;
|
||||||
|
toggleAccordionDefaultExpanded: () => void;
|
||||||
|
setNotificationPreference: (
|
||||||
|
key: keyof NotificationPreferences,
|
||||||
|
value: boolean
|
||||||
|
) => void;
|
||||||
|
setLanguage: (language: string) => void;
|
||||||
|
resetSettings: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSettingsStore = create<SettingsStore>((set) => ({
|
const DEFAULT_NOTIFICATIONS: NotificationPreferences = {
|
||||||
|
push: true,
|
||||||
|
clinicalUpdates: true,
|
||||||
|
weeklyDigest: false,
|
||||||
|
sound: true,
|
||||||
|
vibration: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const DEFAULT_SETTINGS: SettingsState = {
|
||||||
theme: "light",
|
theme: "light",
|
||||||
contentPreviewEnabled: false,
|
contentPreviewEnabled: false,
|
||||||
|
accordionDefaultExpanded: false,
|
||||||
|
notifications: DEFAULT_NOTIFICATIONS,
|
||||||
|
language: "en",
|
||||||
|
};
|
||||||
|
|
||||||
setTheme: (theme) =>
|
export const useSettingsStore = create<SettingsStore>()(
|
||||||
set({
|
persist(
|
||||||
theme,
|
(set) => ({
|
||||||
|
...DEFAULT_SETTINGS,
|
||||||
|
|
||||||
|
setTheme: (theme) => set({ theme }),
|
||||||
|
|
||||||
|
setContentPreviewEnabled: (contentPreviewEnabled) =>
|
||||||
|
set({ contentPreviewEnabled }),
|
||||||
|
|
||||||
|
setAccordionDefaultExpanded: (accordionDefaultExpanded) =>
|
||||||
|
set({ accordionDefaultExpanded }),
|
||||||
|
|
||||||
|
toggleAccordionDefaultExpanded: () =>
|
||||||
|
set((state) => ({
|
||||||
|
accordionDefaultExpanded: !state.accordionDefaultExpanded,
|
||||||
|
})),
|
||||||
|
|
||||||
|
setNotificationPreference: (key, value) =>
|
||||||
|
set((state) => ({
|
||||||
|
notifications: {
|
||||||
|
...state.notifications,
|
||||||
|
[key]: value,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
|
||||||
|
setLanguage: (language) => set({ language }),
|
||||||
|
|
||||||
|
resetSettings: () => set(DEFAULT_SETTINGS),
|
||||||
}),
|
}),
|
||||||
|
{
|
||||||
setContentPreviewEnabled: (contentPreviewEnabled) =>
|
name: "acupedia-settings-storage",
|
||||||
set({ contentPreviewEnabled }),
|
storage: createJSONStorage(() => AsyncStorage),
|
||||||
}));
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
@ -108,7 +108,18 @@ export interface AppState {
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SettingsState {
|
export interface NotificationPreferences {
|
||||||
theme: "light" | "dark";
|
push: boolean;
|
||||||
contentPreviewEnabled: boolean;
|
clinicalUpdates: boolean;
|
||||||
|
weeklyDigest: boolean;
|
||||||
|
sound: boolean;
|
||||||
|
vibration: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SettingsState {
|
||||||
|
theme: "light" | "dark" | "system";
|
||||||
|
contentPreviewEnabled: boolean;
|
||||||
|
accordionDefaultExpanded: boolean;
|
||||||
|
notifications: NotificationPreferences;
|
||||||
|
language: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue