Compare commits
No commits in common. "f0c7e446d65529293980e891b3cd0bb8458cf19b" and "f2ef4bb25e7ce5a7ae529b16facd4d0f58335383" have entirely different histories.
f0c7e446d6
...
f2ef4bb25e
2
.env
2
.env
|
|
@ -19,7 +19,7 @@
|
||||||
# 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=true
|
# EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=false
|
||||||
|
|
||||||
# Local Dev
|
# Local Dev
|
||||||
EXPO_PUBLIC_API_URL=http://localhost:8000/api
|
EXPO_PUBLIC_API_URL=http://localhost:8000/api
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ yarn-error.*
|
||||||
.env*.local
|
.env*.local
|
||||||
.idea/
|
.idea/
|
||||||
.env
|
.env
|
||||||
package-locked.json
|
|
||||||
|
|
||||||
# typescript
|
# typescript
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
|
|
|
||||||
9
app.json
9
app.json
|
|
@ -26,6 +26,7 @@
|
||||||
},
|
},
|
||||||
"predictiveBackGestureEnabled": false,
|
"predictiveBackGestureEnabled": false,
|
||||||
"package": "com.anonymous.acupedia",
|
"package": "com.anonymous.acupedia",
|
||||||
|
"usesCleartextTraffic": true,
|
||||||
"allowBackup": false
|
"allowBackup": false
|
||||||
},
|
},
|
||||||
"web": {
|
"web": {
|
||||||
|
|
@ -41,14 +42,6 @@
|
||||||
"image": "./assets/images/splash-icon.png",
|
"image": "./assets/images/splash-icon.png",
|
||||||
"imageWidth": 76
|
"imageWidth": 76
|
||||||
}
|
}
|
||||||
],
|
|
||||||
[
|
|
||||||
"expo-build-properties",
|
|
||||||
{
|
|
||||||
"android": {
|
|
||||||
"usesCleartextTraffic": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"experiments": {
|
"experiments": {
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
42
package.json
42
package.json
|
|
@ -1,32 +1,22 @@
|
||||||
{
|
{
|
||||||
"name": "AcuPedia",
|
"name": "my-app",
|
||||||
"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.1.1",
|
"expo": "~57.0.20",
|
||||||
"@react-native-async-storage/async-storage": "~2.2.0",
|
"expo-constants": "~57.0.17",
|
||||||
"@react-native-community/netinfo": "12.0.1",
|
"expo-device": "~57.0.1",
|
||||||
"@tanstack/react-query": "^5.101.2",
|
"expo-font": "~57.0.3",
|
||||||
"axios": "^1.18.1",
|
|
||||||
"expo": "~57.0.3",
|
|
||||||
"expo-build-properties": "~57.0.22",
|
|
||||||
"expo-constants": "~57.0.19",
|
|
||||||
"expo-device": "~57.0.2",
|
|
||||||
"expo-font": "~57.0.4",
|
|
||||||
"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.2",
|
"expo-linking": "~57.0.9",
|
||||||
"expo-linking": "~57.0.11",
|
"expo-router": "~57.0.19",
|
||||||
"expo-router": "~57.0.23",
|
"expo-splash-screen": "~57.0.8",
|
||||||
"expo-screen-capture": "~57.0.3",
|
|
||||||
"expo-secure-store": "~57.0.4",
|
|
||||||
"expo-splash-screen": "~57.0.9",
|
|
||||||
"expo-status-bar": "~57.0.1",
|
"expo-status-bar": "~57.0.1",
|
||||||
"expo-symbols": "~57.0.2",
|
"expo-symbols": "~57.0.2",
|
||||||
"expo-system-ui": "~57.0.4",
|
"expo-system-ui": "~57.0.3",
|
||||||
"expo-web-browser": "~57.0.3",
|
"expo-web-browser": "~57.0.2",
|
||||||
"react": "19.2.3",
|
"react": "19.2.3",
|
||||||
"react-dom": "19.2.3",
|
"react-dom": "19.2.3",
|
||||||
"react-native": "0.86.3",
|
"react-native": "0.86.3",
|
||||||
|
|
@ -34,10 +24,18 @@
|
||||||
"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.3",
|
|
||||||
"react-native-worklets": "0.10.1",
|
|
||||||
"zustand": "^4.5.7"
|
"zustand": "^4.5.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
|
|
@ -105,10 +105,7 @@ 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({
|
||||||
|
|
@ -118,26 +115,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,186 +0,0 @@
|
||||||
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),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
import EditProfileScreen from "@/screens/profile/EditProfileScreen";
|
|
||||||
|
|
||||||
export default function EditProfileRoute() {
|
|
||||||
return <EditProfileScreen />;
|
|
||||||
}
|
|
||||||
|
|
@ -1,159 +0,0 @@
|
||||||
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",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
@ -1,239 +0,0 @@
|
||||||
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),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
import SettingsScreen from "@/screens/settings/SettingsScreen";
|
|
||||||
|
|
||||||
export default function SettingsRoute() {
|
|
||||||
return <SettingsScreen />;
|
|
||||||
}
|
|
||||||
|
|
@ -1,232 +0,0 @@
|
||||||
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),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
@ -1,144 +0,0 @@
|
||||||
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),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
@ -1,171 +0,0 @@
|
||||||
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,11 +1,13 @@
|
||||||
import React, { useCallback, useMemo, useState } from "react";
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import {
|
import {
|
||||||
|
ActivityIndicator,
|
||||||
Alert,
|
Alert,
|
||||||
Linking,
|
Linking,
|
||||||
Platform,
|
Platform,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
|
TextInput,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
View,
|
View,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
|
|
@ -17,12 +19,26 @@ import Constants from "expo-constants";
|
||||||
|
|
||||||
import { Colors } from "@/theme";
|
import { Colors } from "@/theme";
|
||||||
import { useAuthStore } from "@/store/auth.store";
|
import { useAuthStore } from "@/store/auth.store";
|
||||||
|
import { calculateCart } from "@/features/commerce";
|
||||||
|
import type { CartCalculationResponse } from "@/features/commerce";
|
||||||
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||||
|
|
||||||
function param(value: string | string[] | undefined): string {
|
function param(value: string | string[] | undefined): string {
|
||||||
return typeof value === "string" ? value : "";
|
return typeof value === "string" ? value : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function money(value: number, currency: string): string {
|
||||||
|
try {
|
||||||
|
return new Intl.NumberFormat("en-IN", {
|
||||||
|
style: "currency",
|
||||||
|
currency,
|
||||||
|
maximumFractionDigits: 2,
|
||||||
|
}).format(value);
|
||||||
|
} catch {
|
||||||
|
return `${currency} ${value.toFixed(2)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function resolveStorefrontUrl(): string {
|
function resolveStorefrontUrl(): string {
|
||||||
const envUrl = process.env.EXPO_PUBLIC_STOREFRONT_URL?.trim();
|
const envUrl = process.env.EXPO_PUBLIC_STOREFRONT_URL?.trim();
|
||||||
if (envUrl) return envUrl;
|
if (envUrl) return envUrl;
|
||||||
|
|
@ -62,10 +78,15 @@ export default function SubscriptionScreen() {
|
||||||
const moduleId = param(params.moduleId);
|
const moduleId = param(params.moduleId);
|
||||||
const moduleCode = param(params.moduleCode);
|
const moduleCode = param(params.moduleCode);
|
||||||
const title = param(params.title) || "Clinical Module";
|
const title = param(params.title) || "Clinical Module";
|
||||||
|
const category = param(params.category);
|
||||||
const description = param(params.desc);
|
const description = param(params.desc);
|
||||||
const planCode = param(params.planCode).trim().toUpperCase();
|
const planCode = param(params.planCode).trim().toUpperCase();
|
||||||
|
|
||||||
|
const [couponCode, setCouponCode] = useState("");
|
||||||
|
const [pricing, setPricing] = useState<CartCalculationResponse | null>(null);
|
||||||
|
const [loadingPricing, setLoadingPricing] = useState(false);
|
||||||
const [openingCheckout, setOpeningCheckout] = useState(false);
|
const [openingCheckout, setOpeningCheckout] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
const unlocked = useMemo(() => {
|
const unlocked = useMemo(() => {
|
||||||
if (!accessToken) return false;
|
if (!accessToken) return false;
|
||||||
|
|
@ -73,6 +94,35 @@ export default function SubscriptionScreen() {
|
||||||
return false;
|
return false;
|
||||||
}, [access, accessToken, moduleCode]);
|
}, [access, accessToken, moduleCode]);
|
||||||
|
|
||||||
|
const loadPricing = useCallback(async (coupon?: string) => {
|
||||||
|
if (!planCode) {
|
||||||
|
setPricing(null);
|
||||||
|
setError("This module does not have a commerce plan configured.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setLoadingPricing(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
const response = await calculateCart({
|
||||||
|
cart_item_codes: [planCode],
|
||||||
|
coupon_code: coupon?.trim() || null,
|
||||||
|
currency: "INR",
|
||||||
|
});
|
||||||
|
setPricing(response);
|
||||||
|
} catch (err: any) {
|
||||||
|
const detail = err?.response?.data?.detail;
|
||||||
|
setError(typeof detail === "string" ? detail : "Unable to load current subscription pricing.");
|
||||||
|
setPricing(null);
|
||||||
|
} finally {
|
||||||
|
setLoadingPricing(false);
|
||||||
|
}
|
||||||
|
}, [planCode]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void loadPricing();
|
||||||
|
}, [loadPricing]);
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
|
|
@ -110,6 +160,7 @@ export default function SubscriptionScreen() {
|
||||||
const query = new URLSearchParams();
|
const query = new URLSearchParams();
|
||||||
query.set("token", accessToken);
|
query.set("token", accessToken);
|
||||||
query.set("planCode", planCode);
|
query.set("planCode", planCode);
|
||||||
|
if (couponCode.trim()) query.set("couponCode", couponCode.trim().toUpperCase());
|
||||||
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
|
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
|
||||||
if (apiUrl) query.set("apiUrl", apiUrl);
|
if (apiUrl) query.set("apiUrl", apiUrl);
|
||||||
if (moduleId) query.set("moduleId", moduleId);
|
if (moduleId) query.set("moduleId", moduleId);
|
||||||
|
|
@ -129,60 +180,102 @@ export default function SubscriptionScreen() {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView style={styles.safeArea} edges={["top", "bottom", "left", "right"]}>
|
<SafeAreaView style={styles.safeArea} edges={["top", "left", "right"]}>
|
||||||
<View style={styles.header}>
|
<View style={styles.header}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity onPress={() => router.back()} style={styles.backButton}>
|
||||||
onPress={() => router.back()}
|
|
||||||
style={styles.backButton}
|
|
||||||
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
|
||||||
>
|
|
||||||
<Ionicons name="chevron-back" size={24} color={Colors.textPrimary} />
|
<Ionicons name="chevron-back" size={24} color={Colors.textPrimary} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<Text style={styles.headerTitle} numberOfLines={1}>
|
<Text style={styles.headerTitle}>Subscription</Text>
|
||||||
{title}
|
|
||||||
</Text>
|
|
||||||
<View style={styles.placeholder} />
|
<View style={styles.placeholder} />
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView contentContainerStyle={styles.content} showsVerticalScrollIndicator={false}>
|
||||||
contentContainerStyle={styles.scrollContent}
|
<View style={styles.iconContainer}>
|
||||||
showsVerticalScrollIndicator={false}
|
<Ionicons name={unlocked ? "checkmark-circle-outline" : "card-outline"} size={58} color={Colors.primary} />
|
||||||
bounces={false}
|
|
||||||
>
|
|
||||||
<View style={styles.centerContainer}>
|
|
||||||
<View style={styles.iconCircle}>
|
|
||||||
<Ionicons
|
|
||||||
name={unlocked ? "checkmark-circle" : "lock-closed"}
|
|
||||||
size={moderateScale(32)}
|
|
||||||
color={Colors.primary}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
|
<Text style={styles.title}>{unlocked ? `${title} is unlocked` : `Unlock ${title}`}</Text>
|
||||||
<Text style={styles.title}>
|
<Text style={styles.subtitle}>
|
||||||
{unlocked ? `${title} is Unlocked` : `Unlock ${title}`}
|
{unlocked
|
||||||
|
? "Your current entitlement already includes this module."
|
||||||
|
: "Pricing and discounts below are calculated by the current commerce API."}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
{description ? (
|
{(category || description) ? (
|
||||||
<Text style={styles.descriptionText}>{description}</Text>
|
<View style={styles.infoBox}>
|
||||||
) : null}
|
<Ionicons name="information-circle-outline" size={20} color={Colors.primary} />
|
||||||
|
<View style={styles.infoText}>
|
||||||
|
{category ? <Text style={styles.infoTitle}>{category}</Text> : null}
|
||||||
|
{description ? <Text style={styles.infoDescription}>{description}</Text> : null}
|
||||||
|
{planCode ? <Text style={styles.planCode}>Plan: {planCode}</Text> : null}
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
<View style={styles.footer}>
|
|
||||||
{!unlocked ? (
|
{!unlocked ? (
|
||||||
|
<>
|
||||||
|
<View style={styles.pricingCard}>
|
||||||
|
{loadingPricing ? (
|
||||||
|
<View style={styles.loadingRow}>
|
||||||
|
<ActivityIndicator color={Colors.primary} />
|
||||||
|
<Text style={styles.loadingText}>Loading current pricing…</Text>
|
||||||
|
</View>
|
||||||
|
) : pricing ? (
|
||||||
|
<>
|
||||||
|
{pricing.cart_items.map((item) => (
|
||||||
|
<View key={item.code} style={styles.priceRow}>
|
||||||
|
<Text style={styles.priceLabel}>{item.name}</Text>
|
||||||
|
<Text style={styles.priceValue}>{money(item.price, pricing.currency)}</Text>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
<View style={styles.divider} />
|
||||||
|
<View style={styles.priceRow}><Text style={styles.secondaryLabel}>Subtotal</Text><Text style={styles.secondaryValue}>{money(pricing.base_subtotal, pricing.currency)}</Text></View>
|
||||||
|
{pricing.total_discounts > 0 ? <View style={styles.priceRow}><Text style={styles.discountLabel}>Discounts</Text><Text style={styles.discountValue}>− {money(pricing.total_discounts, pricing.currency)}</Text></View> : null}
|
||||||
|
{pricing.convenience_fee > 0 ? <View style={styles.priceRow}><Text style={styles.secondaryLabel}>Convenience fee</Text><Text style={styles.secondaryValue}>{money(pricing.convenience_fee, pricing.currency)}</Text></View> : null}
|
||||||
|
<View style={styles.priceRow}><Text style={styles.secondaryLabel}>GST</Text><Text style={styles.secondaryValue}>{money(pricing.gst_amount, pricing.currency)}</Text></View>
|
||||||
|
<View style={styles.divider} />
|
||||||
|
<View style={styles.priceRow}><Text style={styles.totalLabel}>Total</Text><Text style={styles.totalValue}>{money(pricing.grand_total, pricing.currency)}</Text></View>
|
||||||
|
{pricing.coupon_applied ? <Text style={styles.appliedText}>Coupon applied: {pricing.coupon_applied}</Text> : null}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Text style={styles.errorText}>{error ?? "Pricing is unavailable."}</Text>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.couponRow}>
|
||||||
|
<TextInput
|
||||||
|
value={couponCode}
|
||||||
|
onChangeText={setCouponCode}
|
||||||
|
autoCapitalize="characters"
|
||||||
|
placeholder="Coupon code"
|
||||||
|
style={styles.couponInput}
|
||||||
|
/>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={styles.applyButton}
|
||||||
|
onPress={() => void loadPricing(couponCode)}
|
||||||
|
disabled={loadingPricing}
|
||||||
|
>
|
||||||
|
<Text style={styles.applyText}>Apply</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{error && pricing ? <Text style={styles.inlineError}>{error}</Text> : null}
|
||||||
|
|
||||||
|
<View style={styles.buttonContainer}>
|
||||||
|
{openingCheckout ? <ActivityIndicator color={Colors.primary} /> : (
|
||||||
<PrimaryButton
|
<PrimaryButton
|
||||||
title={accessToken ? "Continue to Checkout" : "Log In to Subscribe"}
|
title={accessToken ? "Continue to Checkout" : "Log In to Subscribe"}
|
||||||
onPress={() => void handleCheckout()}
|
onPress={() => void handleCheckout()}
|
||||||
disabled={!planCode}
|
disabled={loadingPricing || !planCode}
|
||||||
loading={openingCheckout}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<PrimaryButton
|
|
||||||
title="Back to Modules"
|
|
||||||
onPress={() => router.replace("/modules")}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<View style={styles.buttonContainer}>
|
||||||
|
<PrimaryButton title="Back to Modules" onPress={() => router.replace("/modules")} />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</ScrollView>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -190,73 +283,48 @@ export default function SubscriptionScreen() {
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
safeArea: { flex: 1, backgroundColor: "#FFFFFF" },
|
safeArea: { flex: 1, backgroundColor: "#FFFFFF" },
|
||||||
header: {
|
header: {
|
||||||
height: moderateScale(56),
|
minHeight: 64,
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
paddingHorizontal: moderateScale(16),
|
paddingHorizontal: moderateScale(16),
|
||||||
|
paddingTop: Platform.OS === "web" ? 14 : moderateScale(8),
|
||||||
|
paddingBottom: moderateScale(8),
|
||||||
borderBottomWidth: 1,
|
borderBottomWidth: 1,
|
||||||
borderBottomColor: "#F1F5F9",
|
borderBottomColor: "#ECECEC",
|
||||||
backgroundColor: "#FFFFFF",
|
|
||||||
},
|
|
||||||
backButton: {
|
|
||||||
width: moderateScale(36),
|
|
||||||
height: moderateScale(36),
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
},
|
|
||||||
headerTitle: {
|
|
||||||
flex: 1,
|
|
||||||
fontSize: moderateScale(17),
|
|
||||||
fontWeight: "700",
|
|
||||||
color: Colors.textPrimary,
|
|
||||||
textAlign: "center",
|
|
||||||
marginHorizontal: moderateScale(8),
|
|
||||||
},
|
|
||||||
placeholder: { width: moderateScale(36) },
|
|
||||||
scrollContent: {
|
|
||||||
flexGrow: 1,
|
|
||||||
justifyContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
paddingHorizontal: moderateScale(24),
|
|
||||||
paddingVertical: verticalScale(24),
|
|
||||||
},
|
|
||||||
centerContainer: {
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
maxWidth: moderateScale(360),
|
|
||||||
width: "100%",
|
|
||||||
},
|
|
||||||
iconCircle: {
|
|
||||||
width: moderateScale(68),
|
|
||||||
height: moderateScale(68),
|
|
||||||
borderRadius: moderateScale(34),
|
|
||||||
backgroundColor: "#E8F5E9",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
marginBottom: verticalScale(20),
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
fontSize: moderateScale(22),
|
|
||||||
fontWeight: "800",
|
|
||||||
color: Colors.textPrimary,
|
|
||||||
textAlign: "center",
|
|
||||||
lineHeight: moderateScale(28),
|
|
||||||
},
|
|
||||||
descriptionText: {
|
|
||||||
fontSize: moderateScale(15),
|
|
||||||
color: Colors.textSecondary,
|
|
||||||
textAlign: "center",
|
|
||||||
lineHeight: moderateScale(23),
|
|
||||||
marginTop: verticalScale(12),
|
|
||||||
paddingHorizontal: moderateScale(8),
|
|
||||||
},
|
|
||||||
footer: {
|
|
||||||
paddingHorizontal: moderateScale(20),
|
|
||||||
paddingTop: verticalScale(12),
|
|
||||||
paddingBottom: Platform.OS === "ios" ? verticalScale(8) : verticalScale(16),
|
|
||||||
borderTopWidth: 1,
|
|
||||||
borderTopColor: "#F1F5F9",
|
|
||||||
backgroundColor: "#FFFFFF",
|
backgroundColor: "#FFFFFF",
|
||||||
},
|
},
|
||||||
|
backButton: { padding: 4 },
|
||||||
|
headerTitle: { fontSize: moderateScale(18), fontWeight: "700", color: Colors.textPrimary },
|
||||||
|
placeholder: { width: 32 },
|
||||||
|
content: { paddingHorizontal: moderateScale(24), paddingTop: verticalScale(28), paddingBottom: verticalScale(40) },
|
||||||
|
iconContainer: { alignItems: "center", marginBottom: verticalScale(16) },
|
||||||
|
title: { fontSize: moderateScale(24), fontWeight: "800", color: Colors.textPrimary, textAlign: "center" },
|
||||||
|
subtitle: { fontSize: moderateScale(14), color: Colors.textSecondary, textAlign: "center", lineHeight: 20, marginTop: verticalScale(8), marginBottom: verticalScale(22) },
|
||||||
|
infoBox: { flexDirection: "row", backgroundColor: "#EEF2FF", borderRadius: moderateScale(14), padding: moderateScale(14), marginBottom: verticalScale(18) },
|
||||||
|
infoText: { flex: 1, marginLeft: moderateScale(10) },
|
||||||
|
infoTitle: { fontSize: moderateScale(14), fontWeight: "700", color: Colors.textPrimary },
|
||||||
|
infoDescription: { marginTop: 3, fontSize: moderateScale(12), color: Colors.textSecondary, lineHeight: 18 },
|
||||||
|
planCode: { marginTop: 5, fontSize: moderateScale(11), color: Colors.primary, fontWeight: "600" },
|
||||||
|
pricingCard: { backgroundColor: "#FFFFFF", borderRadius: moderateScale(16), borderWidth: 1, borderColor: "#E5E7EB", padding: moderateScale(16) },
|
||||||
|
loadingRow: { flexDirection: "row", alignItems: "center", justifyContent: "center", paddingVertical: verticalScale(16) },
|
||||||
|
loadingText: { marginLeft: moderateScale(10), color: Colors.textSecondary, fontSize: moderateScale(13) },
|
||||||
|
priceRow: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", marginVertical: verticalScale(5) },
|
||||||
|
priceLabel: { flex: 1, fontSize: moderateScale(14), fontWeight: "700", color: Colors.textPrimary, marginRight: 10 },
|
||||||
|
priceValue: { fontSize: moderateScale(14), fontWeight: "700", color: Colors.textPrimary },
|
||||||
|
secondaryLabel: { fontSize: moderateScale(13), color: Colors.textSecondary },
|
||||||
|
secondaryValue: { fontSize: moderateScale(13), color: Colors.textPrimary },
|
||||||
|
discountLabel: { fontSize: moderateScale(13), color: "#15803D" },
|
||||||
|
discountValue: { fontSize: moderateScale(13), color: "#15803D", fontWeight: "600" },
|
||||||
|
totalLabel: { fontSize: moderateScale(15), fontWeight: "800", color: Colors.textPrimary },
|
||||||
|
totalValue: { fontSize: moderateScale(18), fontWeight: "800", color: Colors.primary },
|
||||||
|
divider: { height: 1, backgroundColor: "#ECECEC", marginVertical: verticalScale(8) },
|
||||||
|
appliedText: { marginTop: verticalScale(8), fontSize: moderateScale(12), color: "#15803D", fontWeight: "600" },
|
||||||
|
errorText: { fontSize: moderateScale(13), color: "#B91C1C", textAlign: "center", paddingVertical: verticalScale(14) },
|
||||||
|
couponRow: { flexDirection: "row", marginTop: verticalScale(14) },
|
||||||
|
couponInput: { flex: 1, minHeight: 46, backgroundColor: "#FFFFFF", borderWidth: 1, borderColor: "#D1D5DB", borderRadius: moderateScale(12), paddingHorizontal: moderateScale(12), color: Colors.textPrimary },
|
||||||
|
applyButton: { marginLeft: moderateScale(10), minWidth: 78, minHeight: 46, alignItems: "center", justifyContent: "center", backgroundColor: "#EEF2FF", borderRadius: moderateScale(12) },
|
||||||
|
applyText: { fontSize: moderateScale(13), fontWeight: "700", color: Colors.primary },
|
||||||
|
inlineError: { marginTop: verticalScale(8), fontSize: moderateScale(12), color: "#B91C1C" },
|
||||||
|
buttonContainer: { marginTop: verticalScale(24) },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import { ScrollView, StyleSheet } from "react-native";
|
|
||||||
|
|
||||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
|
||||||
import { asString, humanizeKey } from "../helpers/value";
|
|
||||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
|
||||||
import { ContentValue } from "../shared/ContentValue";
|
|
||||||
import { Hero } from "../shared/Hero";
|
|
||||||
import { SectionCard } from "../shared/SectionCard";
|
|
||||||
|
|
||||||
const EXCLUDED_KEYS = new Set(["code"]);
|
|
||||||
|
|
||||||
export function TcmPatternDetailRenderer({
|
|
||||||
content,
|
|
||||||
data,
|
|
||||||
presentationAttributes,
|
|
||||||
}: DetailRendererProps) {
|
|
||||||
const title =
|
|
||||||
asString(data.name) ||
|
|
||||||
asString(data.title) ||
|
|
||||||
content.title ||
|
|
||||||
"TCM Pattern";
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ScrollView
|
|
||||||
contentContainerStyle={styles.content}
|
|
||||||
showsVerticalScrollIndicator={false}
|
|
||||||
>
|
|
||||||
<Hero title={title} subtitle={content.summary ?? undefined} />
|
|
||||||
|
|
||||||
{Object.entries(data)
|
|
||||||
.filter(([key]) => !EXCLUDED_KEYS.has(key))
|
|
||||||
.map(([key, value]) => (
|
|
||||||
<SectionCard key={key} title={humanizeKey(key)}>
|
|
||||||
<ContentValue value={value} />
|
|
||||||
</SectionCard>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<ContentLinkAttributeSections
|
|
||||||
data={data}
|
|
||||||
presentationAttributes={presentationAttributes}
|
|
||||||
/>
|
|
||||||
</ScrollView>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
content: {
|
|
||||||
paddingHorizontal: 18,
|
|
||||||
paddingTop: 16,
|
|
||||||
paddingBottom: 40,
|
|
||||||
gap: 14,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
@ -45,7 +45,6 @@ import { TwelveChannelsDetailRenderer } from "./details/TwelveChannelsDetailRend
|
||||||
import { ThreeBurnersCollectionRenderer, ThreeBurnersCardRenderer } from "./collections/ThreeBurnersRenderers";
|
import { ThreeBurnersCollectionRenderer, ThreeBurnersCardRenderer } from "./collections/ThreeBurnersRenderers";
|
||||||
import { ThreeBurnersDetailRenderer } from "./details/ThreeBurnersDetailRenderer";
|
import { ThreeBurnersDetailRenderer } from "./details/ThreeBurnersDetailRenderer";
|
||||||
import { SixStagesDetailRenderer } from "./details/SixStagesDetailRenderer";
|
import { SixStagesDetailRenderer } from "./details/SixStagesDetailRenderer";
|
||||||
import { TcmPatternDetailRenderer } from "./details/TcmPatternDetailRenderer";
|
|
||||||
|
|
||||||
export const collectionRenderers: Readonly<Record<string, CollectionRendererComponent>> = Object.freeze({
|
export const collectionRenderers: Readonly<Record<string, CollectionRendererComponent>> = Object.freeze({
|
||||||
module_catalog_collection: ModuleCatalogCollectionRenderer,
|
module_catalog_collection: ModuleCatalogCollectionRenderer,
|
||||||
|
|
@ -173,7 +172,6 @@ export const detailRenderers: Readonly<Record<string, DetailRendererComponent>>
|
||||||
m0017_ct0001_detail: ThreeBurnersDetailRenderer,
|
m0017_ct0001_detail: ThreeBurnersDetailRenderer,
|
||||||
m0017_ct0002_detail: ThreeBurnersDetailRenderer,
|
m0017_ct0002_detail: ThreeBurnersDetailRenderer,
|
||||||
six_stages_detail: SixStagesDetailRenderer,
|
six_stages_detail: SixStagesDetailRenderer,
|
||||||
tcm_pattern_detail: TcmPatternDetailRenderer,
|
|
||||||
});
|
});
|
||||||
function reportMissingRenderer(kind: string, code?: string | null) {
|
function reportMissingRenderer(kind: string, code?: string | null) {
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
|
|
@ -339,12 +337,6 @@ export function resolveDetailRenderer(
|
||||||
) {
|
) {
|
||||||
return SixStagesDetailRenderer;
|
return SixStagesDetailRenderer;
|
||||||
}
|
}
|
||||||
if( normalizedTemplate === "m0012_ct0014" ||
|
|
||||||
(normalizedModule === "m0012" && (code === "tcm_pattern_detail" || code === "pattern_detail")) ||
|
|
||||||
code === "tcm_pattern_detail"
|
|
||||||
) {
|
|
||||||
return TcmPatternDetailRenderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (code && detailRenderers[code]) return detailRenderers[code];
|
if (code && detailRenderers[code]) return detailRenderers[code];
|
||||||
reportMissingRenderer("detail", code);
|
reportMissingRenderer("detail", code);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { type PropsWithChildren, useEffect, useMemo, useState } from "react";
|
import React, { type PropsWithChildren, useMemo, useState } from "react";
|
||||||
import {
|
import {
|
||||||
LayoutAnimation,
|
LayoutAnimation,
|
||||||
Platform,
|
Platform,
|
||||||
|
|
@ -30,10 +30,6 @@ 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,7 +2,6 @@ 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;
|
||||||
|
|
@ -36,20 +35,13 @@ function hasRenderableContent(node: React.ReactNode): boolean {
|
||||||
|
|
||||||
export function SectionCard({
|
export function SectionCard({
|
||||||
title,
|
title,
|
||||||
defaultExpanded,
|
defaultExpanded = true,
|
||||||
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={isExpanded}>
|
<AccordionSection title={title} defaultExpanded={defaultExpanded}>
|
||||||
{children}
|
{children}
|
||||||
</AccordionSection>
|
</AccordionSection>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
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,
|
||||||
|
|
@ -11,25 +13,46 @@ import {
|
||||||
} from "react-native-size-matters";
|
} from "react-native-size-matters";
|
||||||
|
|
||||||
interface EditProfileAvatarProps {
|
interface EditProfileAvatarProps {
|
||||||
name?: string;
|
imageUri?: string;
|
||||||
|
onPress?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInitials(nameString?: string): string {
|
export default function EditProfileAvatar({
|
||||||
if (!nameString || !nameString.trim()) return "U";
|
imageUri,
|
||||||
const parts = nameString.trim().split(/\s+/);
|
onPress,
|
||||||
if (parts.length === 1) {
|
}: EditProfileAvatarProps) {
|
||||||
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.initialsContainer}>
|
<View style={styles.avatarWrapper}>
|
||||||
<Text style={styles.initialsText}>{initials}</Text>
|
{imageUri ? (
|
||||||
|
<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>
|
||||||
);
|
);
|
||||||
|
|
@ -38,24 +61,37 @@ export default function EditProfileAvatar({ name }: EditProfileAvatarProps) {
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
marginBottom: verticalScale(16),
|
marginBottom: verticalScale(28),
|
||||||
},
|
},
|
||||||
|
|
||||||
initialsContainer: {
|
avatarWrapper: {
|
||||||
width: scale(88),
|
position: "relative",
|
||||||
height: scale(88),
|
},
|
||||||
borderRadius: scale(44),
|
|
||||||
backgroundColor: "#DCFCE7",
|
avatar: {
|
||||||
borderWidth: 2,
|
width: scale(108),
|
||||||
borderColor: "#BBF7D0",
|
height: scale(108),
|
||||||
|
borderRadius: scale(54),
|
||||||
|
backgroundColor: "#F2F3F7",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
|
|
||||||
initialsText: {
|
cameraButton: {
|
||||||
fontSize: moderateScale(28),
|
position: "absolute",
|
||||||
fontWeight: "800",
|
right: scale(0),
|
||||||
color: "#15803D",
|
bottom: scale(2),
|
||||||
letterSpacing: 1,
|
|
||||||
|
width: scale(32),
|
||||||
|
height: scale(32),
|
||||||
|
borderRadius: scale(16),
|
||||||
|
|
||||||
|
backgroundColor: "#5B3DF5",
|
||||||
|
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
|
||||||
|
borderWidth: 2,
|
||||||
|
borderColor: "#FFFFFF",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -1,16 +1,9 @@
|
||||||
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";
|
||||||
|
|
||||||
|
|
@ -18,48 +11,26 @@ 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, updatedCountry: string) => void;
|
onSave?: (updatedName: string, updatedPhone: 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);
|
||||||
|
|
@ -69,25 +40,35 @@ export default function EditProfileForm({
|
||||||
setPhone(initialPhone);
|
setPhone(initialPhone);
|
||||||
}, [initialPhone]);
|
}, [initialPhone]);
|
||||||
|
|
||||||
useEffect(() => {
|
const [profession, setProfession] =
|
||||||
setCountry(initialCountry);
|
useState(initialProfession);
|
||||||
}, [initialCountry]);
|
|
||||||
|
const [country] =
|
||||||
|
useState(initialCountry);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View style={styles.field}>
|
<View style={styles.field}>
|
||||||
<FieldLabel label="Full Name" required />
|
<FieldLabel
|
||||||
|
label="Full Name"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
|
||||||
<BaseTextInput
|
<BaseTextInput
|
||||||
value={fullName}
|
value={fullName}
|
||||||
onChangeText={setFullName}
|
onChangeText={setFullName}
|
||||||
placeholder="Your full name"
|
placeholder="User Name"
|
||||||
autoCapitalize="words"
|
autoCapitalize="words"
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.field}>
|
<View style={styles.field}>
|
||||||
<FieldLabel label="Email" required />
|
<FieldLabel
|
||||||
|
label="Email"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
|
||||||
<BaseTextInput
|
<BaseTextInput
|
||||||
value={initialEmail}
|
value={initialEmail}
|
||||||
editable={false}
|
editable={false}
|
||||||
|
|
@ -96,17 +77,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 label="Phone Number" />
|
<FieldLabel
|
||||||
|
label="Phone Number"
|
||||||
|
/>
|
||||||
|
|
||||||
<BaseTextInput
|
<BaseTextInput
|
||||||
value={phone}
|
value={phone}
|
||||||
onChangeText={setPhone}
|
onChangeText={setPhone}
|
||||||
placeholder="e.g. +91 9876543210"
|
placeholder="Phone Number"
|
||||||
keyboardType="phone-pad"
|
keyboardType="phone-pad"
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
|
|
@ -114,176 +95,50 @@ export default function EditProfileForm({
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.field}>
|
<View style={styles.field}>
|
||||||
<FieldLabel label="Country / Region" required />
|
<FieldLabel
|
||||||
|
label="Profession (Optional)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<BaseTextInput
|
||||||
|
value={profession}
|
||||||
|
onChangeText={setProfession}
|
||||||
|
placeholder="Practitioner"
|
||||||
|
autoCapitalize="words"
|
||||||
|
autoCorrect={false}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.field}>
|
||||||
|
<FieldLabel
|
||||||
|
label="Country / Region"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
|
||||||
<DropdownField
|
<DropdownField
|
||||||
value={country}
|
value={country}
|
||||||
placeholder="Select country"
|
onPress={() => {
|
||||||
onPress={() => setShowCountryModal(true)}
|
// TODO:
|
||||||
|
// Open Country Picker
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.buttonWrapper}>
|
|
||||||
<PrimaryButton
|
<PrimaryButton
|
||||||
title="Save Changes"
|
title="Save Changes"
|
||||||
loading={isLoading}
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
onSave?.(fullName, phone, country);
|
onSave?.(fullName, phone);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Country Selection Modal */}
|
|
||||||
<Modal
|
|
||||||
visible={showCountryModal}
|
|
||||||
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>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
marginTop: verticalScale(4),
|
marginTop: verticalScale(8),
|
||||||
},
|
},
|
||||||
|
|
||||||
field: {
|
field: {
|
||||||
marginBottom: verticalScale(16),
|
marginBottom: verticalScale(18),
|
||||||
},
|
|
||||||
|
|
||||||
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,9 +1,13 @@
|
||||||
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,
|
||||||
|
|
@ -15,31 +19,71 @@ 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 initials = getInitials(name);
|
const router = useRouter();
|
||||||
|
|
||||||
|
const handleEditProfile = () => {
|
||||||
|
onEditPress?.();
|
||||||
|
router.push("/profile/edit");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View style={styles.initialsContainer}>
|
<View style={styles.avatarWrapper}>
|
||||||
<Text style={styles.initialsText}>{initials}</Text>
|
{imageUri ? (
|
||||||
|
<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>
|
||||||
|
|
||||||
<Text style={styles.name}>{name}</Text>
|
<Pressable
|
||||||
<Text style={styles.email}>{email}</Text>
|
accessibilityRole="button"
|
||||||
|
accessibilityLabel="Edit Profile"
|
||||||
|
hitSlop={10}
|
||||||
|
onPress={handleEditProfile}
|
||||||
|
>
|
||||||
|
<Text style={styles.name}>
|
||||||
|
{name}
|
||||||
|
</Text>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<Text style={styles.email}>
|
||||||
|
{email}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -47,40 +91,51 @@ export default function ProfileAvatar({
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
marginTop: verticalScale(4),
|
marginTop: verticalScale(10),
|
||||||
|
marginBottom: verticalScale(28),
|
||||||
|
},
|
||||||
|
|
||||||
|
avatarWrapper: {
|
||||||
|
position: "relative",
|
||||||
marginBottom: verticalScale(16),
|
marginBottom: verticalScale(16),
|
||||||
},
|
},
|
||||||
|
|
||||||
initialsContainer: {
|
avatar: {
|
||||||
width: scale(88),
|
width: scale(96),
|
||||||
height: scale(88),
|
height: scale(96),
|
||||||
borderRadius: scale(44),
|
borderRadius: scale(48),
|
||||||
backgroundColor: "#DCFCE7",
|
backgroundColor: "#F2F3F7",
|
||||||
borderWidth: 2,
|
|
||||||
borderColor: "#BBF7D0",
|
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
marginBottom: verticalScale(12),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
initialsText: {
|
editButton: {
|
||||||
fontSize: moderateScale(28),
|
position: "absolute",
|
||||||
fontWeight: "800",
|
right: scale(-2),
|
||||||
color: "#15803D",
|
bottom: scale(-2),
|
||||||
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.textPrimary,
|
color: Colors.text,
|
||||||
textAlign: "center",
|
|
||||||
},
|
},
|
||||||
|
|
||||||
email: {
|
email: {
|
||||||
marginTop: verticalScale(3),
|
marginTop: verticalScale(6),
|
||||||
fontSize: moderateScale(13),
|
fontSize: moderateScale(14),
|
||||||
color: Colors.textSecondary,
|
color: "#7A7A7A",
|
||||||
textAlign: "center",
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -17,28 +17,22 @@ 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}>
|
||||||
{showBackButton ? (
|
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
accessibilityLabel="Go Back"
|
accessibilityLabel="Go Back"
|
||||||
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
hitSlop={10}
|
||||||
style={({ pressed }) => [
|
style={styles.iconButton}
|
||||||
styles.iconButton,
|
|
||||||
pressed && styles.iconButtonPressed,
|
|
||||||
]}
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (router.canGoBack()) {
|
if (router.canGoBack()) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|
@ -48,33 +42,30 @@ export default function ProfileHeader({
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Ionicons
|
<Ionicons
|
||||||
name="chevron-back"
|
name="arrow-back"
|
||||||
size={moderateScale(24)}
|
size={moderateScale(22)}
|
||||||
color={Colors.textPrimary}
|
color={Colors.text}
|
||||||
/>
|
/>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
) : (
|
|
||||||
<View style={styles.placeholder} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Text numberOfLines={1} style={styles.title}>
|
<Text
|
||||||
|
numberOfLines={1}
|
||||||
|
style={styles.title}
|
||||||
|
>
|
||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
accessibilityLabel="Settings"
|
accessibilityLabel="Settings"
|
||||||
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
hitSlop={10}
|
||||||
style={({ pressed }) => [
|
style={styles.iconButton}
|
||||||
styles.iconButton,
|
|
||||||
pressed && styles.iconButtonPressed,
|
|
||||||
]}
|
|
||||||
onPress={onSettingsPress}
|
onPress={onSettingsPress}
|
||||||
>
|
>
|
||||||
<Ionicons
|
<Ionicons
|
||||||
name="settings-outline"
|
name="settings-outline"
|
||||||
size={moderateScale(21)}
|
size={moderateScale(22)}
|
||||||
color={Colors.textPrimary}
|
color={Colors.text}
|
||||||
/>
|
/>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -83,36 +74,36 @@ export default function ProfileHeader({
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
height: verticalScale(50),
|
height: verticalScale(56),
|
||||||
|
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
|
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
marginBottom: verticalScale(16),
|
|
||||||
|
marginBottom: verticalScale(24),
|
||||||
},
|
},
|
||||||
|
|
||||||
iconButton: {
|
iconButton: {
|
||||||
width: scale(38),
|
width: scale(40),
|
||||||
height: scale(38),
|
|
||||||
borderRadius: scale(19),
|
|
||||||
justifyContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
backgroundColor: "#F1F5F9",
|
|
||||||
},
|
|
||||||
|
|
||||||
iconButtonPressed: {
|
height: scale(40),
|
||||||
backgroundColor: "#E2E8F0",
|
|
||||||
|
justifyContent: "center",
|
||||||
|
|
||||||
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
|
|
||||||
title: {
|
title: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
textAlign: "center",
|
|
||||||
fontSize: moderateScale(18),
|
|
||||||
fontWeight: "700",
|
|
||||||
color: Colors.textPrimary,
|
|
||||||
},
|
|
||||||
|
|
||||||
placeholder: {
|
textAlign: "center",
|
||||||
width: scale(38),
|
|
||||||
height: scale(38),
|
fontSize: moderateScale(18),
|
||||||
|
|
||||||
|
fontWeight: "700",
|
||||||
|
|
||||||
|
color: Colors.text,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -96,14 +96,12 @@ export default function ProfileMenuItem({
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isSwitch ? (
|
{isSwitch ? (
|
||||||
<View style={{ pointerEvents: "none" }}>
|
|
||||||
<Switch
|
<Switch
|
||||||
value={switchValue}
|
value={switchValue}
|
||||||
onValueChange={onSwitchChange}
|
onValueChange={onSwitchChange}
|
||||||
trackColor={{ false: "#E2E8F0", true: Colors.primary }}
|
trackColor={{ false: "#CBD5E1", true: "#2563EB" }}
|
||||||
thumbColor="#FFFFFF"
|
thumbColor="#FFFFFF"
|
||||||
/>
|
/>
|
||||||
</View>
|
|
||||||
) : showArrow ? (
|
) : showArrow ? (
|
||||||
<Ionicons
|
<Ionicons
|
||||||
name="chevron-forward"
|
name="chevron-forward"
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
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, scale, verticalScale } from "react-native-size-matters";
|
import { moderateScale, 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";
|
||||||
|
|
@ -37,9 +36,7 @@ export default function ProfileOverviewCard() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
void refreshAccess().catch((error) =>
|
void refreshAccess().catch((error) => console.warn("Unable to refresh profile access:", error));
|
||||||
console.warn("Unable to refresh profile access:", error)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}, [accessToken, refreshAccess]);
|
}, [accessToken, refreshAccess]);
|
||||||
|
|
||||||
|
|
@ -84,17 +81,23 @@ 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>
|
||||||
|
|
||||||
{activeSubscriptions.length > 0 && (
|
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<Text style={styles.heading}>Active Subscriptions</Text>
|
<Text style={styles.heading}>Subscriptions</Text>
|
||||||
<View style={styles.card}>
|
<View style={styles.card}>
|
||||||
{activeSubscriptions.map((subscription, index) => (
|
{activeSubscriptions.length === 0 ? (
|
||||||
|
<View style={styles.emptyRow}>
|
||||||
|
<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={[
|
||||||
|
|
@ -103,9 +106,7 @@ export default function ProfileOverviewCard() {
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<View style={styles.subLeft}>
|
<View style={styles.subLeft}>
|
||||||
<Text style={styles.subTitle}>
|
<Text style={styles.subTitle}>{planLabel(subscription.plan_code)}</Text>
|
||||||
{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>
|
||||||
|
|
@ -117,10 +118,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}>
|
||||||
|
|
@ -153,68 +154,45 @@ export default function ProfileOverviewCard() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: { marginTop: verticalScale(4) },
|
container: { marginTop: verticalScale(8) },
|
||||||
section: { marginTop: verticalScale(20) },
|
section: { marginTop: verticalScale(24) },
|
||||||
|
|
||||||
sectionHeaderRow: {
|
|
||||||
flexDirection: "row",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
alignItems: "center",
|
|
||||||
marginBottom: verticalScale(8),
|
|
||||||
},
|
|
||||||
|
|
||||||
heading: {
|
heading: {
|
||||||
fontSize: moderateScale(13),
|
fontSize: moderateScale(16),
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: Colors.textSecondary,
|
color: "#171717",
|
||||||
textTransform: "uppercase",
|
marginBottom: verticalScale(12),
|
||||||
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: "#E5E7EB",
|
borderColor: "#ECECEC",
|
||||||
},
|
},
|
||||||
|
|
||||||
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: Colors.textPrimary,
|
color: "#171717",
|
||||||
marginBottom: verticalScale(2),
|
marginBottom: verticalScale(4),
|
||||||
},
|
},
|
||||||
|
|
||||||
subDateText: {
|
subDateText: {
|
||||||
fontSize: moderateScale(12),
|
fontSize: moderateScale(12),
|
||||||
color: Colors.textSecondary,
|
color: "#737373",
|
||||||
marginTop: verticalScale(2),
|
marginTop: verticalScale(2),
|
||||||
},
|
},
|
||||||
|
|
||||||
statusBadge: {
|
statusBadge: {
|
||||||
backgroundColor: "#DCFCE7",
|
backgroundColor: "#DCFCE7",
|
||||||
paddingHorizontal: moderateScale(10),
|
paddingHorizontal: moderateScale(10),
|
||||||
|
|
@ -222,13 +200,23 @@ 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: "700",
|
fontWeight: "600",
|
||||||
color: "#15803D",
|
color: "#15803D",
|
||||||
textTransform: "capitalize",
|
textTransform: "capitalize",
|
||||||
},
|
},
|
||||||
|
separator: { borderBottomWidth: 1, borderBottomColor: "#ECECEC" },
|
||||||
separator: { borderBottomWidth: 1, borderBottomColor: "#F1F5F9" },
|
emptyRow: { padding: moderateScale(16) },
|
||||||
|
emptyTitle: {
|
||||||
|
fontSize: moderateScale(14),
|
||||||
|
fontWeight: "600",
|
||||||
|
color: "#171717",
|
||||||
|
},
|
||||||
|
emptyText: {
|
||||||
|
marginTop: verticalScale(5),
|
||||||
|
fontSize: moderateScale(12),
|
||||||
|
color: "#737373",
|
||||||
|
lineHeight: moderateScale(18),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,8 @@ import type {
|
||||||
SearchScope,
|
SearchScope,
|
||||||
} from "../types/search.types";
|
} from "../types/search.types";
|
||||||
|
|
||||||
function capabilityQuery(scope?: SearchScope, preview = false): string {
|
function capabilityQuery(scope?: SearchScope): string {
|
||||||
const params: string[] = [];
|
const params: string[] = [];
|
||||||
if (preview) params.push("preview=true");
|
|
||||||
if (scope?.module_codes?.length) {
|
if (scope?.module_codes?.length) {
|
||||||
params.push(`module_codes=${encodeURIComponent(scope.module_codes.join(","))}`);
|
params.push(`module_codes=${encodeURIComponent(scope.module_codes.join(","))}`);
|
||||||
}
|
}
|
||||||
|
|
@ -22,10 +21,9 @@ function capabilityQuery(scope?: SearchScope, preview = false): string {
|
||||||
|
|
||||||
export async function getSearchCapabilities(
|
export async function getSearchCapabilities(
|
||||||
scope?: SearchScope,
|
scope?: SearchScope,
|
||||||
preview = false,
|
|
||||||
): Promise<SearchCapabilitiesResponse> {
|
): Promise<SearchCapabilitiesResponse> {
|
||||||
const response = await apiClient.get<SearchCapabilitiesResponse>(
|
const response = await apiClient.get<SearchCapabilitiesResponse>(
|
||||||
`/search/capabilities${capabilityQuery(scope, preview)}`,
|
`/search/capabilities${capabilityQuery(scope)}`,
|
||||||
);
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
@ -36,24 +34,20 @@ function apiFilters(filters: FacetValuesRequest["active_filters"]) {
|
||||||
|
|
||||||
export async function getFacetValues(
|
export async function getFacetValues(
|
||||||
payload: FacetValuesRequest,
|
payload: FacetValuesRequest,
|
||||||
preview = false,
|
|
||||||
): Promise<FacetValuesResponse> {
|
): Promise<FacetValuesResponse> {
|
||||||
const response = await apiClient.post<FacetValuesResponse>(
|
const response = await apiClient.post<FacetValuesResponse>(
|
||||||
"/search/facet-values",
|
"/search/facet-values",
|
||||||
{ ...payload, active_filters: apiFilters(payload.active_filters) },
|
{ ...payload, active_filters: apiFilters(payload.active_filters) },
|
||||||
{ params: { preview } },
|
|
||||||
);
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function searchContents(
|
export async function searchContents(
|
||||||
payload: FacetedSearchRequest,
|
payload: FacetedSearchRequest,
|
||||||
preview = false,
|
|
||||||
): Promise<FacetedSearchResponse> {
|
): Promise<FacetedSearchResponse> {
|
||||||
const response = await apiClient.post<FacetedSearchResponse>(
|
const response = await apiClient.post<FacetedSearchResponse>(
|
||||||
"/search/contents",
|
"/search/contents",
|
||||||
{ ...payload, filters: apiFilters(payload.filters) },
|
{ ...payload, filters: apiFilters(payload.filters) },
|
||||||
{ params: { preview } },
|
|
||||||
);
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { useSettingsStore } from "@/store/settings.store";
|
|
||||||
import { getFacetValues } from "../api/search.api";
|
import { getFacetValues } from "../api/search.api";
|
||||||
import type { FacetValuesRequest } from "../types/search.types";
|
import type { FacetValuesRequest } from "../types/search.types";
|
||||||
|
|
||||||
|
|
@ -7,7 +6,6 @@ export function useFacetValues(
|
||||||
request: FacetValuesRequest | null,
|
request: FacetValuesRequest | null,
|
||||||
enabled = true,
|
enabled = true,
|
||||||
) {
|
) {
|
||||||
const preview = useSettingsStore((state) => state.contentPreviewEnabled);
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: [
|
queryKey: [
|
||||||
"search",
|
"search",
|
||||||
|
|
@ -19,9 +17,8 @@ export function useFacetValues(
|
||||||
request?.filter_logic ?? "and",
|
request?.filter_logic ?? "and",
|
||||||
request?.active_filters ?? [],
|
request?.active_filters ?? [],
|
||||||
request?.limit ?? 25,
|
request?.limit ?? 25,
|
||||||
preview,
|
|
||||||
],
|
],
|
||||||
queryFn: () => getFacetValues(request!, preview),
|
queryFn: () => getFacetValues(request!),
|
||||||
enabled: enabled && request !== null,
|
enabled: enabled && request !== null,
|
||||||
staleTime: 30 * 1000,
|
staleTime: 30 * 1000,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { useInfiniteQuery } from "@tanstack/react-query";
|
import { useInfiniteQuery } from "@tanstack/react-query";
|
||||||
import { useSettingsStore } from "@/store/settings.store";
|
|
||||||
import { searchContents } from "../api/search.api";
|
import { searchContents } from "../api/search.api";
|
||||||
import type { FacetedSearchRequest } from "../types/search.types";
|
import type { FacetedSearchRequest } from "../types/search.types";
|
||||||
|
|
||||||
|
|
@ -7,7 +6,6 @@ export function useFacetedSearch(
|
||||||
request: Omit<FacetedSearchRequest, "page">,
|
request: Omit<FacetedSearchRequest, "page">,
|
||||||
enabled = true,
|
enabled = true,
|
||||||
) {
|
) {
|
||||||
const preview = useSettingsStore((state) => state.contentPreviewEnabled);
|
|
||||||
return useInfiniteQuery({
|
return useInfiniteQuery({
|
||||||
queryKey: [
|
queryKey: [
|
||||||
"search",
|
"search",
|
||||||
|
|
@ -19,10 +17,8 @@ export function useFacetedSearch(
|
||||||
request.filter_logic,
|
request.filter_logic,
|
||||||
request.sort,
|
request.sort,
|
||||||
request.page_size,
|
request.page_size,
|
||||||
preview,
|
|
||||||
],
|
],
|
||||||
queryFn: ({ pageParam }) =>
|
queryFn: ({ pageParam }) => searchContents({ ...request, page: pageParam }),
|
||||||
searchContents({ ...request, page: pageParam }, preview),
|
|
||||||
initialPageParam: 1,
|
initialPageParam: 1,
|
||||||
enabled,
|
enabled,
|
||||||
getNextPageParam: (last) =>
|
getNextPageParam: (last) =>
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { useSettingsStore } from "@/store/settings.store";
|
|
||||||
import { getSearchCapabilities } from "../api/search.api";
|
import { getSearchCapabilities } from "../api/search.api";
|
||||||
import type { SearchScope } from "../types/search.types";
|
import type { SearchScope } from "../types/search.types";
|
||||||
|
|
||||||
export function useSearchCapabilities(scope?: SearchScope) {
|
export function useSearchCapabilities(scope?: SearchScope) {
|
||||||
const preview = useSettingsStore((state) => state.contentPreviewEnabled);
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: [
|
queryKey: [
|
||||||
"search",
|
"search",
|
||||||
"capabilities",
|
"capabilities",
|
||||||
scope?.module_codes ?? null,
|
scope?.module_codes ?? null,
|
||||||
scope?.content_kinds ?? null,
|
scope?.content_kinds ?? null,
|
||||||
preview,
|
|
||||||
],
|
],
|
||||||
queryFn: () => getSearchCapabilities(scope, preview),
|
queryFn: () => getSearchCapabilities(scope),
|
||||||
staleTime: 30 * 60 * 1000,
|
staleTime: 30 * 60 * 1000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
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",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
@ -1,118 +0,0 @@
|
||||||
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",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
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",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
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",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
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,6 +1,5 @@
|
||||||
import React, { useState } from "react";
|
import React from "react";
|
||||||
import {
|
import {
|
||||||
Alert,
|
|
||||||
KeyboardAvoidingView,
|
KeyboardAvoidingView,
|
||||||
Platform,
|
Platform,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
|
|
@ -13,8 +12,7 @@ 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";
|
||||||
|
|
@ -24,51 +22,22 @@ 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 (
|
const handleSave = async (updatedName: string, updatedPhone: string) => {
|
||||||
updatedName: string,
|
if (user) {
|
||||||
updatedPhone: string,
|
|
||||||
updatedCountry: string
|
|
||||||
) => {
|
|
||||||
if (!user) {
|
|
||||||
router.back();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setSaving(true);
|
|
||||||
try {
|
try {
|
||||||
await apiClient.put("/auth/profile", {
|
await apiClient.put("/auth/profile", {
|
||||||
full_name: updatedName.trim(),
|
full_name: updatedName,
|
||||||
phone_number: updatedPhone.trim() || null,
|
phone_number: updatedPhone,
|
||||||
country: updatedCountry.trim() || null,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await refreshIdentity();
|
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) {
|
} 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);
|
console.warn("Failed to update profile:", err);
|
||||||
if (Platform.OS === "web") {
|
alert("Failed to save changes. Please try again.");
|
||||||
window.alert(errMsg);
|
|
||||||
} else {
|
|
||||||
Alert.alert("Error", errMsg);
|
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
setSaving(false);
|
|
||||||
}
|
}
|
||||||
|
router.back();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -83,18 +52,27 @@ export default function EditProfileScreen() {
|
||||||
contentContainerStyle={styles.contentContainer}
|
contentContainerStyle={styles.contentContainer}
|
||||||
>
|
>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<SettingsHeader title="Edit Profile" />
|
|
||||||
|
|
||||||
<EditProfileAvatar name={user?.name || "User Name"} />
|
<EditProfileHeader />
|
||||||
|
|
||||||
|
<EditProfileAvatar
|
||||||
|
onPress={() => {
|
||||||
|
// TODO: Open image picker
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<EditProfileForm
|
<EditProfileForm
|
||||||
initialName={user?.name || ""}
|
initialName={user?.name || "User Name"}
|
||||||
initialEmail={user?.email || ""}
|
initialEmail={user?.email || "user@example.com"}
|
||||||
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>
|
||||||
|
|
@ -114,12 +92,12 @@ const styles = StyleSheet.create({
|
||||||
|
|
||||||
contentContainer: {
|
contentContainer: {
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
paddingBottom: verticalScale(32),
|
paddingBottom: verticalScale(24),
|
||||||
},
|
},
|
||||||
|
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
paddingHorizontal: moderateScale(20),
|
paddingHorizontal: moderateScale(24),
|
||||||
paddingTop: verticalScale(12),
|
paddingTop: verticalScale(20),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -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 of Acupedia?",
|
"Are you sure you want to log out?",
|
||||||
[
|
[
|
||||||
{ 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,21 +68,16 @@ export default function ProfileOverviewScreen() {
|
||||||
>
|
>
|
||||||
<View style={styles.guestCard}>
|
<View style={styles.guestCard}>
|
||||||
<View style={styles.guestIconWrapper}>
|
<View style={styles.guestIconWrapper}>
|
||||||
<Ionicons
|
<Ionicons name="person-circle-outline" size={80} color={Colors.primary} />
|
||||||
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 clinical point pathways, track your learning progress, and customize your clinical references.
|
Sign in or create an account to unlock premium clinical modules, track your learning progress, and customize your profile 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>
|
||||||
|
|
@ -90,7 +85,6 @@ 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>
|
||||||
|
|
@ -108,8 +102,6 @@ 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");
|
||||||
}}
|
}}
|
||||||
|
|
@ -118,11 +110,21 @@ export default function ProfileOverviewScreen() {
|
||||||
<ProfileAvatar
|
<ProfileAvatar
|
||||||
name={displayName}
|
name={displayName}
|
||||||
email={displayEmail}
|
email={displayEmail}
|
||||||
|
onEditPress={() => {
|
||||||
|
router.push("/profile/edit");
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ProfileOverviewCard />
|
<ProfileOverviewCard />
|
||||||
|
|
||||||
<LogoutButton onPress={handleLogout} />
|
<TouchableOpacity
|
||||||
|
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>
|
||||||
|
|
@ -140,25 +142,40 @@ 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(20),
|
paddingHorizontal: moderateScale(24),
|
||||||
paddingTop: verticalScale(12),
|
paddingTop: verticalScale(20),
|
||||||
},
|
},
|
||||||
|
|
||||||
guestContentContainer: {
|
guestContentContainer: {
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
paddingHorizontal: moderateScale(20),
|
paddingHorizontal: moderateScale(24),
|
||||||
paddingBottom: verticalScale(40),
|
paddingBottom: verticalScale(40),
|
||||||
},
|
},
|
||||||
|
|
||||||
guestCard: {
|
guestCard: {
|
||||||
backgroundColor: "#FFFFFF",
|
backgroundColor: "#FFFFFF",
|
||||||
borderRadius: moderateScale(20),
|
borderRadius: moderateScale(24),
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: "#E5E7EB",
|
borderColor: "#E5E7EB",
|
||||||
padding: moderateScale(26),
|
padding: moderateScale(28),
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
shadowColor: "#000000",
|
shadowColor: "#000000",
|
||||||
shadowOffset: { width: 0, height: 4 },
|
shadowOffset: { width: 0, height: 4 },
|
||||||
|
|
@ -166,51 +183,44 @@ const styles = StyleSheet.create({
|
||||||
shadowRadius: 10,
|
shadowRadius: 10,
|
||||||
elevation: 2,
|
elevation: 2,
|
||||||
},
|
},
|
||||||
|
|
||||||
guestIconWrapper: {
|
guestIconWrapper: {
|
||||||
marginBottom: verticalScale(14),
|
marginBottom: verticalScale(16),
|
||||||
},
|
},
|
||||||
|
|
||||||
guestTitle: {
|
guestTitle: {
|
||||||
fontSize: moderateScale(22),
|
fontSize: moderateScale(22),
|
||||||
fontWeight: "800",
|
fontWeight: "800",
|
||||||
color: Colors.textPrimary,
|
color: Colors.textPrimary,
|
||||||
marginBottom: verticalScale(6),
|
marginBottom: verticalScale(8),
|
||||||
},
|
},
|
||||||
|
|
||||||
guestSubtitle: {
|
guestSubtitle: {
|
||||||
fontSize: moderateScale(13),
|
fontSize: moderateScale(14),
|
||||||
color: Colors.textSecondary,
|
color: Colors.textSecondary,
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
lineHeight: 19,
|
lineHeight: 20,
|
||||||
marginBottom: verticalScale(24),
|
marginBottom: verticalScale(28),
|
||||||
},
|
},
|
||||||
|
|
||||||
guestLoginButton: {
|
guestLoginButton: {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
backgroundColor: Colors.primary,
|
backgroundColor: Colors.primary,
|
||||||
borderRadius: moderateScale(12),
|
borderRadius: moderateScale(14),
|
||||||
paddingVertical: verticalScale(13),
|
paddingVertical: verticalScale(13),
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
marginBottom: verticalScale(10),
|
marginBottom: verticalScale(12),
|
||||||
},
|
},
|
||||||
|
|
||||||
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: 1.5,
|
borderWidth: 2,
|
||||||
borderColor: Colors.primary,
|
borderColor: Colors.primary,
|
||||||
borderRadius: moderateScale(12),
|
borderRadius: moderateScale(14),
|
||||||
paddingVertical: verticalScale(12),
|
paddingVertical: verticalScale(12),
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
|
|
||||||
guestSignupButtonText: {
|
guestSignupButtonText: {
|
||||||
fontSize: moderateScale(15),
|
fontSize: moderateScale(15),
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
|
|
|
||||||
|
|
@ -1,150 +0,0 @@
|
||||||
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 { getApiErrorStatus, isUnauthorizedApiError } from "@/api/error-utils";
|
import { 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,11 +167,8 @@ 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" && isSessionInvalid(identityResult.reason)) ||
|
(identityResult.status === "rejected" && isUnauthorizedApiError(identityResult.reason)) ||
|
||||||
(accessResult.status === "rejected" && isUnauthorizedApiError(accessResult.reason));
|
(accessResult.status === "rejected" && isUnauthorizedApiError(accessResult.reason));
|
||||||
|
|
||||||
if (unauthorized) {
|
if (unauthorized) {
|
||||||
|
|
@ -226,14 +223,10 @@ export const useAuthStore = create<AuthStore>()(
|
||||||
get().refreshAccess(),
|
get().refreshAccess(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Identity 401/404/invalid-token is handled conservatively by clearing the
|
// Identity 401/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 (
|
if (identityResult.status === "rejected" && isUnauthorizedApiError(identityResult.reason)) {
|
||||||
identityResult.status === "rejected" &&
|
|
||||||
(isUnauthorizedApiError(identityResult.reason) ||
|
|
||||||
getApiErrorStatus(identityResult.reason) === 404)
|
|
||||||
) {
|
|
||||||
get().logout();
|
get().logout();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,71 +1,21 @@
|
||||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import { createJSONStorage, persist } from "zustand/middleware";
|
|
||||||
|
|
||||||
import { NotificationPreferences, SettingsState } from "./types";
|
import { SettingsState } from "./types";
|
||||||
|
|
||||||
interface SettingsStore extends SettingsState {
|
interface SettingsStore extends SettingsState {
|
||||||
setTheme: (theme: "light" | "dark" | "system") => void;
|
setTheme: (theme: "light" | "dark") => 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_NOTIFICATIONS: NotificationPreferences = {
|
export const useSettingsStore = create<SettingsStore>((set) => ({
|
||||||
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",
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useSettingsStore = create<SettingsStore>()(
|
setTheme: (theme) =>
|
||||||
persist(
|
set({
|
||||||
(set) => ({
|
theme,
|
||||||
...DEFAULT_SETTINGS,
|
}),
|
||||||
|
|
||||||
setTheme: (theme) => set({ theme }),
|
|
||||||
|
|
||||||
setContentPreviewEnabled: (contentPreviewEnabled) =>
|
setContentPreviewEnabled: (contentPreviewEnabled) =>
|
||||||
set({ 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),
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
name: "acupedia-settings-storage",
|
|
||||||
storage: createJSONStorage(() => AsyncStorage),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
@ -108,18 +108,7 @@ export interface AppState {
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NotificationPreferences {
|
|
||||||
push: boolean;
|
|
||||||
clinicalUpdates: boolean;
|
|
||||||
weeklyDigest: boolean;
|
|
||||||
sound: boolean;
|
|
||||||
vibration: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SettingsState {
|
export interface SettingsState {
|
||||||
theme: "light" | "dark" | "system";
|
theme: "light" | "dark";
|
||||||
contentPreviewEnabled: boolean;
|
contentPreviewEnabled: boolean;
|
||||||
accordionDefaultExpanded: boolean;
|
|
||||||
notifications: NotificationPreferences;
|
|
||||||
language: string;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue