Compare commits

...

12 Commits

Author SHA1 Message Date
Amit Salunke ededd6f0c1 Merge pull request 'feat/mobile-dynamic-plan-code' (#143) from feat/mobile-dynamic-plan-code into main
Reviewed-on: https://git.zedobject.local/AcuPedia/acupedia-mobile-ui/pulls/143
Reviewed-by: Amit Salunke <amit@noreply.localhost>
2026-12-04 05:23:59 +00:00
Amit Salunke 053d08eb5d Merge pull request 'fix(m0042): stack tongue/pulse/method sections, show patterns label, preserve template heading case' (#142) from m0042 into main
Reviewed-on: https://git.zedobject.local/AcuPedia/acupedia-mobile-ui/pulls/142
Reviewed-by: Amit Salunke <amit@noreply.localhost>
2026-12-04 05:23:18 +00:00
ShivaniKhaire 967aec6403 fix(m0042): stack tongue/pulse/method sections, show patterns label, preserve template heading case 2026-12-03 15:02:01 +05:30
Urvish Prajapati 5d76e8ba19 feat(modules): refetch module catalog on focus and lower staleTime to 30s 2026-12-03 12:40:43 +05:30
Urvish Prajapati 6291c325eb feat(modules): prefer API plan_code in toModuleIndexItem for dynamic deep-linking 2026-12-02 15:33:53 +05:30
Amit Salunke e153668f06 Merge pull request 'fix(profile): add country search bar with dial codes and clear phone on country change' (#135) from fix/edit-profile-country-picker into main
Reviewed-on: https://git.zedobject.local/AcuPedia/acupedia-mobile-ui/pulls/135
Reviewed-by: Amit Salunke <amit@noreply.localhost>
2026-11-27 04:48:37 +00:00
Amit Salunke 4453a2a96c Merge pull request 'fix(mobile): unify logout confirmation modal and button labels across platforms' (#134) from fix/consistent-logout-confirmation into main
Reviewed-on: https://git.zedobject.local/AcuPedia/acupedia-mobile-ui/pulls/134
Reviewed-by: Amit Salunke <amit@noreply.localhost>
2026-11-27 04:47:56 +00:00
Amit Salunke e442a9825a Merge pull request 'fix(mobile): map m0041 (Auriculotherapy) to THERAPEUTICS_EAR instead of LIFETIME_ALL' (#133) from fix/auriculotherapy-plan-code into main
Reviewed-on: https://git.zedobject.local/AcuPedia/acupedia-mobile-ui/pulls/133
Reviewed-by: Amit Salunke <amit@noreply.localhost>
2026-11-27 04:47:09 +00:00
Urvish Prajapati b052bb97d7 fix(profile): add country search bar with dial codes and clear phone on country change 2026-11-26 11:35:50 +05:30
Urvish Prajapati 68e8c2a07b fix(mobile): unify logout confirmation modal and button labels across platforms 2026-11-26 11:11:03 +05:30
Urvish Prajapati b2c70e1b2e fix(mobile): map m0041 (Auriculotherapy) to THERAPEUTICS_EAR instead of LIFETIME_ALL 2026-11-25 15:34:57 +05:30
Amit Salunke 49fe5196ef Merge pull request 'fix(point-categories): align yuan source UI with card accordions and standard typography' (#132) from fix-point-categories into main
Reviewed-on: https://git.zedobject.local/AcuPedia/acupedia-mobile-ui/pulls/132
2026-11-19 10:11:00 +00:00
26 changed files with 529 additions and 297 deletions

View File

@ -1,9 +1,11 @@
import { useState } from "react";
import { Tabs, router } from "expo-router";
import { Ionicons } from "@expo/vector-icons";
import { Alert, Platform } from "react-native";
import { Platform } from "react-native";
import { AuthColors } from "@/features/auth/constants/colors";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useAuthStore } from "@/store/auth.store";
import LogoutConfirmModal from "@/components/LogoutConfirmModal";
export default function TabsLayout() {
const insets = useSafeAreaInsets();
@ -13,40 +15,24 @@ export default function TabsLayout() {
const { accessToken, logout } = useAuthStore();
const isAuthenticated = !!accessToken;
const [logoutModalVisible, setLogoutModalVisible] = useState(false);
const doLogout = () => {
setLogoutModalVisible(false);
logout();
router.replace("/login");
};
const handleAuthAction = () => {
if (isAuthenticated) {
const doLogout = () => {
logout();
router.replace("/login");
};
if (Platform.OS === "web") {
const confirmed = typeof window !== "undefined" ? window.confirm("Are you sure you want to logout?") : true;
if (confirmed) {
doLogout();
}
} else {
Alert.alert(
"Logout",
"Are you sure you want to logout?",
[
{ text: "Cancel", style: "cancel" },
{
text: "Yes",
style: "destructive",
onPress: doLogout,
},
],
{ cancelable: true }
);
}
setLogoutModalVisible(true);
} else {
router.push("/login");
}
};
return (
<>
<Tabs
screenOptions={{
headerShown: false,
@ -142,5 +128,11 @@ export default function TabsLayout() {
}}
/>
</Tabs>
<LogoutConfirmModal
visible={logoutModalVisible}
onCancel={() => setLogoutModalVisible(false)}
onConfirm={doLogout}
/>
</>
);
}

View File

@ -56,10 +56,11 @@ export default function LibraryScreen() {
useFocusEffect(
useCallback(() => {
isNavigatingRef.current = false;
void modulesQuery.refetch().catch((error) => console.warn("Unable to refresh modules:", error));
if (accessToken) {
void refreshAccess().catch((error) => console.warn("Unable to refresh library access:", error));
}
}, [accessToken, refreshAccess]),
}, [accessToken, modulesQuery.refetch, refreshAccess]),
);
const items = useMemo(

View File

@ -0,0 +1,145 @@
import React from "react";
import {
Modal,
Pressable,
StyleSheet,
Text,
TouchableOpacity,
View,
} from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { moderateScale, scale, verticalScale } from "react-native-size-matters";
import { Colors } from "@/theme";
interface LogoutConfirmModalProps {
visible: boolean;
onCancel: () => void;
onConfirm: () => void;
}
export default function LogoutConfirmModal({
visible,
onCancel,
onConfirm,
}: LogoutConfirmModalProps) {
return (
<Modal
visible={visible}
transparent
animationType="fade"
onRequestClose={onCancel}
>
<Pressable style={styles.backdrop} onPress={onCancel}>
<Pressable style={styles.card} onPress={() => {}}>
<View style={styles.iconContainer}>
<Ionicons name="log-out-outline" size={26} color="#DC2626" />
</View>
<Text style={styles.title}>Log Out</Text>
<Text style={styles.message}>
Are you sure you want to log out of Acupedia?
</Text>
<View style={styles.actions}>
<TouchableOpacity
style={[styles.button, styles.cancelButton]}
onPress={onCancel}
activeOpacity={0.8}
accessibilityRole="button"
accessibilityLabel="Cancel"
>
<Text style={styles.cancelText}>Cancel</Text>
</TouchableOpacity>
<TouchableOpacity
style={[styles.button, styles.confirmButton]}
onPress={onConfirm}
activeOpacity={0.8}
accessibilityRole="button"
accessibilityLabel="Log Out"
>
<Text style={styles.confirmText}>Log Out</Text>
</TouchableOpacity>
</View>
</Pressable>
</Pressable>
</Modal>
);
}
const styles = StyleSheet.create({
backdrop: {
flex: 1,
backgroundColor: "rgba(15, 23, 42, 0.55)",
justifyContent: "center",
alignItems: "center",
paddingHorizontal: scale(24),
},
card: {
width: "100%",
maxWidth: 360,
backgroundColor: Colors.surface ?? "#FFFFFF",
borderRadius: moderateScale(20),
padding: moderateScale(22),
alignItems: "center",
shadowColor: "#000",
shadowOffset: { width: 0, height: 10 },
shadowOpacity: 0.18,
shadowRadius: 20,
elevation: 8,
},
iconContainer: {
width: scale(48),
height: scale(48),
borderRadius: scale(24),
backgroundColor: "#FEE2E2",
justifyContent: "center",
alignItems: "center",
marginBottom: verticalScale(12),
},
title: {
fontSize: moderateScale(18),
fontWeight: "700",
color: Colors.textPrimary ?? "#0F172A",
marginBottom: verticalScale(6),
textAlign: "center",
},
message: {
fontSize: moderateScale(14),
color: Colors.textSecondary ?? "#475569",
textAlign: "center",
lineHeight: moderateScale(20),
marginBottom: verticalScale(20),
},
actions: {
flexDirection: "row",
gap: scale(10),
width: "100%",
},
button: {
flex: 1,
paddingVertical: verticalScale(11),
borderRadius: moderateScale(12),
alignItems: "center",
justifyContent: "center",
},
cancelButton: {
backgroundColor: "#F1F5F9",
borderWidth: 1,
borderColor: "#E2E8F0",
},
confirmButton: {
backgroundColor: "#DC2626",
},
cancelText: {
fontSize: moderateScale(14),
fontWeight: "600",
color: "#334155",
},
confirmText: {
fontSize: moderateScale(14),
fontWeight: "700",
color: "#FFFFFF",
},
});

View File

@ -15,7 +15,7 @@ export function useModulesQuery() {
return useQuery({
queryKey: contentQueryKeys.modules(preview),
queryFn: () => contentApi.getModules(preview),
staleTime: 10 * 60 * 1000,
staleTime: 30 * 1000,
});
}

View File

@ -2,7 +2,7 @@ import React, { useMemo } from "react";
import { ScrollView } from "react-native";
import type { DetailRendererProps } from "../types/renderer.types";
import { humanizeKey } from "./helpers/value";
import { buildDefinitionLabelMap, humanizeKey, resolveAttributeLabel } from "./helpers/value";
import { ContentValue } from "./shared/ContentValue";
import { Hero } from "./shared/Hero";
import { ImageGallery } from "./shared/ImageGallery";
@ -40,10 +40,7 @@ export function GenericDetailRenderer({
);
const definitionMap = useMemo(
() =>
new Map(
(definitions ?? []).map((d) => [d.code, d.label]),
),
() => buildDefinitionLabelMap(definitions),
[definitions],
);
@ -73,8 +70,7 @@ export function GenericDetailRenderer({
!(isTherapeutic && key.toLowerCase() === "name"),
)
.map(([key, value]) => {
const rawLabel = definitionMap.get(key) || key;
const label = humanizeKey(rawLabel);
const label = resolveAttributeLabel(key, definitionMap);
return (
<SectionCard key={key} title={label}>
<ContentValue value={value} />

View File

@ -549,7 +549,13 @@ export function GynecologyDiseaseCollectionRenderer(
</View>
);
return <CollectionScaffold {...props} header={header} />;
return (
<CollectionScaffold
{...props}
header={header}
countLabel="Identifications of patterns"
/>
);
}
export function createGynecologyDiseaseCollectionRenderer(templateCode: string) {

View File

@ -14,13 +14,21 @@ import { useRouter } from "expo-router";
import { moderateScale, verticalScale } from "react-native-size-matters";
import { Colors } from "@/theme";
import { asNumber, asString, asStringArray, humanizeKey } from "../helpers/value";
import {
asNumber,
asString,
asStringArray,
buildDefinitionLabelMap,
humanizeKey,
resolveAttributeLabel,
} from "../helpers/value";
import { CollectionScaffold } from "../shared/CollectionScaffold";
import { ContentCountBadge } from "../shared/ContentCountBadge";
import { greenTone } from "../shared/reading-palette";
import {
useModuleContentDetailQuery,
useModuleTemplateContentDetailsQuery,
useTemplateDefinitionsQuery,
} from "../../hooks/use-content-queries";
import type {
CollectionItemRendererProps,
@ -35,6 +43,10 @@ export function ModuleCatalogCollectionRenderer(props: CollectionRendererProps)
return <CollectionScaffold {...props} />;
}
function stripTrailingPeriod(value: string): string {
return value.replace(/\s*\.+\s*$/, "").trim();
}
function normalizePointCode(raw: string): string {
let code = raw.replace(/\s*\([^)]*\)/g, "").trim().toLowerCase();
code = code.replace(/^ren-/, "cv-");
@ -70,6 +82,16 @@ export function PatternAccordionCardRenderer({
contentId,
);
const detailTemplateCode =
asString(linkTarget?.template_code) ||
asString(detailQuery.data?.content?.metadata?.template_code) ||
(moduleCode.toLowerCase() === "m0042" ? "m0042_ct0005" : "");
const templateDefsQuery = useTemplateDefinitionsQuery(detailTemplateCode || undefined);
const labelMap = useMemo(
() => buildDefinitionLabelMap(templateDefsQuery.data?.attributes),
[templateDefsQuery.data?.attributes],
);
// Query all acupuncture points from m0001 to resolve links
const { data: pointsData } = useModuleTemplateContentDetailsQuery({
module_code: "m0001",
@ -138,8 +160,8 @@ export function PatternAccordionCardRenderer({
? rawManifestations.split("\n").map((s) => s.trim()).filter(Boolean)
: [];
const tongue = asString(detailData.tongue);
const pulse = asString(detailData.pulse);
const tongue = stripTrailingPeriod(asString(detailData.tongue));
const pulse = stripTrailingPeriod(asString(detailData.pulse));
const rawPrinciples = detailData.treatment_principle;
const treatmentPrinciples: string[] = Array.isArray(rawPrinciples)
? (rawPrinciples as string[]).map(String).map((s) => s.trim()).filter(Boolean)
@ -213,7 +235,7 @@ export function PatternAccordionCardRenderer({
{clinicalManifestations.length > 0 ? (
<View style={accordionStyles.section}>
<Text style={accordionStyles.sectionTitle}>
Clinical Manifestations
{resolveAttributeLabel("clinical_manifestations", labelMap, "Clinical Manifestations")}
</Text>
<View style={accordionStyles.bulletList}>
{clinicalManifestations.map((itemText, idx) => (
@ -226,22 +248,23 @@ export function PatternAccordionCardRenderer({
</View>
) : null}
{/* 2. Tongue & Pulse (Side-by-Side as drawn) */}
{tongue || pulse ? (
<View style={accordionStyles.twoColumnBox}>
{tongue ? (
<View style={accordionStyles.column}>
<Text style={accordionStyles.columnLabel}>Tongue</Text>
<Text style={accordionStyles.columnValue}>{tongue}</Text>
</View>
) : null}
{tongue && pulse ? <View style={accordionStyles.columnDivider} /> : null}
{pulse ? (
<View style={accordionStyles.column}>
<Text style={accordionStyles.columnLabel}>Pulse</Text>
<Text style={accordionStyles.columnValue}>{pulse}</Text>
</View>
) : null}
{/* 2. Tongue */}
{tongue ? (
<View style={accordionStyles.section}>
<Text style={accordionStyles.sectionTitle}>
{resolveAttributeLabel("tongue", labelMap, "Tongue")}
</Text>
<Text style={accordionStyles.sectionText}>{tongue}</Text>
</View>
) : null}
{/* 3. Pulse */}
{pulse ? (
<View style={accordionStyles.section}>
<Text style={accordionStyles.sectionTitle}>
{resolveAttributeLabel("pulse", labelMap, "Pulse")}
</Text>
<Text style={accordionStyles.sectionText}>{pulse}</Text>
</View>
) : null}
@ -249,7 +272,7 @@ export function PatternAccordionCardRenderer({
{treatmentPrinciples.length > 0 ? (
<View style={accordionStyles.section}>
<Text style={accordionStyles.sectionTitle}>
Treatment Principle
{resolveAttributeLabel("treatment_principle", labelMap, "Treatment Principle")}
</Text>
<View style={accordionStyles.bulletList}>
{treatmentPrinciples.map((itemText, idx) => (
@ -262,42 +285,44 @@ export function PatternAccordionCardRenderer({
</View>
) : null}
{/* 4. Acupuncture Points & Method */}
{pointChips.length > 0 || acuMethod ? (
{/* 4. Acupuncture Points */}
{pointChips.length > 0 ? (
<View style={accordionStyles.section}>
<Text style={accordionStyles.sectionTitle}>
Acupuncture Points
{resolveAttributeLabel("acupuncture", labelMap, "Acupuncture Points")}
</Text>
{pointChips.length > 0 ? (
<View style={accordionStyles.chipsContainer}>
{pointChips.map((pt, idx) => (
<Pressable
key={idx}
accessibilityRole="button"
accessibilityLabel={`View ${pt} acupuncture point`}
onPress={() => handlePointPress(pt)}
style={({ pressed }) => [
accordionStyles.pointChip,
pressed && accordionStyles.pointChipPressed,
]}
>
<Text style={accordionStyles.pointChipText}>{pt}</Text>
<Ionicons
name="chevron-forward"
size={12}
color="#35664E"
style={{ marginLeft: 2 }}
/>
</Pressable>
))}
</View>
) : null}
{acuMethod ? (
<View style={accordionStyles.methodContainer}>
<Text style={accordionStyles.subSectionLabel}>Method:</Text>
<Text style={accordionStyles.methodText}>{acuMethod}</Text>
</View>
) : null}
<View style={accordionStyles.chipsContainer}>
{pointChips.map((pt, idx) => (
<Pressable
key={idx}
accessibilityRole="button"
accessibilityLabel={`View ${pt} acupuncture point`}
onPress={() => handlePointPress(pt)}
style={({ pressed }) => [
accordionStyles.pointChip,
pressed && accordionStyles.pointChipPressed,
]}
>
<Text style={accordionStyles.pointChipText}>{pt}</Text>
<Ionicons
name="chevron-forward"
size={12}
color="#35664E"
style={{ marginLeft: 2 }}
/>
</Pressable>
))}
</View>
</View>
) : null}
{/* 5. Method */}
{acuMethod ? (
<View style={accordionStyles.section}>
<Text style={accordionStyles.sectionTitle}>
{resolveAttributeLabel("acupuncture.method", labelMap, "Method")}
</Text>
<Text style={accordionStyles.sectionText}>{acuMethod}</Text>
</View>
) : null}
@ -305,7 +330,7 @@ export function PatternAccordionCardRenderer({
{explanations.length > 0 ? (
<View style={accordionStyles.section}>
<Text style={accordionStyles.sectionTitle}>
Explanation
{resolveAttributeLabel("explanation", labelMap, "Explanation")}
</Text>
<View style={accordionStyles.explanationList}>
{explanations.map((exp, idx) => (
@ -321,7 +346,9 @@ export function PatternAccordionCardRenderer({
{/* 6. Category */}
{category ? (
<View style={accordionStyles.categoryRow}>
<Text style={accordionStyles.categoryLabel}>Category:</Text>
<Text style={accordionStyles.categoryLabel}>
{`${resolveAttributeLabel("category", labelMap, "Category")}:`}
</Text>
<View style={accordionStyles.categoryBadge}>
<Text style={accordionStyles.categoryBadgeText}>{category}</Text>
</View>
@ -495,8 +522,7 @@ const accordionStyles = StyleSheet.create({
lineHeight: moderateScale(16),
fontWeight: "700",
color: "#4A6B5B",
textTransform: "uppercase",
letterSpacing: 0.7,
letterSpacing: 0.15,
},
bulletList: {
gap: verticalScale(8),
@ -519,38 +545,10 @@ const accordionStyles = StyleSheet.create({
lineHeight: moderateScale(21),
color: "#334155",
},
twoColumnBox: {
flexDirection: "row",
backgroundColor: greenTone.soft,
borderRadius: moderateScale(10),
borderWidth: 1,
borderColor: greenTone.border,
paddingHorizontal: moderateScale(14),
paddingVertical: verticalScale(11),
alignItems: "stretch",
},
column: {
flex: 1,
gap: verticalScale(3),
},
columnDivider: {
width: StyleSheet.hairlineWidth,
backgroundColor: greenTone.border,
marginHorizontal: moderateScale(12),
},
columnLabel: {
fontSize: moderateScale(11),
lineHeight: moderateScale(15),
fontWeight: "700",
color: "#597064",
textTransform: "uppercase",
letterSpacing: 0.5,
},
columnValue: {
sectionText: {
fontSize: moderateScale(14),
lineHeight: moderateScale(20),
color: "#1E293B",
fontWeight: "600",
lineHeight: moderateScale(21),
color: "#334155",
},
principleBox: {
backgroundColor: greenTone.soft,
@ -591,23 +589,6 @@ const accordionStyles = StyleSheet.create({
fontWeight: "700",
color: "#35664E",
},
methodContainer: {
marginTop: verticalScale(4),
flexDirection: "row",
alignItems: "flex-start",
gap: moderateScale(6),
},
subSectionLabel: {
fontSize: moderateScale(13),
fontWeight: "700",
color: "#597064",
},
methodText: {
flex: 1,
fontSize: moderateScale(13),
lineHeight: moderateScale(19),
color: "#334155",
},
explanationList: {
gap: verticalScale(8),
},
@ -640,8 +621,7 @@ const accordionStyles = StyleSheet.create({
lineHeight: moderateScale(15),
fontWeight: "700",
color: "#597064",
textTransform: "uppercase",
letterSpacing: 0.5,
letterSpacing: 0.15,
},
categoryBadge: {
backgroundColor: "#EEF7F1",

View File

@ -234,8 +234,7 @@ const styles = StyleSheet.create({
lineHeight: 17,
fontWeight: "700",
color: "#597064",
textTransform: "uppercase",
letterSpacing: 0.4,
letterSpacing: 0.15,
},
pathway: {
fontSize: 16,

View File

@ -278,7 +278,6 @@ const styles = StyleSheet.create({
lineHeight: 18,
fontWeight: "700",
color: "#536F61",
textTransform: "uppercase",
letterSpacing: 0.35,
letterSpacing: 0.15,
},
});

View File

@ -216,8 +216,7 @@ const styles = StyleSheet.create({
fontSize: moderateScale(12),
fontWeight: "700",
color: Colors.textSecondary,
textTransform: "uppercase",
letterSpacing: 1,
letterSpacing: 0.2,
marginBottom: verticalScale(12),
marginLeft: moderateScale(4),
},

View File

@ -2,7 +2,12 @@ import React, { useMemo } from "react";
import { ScrollView, StyleSheet } from "react-native";
import type { DetailRendererProps } from "../../types/renderer.types";
import { asString, humanizeKey } from "../helpers/value";
import {
asString,
buildDefinitionLabelMap,
humanizeKey,
resolveAttributeLabel,
} from "../helpers/value";
import {
findAttributePresentationRule,
isEmptyValue,
@ -41,9 +46,7 @@ export function SixStagesDetailRenderer({
const title = humanizeKey(rawTitle);
const orderedSections = useMemo(() => {
const definitionByLabel = new Map(
(definitions ?? []).map((d) => [d.code, d.label]),
);
const definitionByLabel = buildDefinitionLabelMap(definitions);
return Object.entries(data)
.filter(
@ -55,8 +58,7 @@ export function SixStagesDetailRenderer({
.map(([key, value]) => {
const rule = findAttributePresentationRule(key, presentationAttributes);
const order = presentationDisplayOrder(rule);
const rawLabel = definitionByLabel.get(key) || key;
const label = humanizeKey(rawLabel);
const label = resolveAttributeLabel(key, definitionByLabel);
return { key, value, order, label };
})
.sort((a, b) => a.order - b.order || a.label.localeCompare(b.label));

View File

@ -2,7 +2,12 @@ import React, { useMemo } from "react";
import { ScrollView, StyleSheet } from "react-native";
import type { DetailRendererProps } from "../../types/renderer.types";
import { asString, humanizeKey } from "../helpers/value";
import {
asString,
buildDefinitionLabelMap,
humanizeKey,
resolveAttributeLabel,
} from "../helpers/value";
import {
findAttributePresentationRule,
isEmptyValue,
@ -36,9 +41,7 @@ export function TcmPatternDetailRenderer({
const title = humanizeKey(rawTitle);
const orderedSections = useMemo(() => {
const definitionByLabel = new Map(
(definitions ?? []).map((d) => [d.code, d.label]),
);
const definitionByLabel = buildDefinitionLabelMap(definitions);
return Object.entries(data)
.filter(
@ -49,8 +52,7 @@ export function TcmPatternDetailRenderer({
.map(([key, value]) => {
const rule = findAttributePresentationRule(key, presentationAttributes);
const order = presentationDisplayOrder(rule);
const rawLabel = definitionByLabel.get(key) || key;
const label = humanizeKey(rawLabel);
const label = resolveAttributeLabel(key, definitionByLabel);
return { key, value, order, label };
})
.sort((a, b) => a.order - b.order || a.label.localeCompare(b.label));

View File

@ -452,8 +452,7 @@ const styles = StyleSheet.create({
lineHeight: 17,
fontWeight: "700",
color: "#597064",
textTransform: "uppercase",
letterSpacing: 0.4,
letterSpacing: 0.15,
},
sectionValue: {
fontSize: 16,

View File

@ -1,3 +1,5 @@
import type { AttributeDefinitionResponse } from "../../types/content.types";
export function asString(value: unknown): string {
if (typeof value === "string") return value;
if (typeof value === "number" || typeof value === "boolean") return String(value);
@ -54,3 +56,53 @@ export function formatPatternTitle(value: string): string {
return value.replace(/\bLung(?:es|s)['’]/gi, "Lung's");
}
/**
* Indexes template attribute definitions (and nested children) by code so
* renderers can display exact template labels and casing without hardcoding.
*/
export function buildDefinitionLabelMap(
attributes?: readonly AttributeDefinitionResponse[] | null,
): Map<string, string> {
const map = new Map<string, string>();
if (!attributes) return map;
const visit = (attrs: readonly AttributeDefinitionResponse[], prefix?: string) => {
for (const attr of attrs) {
const code = attr.code?.trim();
const label = attr.label?.trim();
if (code && label) {
map.set(code, label);
map.set(code.toLowerCase(), label);
if (prefix) {
map.set(`${prefix}.${code}`, label);
map.set(`${prefix}.${code}`.toLowerCase(), label);
}
}
if (Array.isArray(attr.children) && attr.children.length > 0) {
visit(attr.children, code || prefix);
}
}
};
visit(attributes);
return map;
}
/**
* Returns the exact template label when defined, falling back to a provided label or humanized key.
*/
export function resolveAttributeLabel(
code: string,
labelMap?: ReadonlyMap<string, string>,
fallback?: string,
): string {
const trimmed = code.trim();
const fromMap =
labelMap?.get(trimmed) || labelMap?.get(trimmed.toLowerCase());
if (fromMap && fromMap.trim().length > 0) {
return fromMap.trim();
}
return fallback ?? humanizeKey(trimmed);
}

View File

@ -13,7 +13,7 @@ import { Colors } from "@/theme";
import type { CollectionRendererProps } from "../../types/renderer.types";
export function CollectionScaffold(
props: CollectionRendererProps & { header?: React.ReactNode },
props: CollectionRendererProps & { header?: React.ReactNode; countLabel?: string },
) {
return (
<FlatList
@ -30,7 +30,7 @@ export function CollectionScaffold(
<>
{props.header}
<Text style={styles.resultCount} accessibilityLiveRegion="polite">
{props.total} {props.total === 1 ? "result" : "results"}
{props.countLabel ?? `${props.total} ${props.total === 1 ? "result" : "results"}`}
</Text>
</>
}
@ -86,8 +86,7 @@ const styles = StyleSheet.create({
fontSize: moderateScale(12),
fontWeight: "700",
color: Colors.textSecondary,
textTransform: "uppercase",
letterSpacing: 1,
letterSpacing: 0.2,
marginBottom: verticalScale(8),
marginLeft: moderateScale(4),
},

View File

@ -217,7 +217,6 @@ const styles = StyleSheet.create({
lineHeight: 17,
fontWeight: "700",
color: Colors.textSecondary,
textTransform: "uppercase",
letterSpacing: 0.35,
letterSpacing: 0.15,
},
});

View File

@ -29,8 +29,7 @@ const styles = StyleSheet.create({
lineHeight: 17,
fontWeight: "700",
color: "#597064",
textTransform: "uppercase",
letterSpacing: 0.4,
letterSpacing: 0.15,
},
value: { fontSize: 16, lineHeight: 25, color: "#334155" },
});

View File

@ -64,7 +64,6 @@ const styles = StyleSheet.create({
fontSize: 13,
lineHeight: 18,
color: "#536F61",
textTransform: "uppercase",
letterSpacing: 0.35,
letterSpacing: 0.15,
},
});

View File

@ -53,8 +53,7 @@ const styles = StyleSheet.create({
lineHeight: 17,
fontWeight: "700",
color: "#617468",
textTransform: "uppercase",
letterSpacing: 0.35,
letterSpacing: 0.15,
},
value: { fontSize: 15, lineHeight: 23, color: "#334155" },
});

View File

@ -31,6 +31,7 @@ export interface ModuleResponse extends ModuleSummary {
release_version: string | null;
expected_release_date: string | null;
release_notes: string | null;
plan_code?: string | null;
metadata: Record<string, unknown>;
created_by: string | null;
updated_by: string | null;

View File

@ -121,7 +121,7 @@ const MODULE_VISUALS: Record<string, ModuleVisualConfig> = {
icon: "body-outline",
color: "#8B5CF6",
isDefaultFree: false,
planCode: "LIFETIME_ALL",
planCode: "THERAPEUTICS_EAR",
},
m0042: {
icon: "woman-outline",
@ -224,6 +224,7 @@ export function toModuleIndexItem(module: ModuleResponse): ModuleIndexItem {
const visual = MODULE_VISUALS[module.code.toLowerCase()];
const metadataIcon = readMetadataString(module, "icon");
const metadataColor = readMetadataString(module, "color");
const apiPlanCode = asNonBlankString(module.plan_code);
const metadataPlanCode = readMetadataString(module, "plan_code");
const metadataIsDefaultFree = readMetadataBoolean(module, "is_default_free");
@ -241,7 +242,7 @@ export function toModuleIndexItem(module: ModuleResponse): ModuleIndexItem {
icon: metadataIcon ?? visual?.icon ?? "folder-outline",
color: metadataColor ?? visual?.color ?? "#4F46E5",
isDefaultFree: metadataIsDefaultFree ?? visual?.isDefaultFree ?? false,
planCode: metadataPlanCode ?? visual?.planCode ?? "",
planCode: apiPlanCode ?? metadataPlanCode ?? visual?.planCode ?? "",
};
}

View File

@ -1,10 +1,11 @@
import React, { useState, useEffect } from "react";
import React, { useState, useEffect, useMemo } from "react";
import {
Modal,
Pressable,
ScrollView,
StyleSheet,
Text,
TextInput,
View,
} from "react-native";
import { Ionicons } from "@expo/vector-icons";
@ -20,8 +21,8 @@ import FieldLabel from "@/components/forms/FieldLabel";
import PrimaryButton from "@/components/buttons/PrimaryButton";
import { Colors } from "@/theme";
import {
SORTED_COUNTRY_CODES,
getCountryRuleByName,
updatePhoneDialCode,
validatePhoneNumber,
isValidPhoneNumber,
parsePhoneNumber,
@ -38,25 +39,6 @@ interface EditProfileFormProps {
isLoading?: boolean;
}
const COMMON_COUNTRIES = [
"Australia",
"Canada",
"France",
"Germany",
"India",
"Ireland",
"Malaysia",
"Netherlands",
"New Zealand",
"Singapore",
"South Africa",
"Spain",
"Switzerland",
"United Arab Emirates",
"United Kingdom",
"United States",
];
export default function EditProfileForm({
initialName = "User Name",
initialEmail = "user@example.com",
@ -71,9 +53,21 @@ export default function EditProfileForm({
const [nameError, setNameError] = useState("");
const [phoneError, setPhoneError] = useState("");
const [showCountryModal, setShowCountryModal] = useState(false);
const [countrySearch, setCountrySearch] = useState("");
const activeRule = getCountryRuleByName(country);
const filteredCountries = useMemo(() => {
const q = countrySearch.trim().toLowerCase();
if (!q) return SORTED_COUNTRY_CODES;
return SORTED_COUNTRY_CODES.filter(
(c) =>
c.country.toLowerCase().includes(q) ||
c.code.toLowerCase().includes(q) ||
c.label.toLowerCase().includes(q)
);
}, [countrySearch]);
useEffect(() => {
setFullName(initialName);
}, [initialName]);
@ -105,12 +99,12 @@ export default function EditProfileForm({
const handleCountrySelect = (newCountry: string) => {
if (newCountry !== country) {
const updatedPhone = updatePhoneDialCode(phone, country, newCountry);
setPhone(updatedPhone);
setPhone("");
setCountry(newCountry);
if (phoneError) setPhoneError("");
}
setShowCountryModal(false);
setCountrySearch("");
};
const handleSave = () => {
@ -220,18 +214,27 @@ export default function EditProfileForm({
visible={showCountryModal}
transparent
animationType="slide"
onRequestClose={() => setShowCountryModal(false)}
onRequestClose={() => {
setShowCountryModal(false);
setCountrySearch("");
}}
>
<Pressable
style={styles.modalOverlay}
onPress={() => setShowCountryModal(false)}
onPress={() => {
setShowCountryModal(false);
setCountrySearch("");
}}
>
<View style={styles.modalSheet}>
<Pressable style={styles.modalSheet} onPress={() => {}}>
<View style={styles.modalHeader}>
<Text style={styles.modalTitle}>Select Country</Text>
<Pressable
hitSlop={8}
onPress={() => setShowCountryModal(false)}
onPress={() => {
setShowCountryModal(false);
setCountrySearch("");
}}
>
<Ionicons
name="close"
@ -241,42 +244,82 @@ export default function EditProfileForm({
</Pressable>
</View>
{/* Country Search Bar */}
<View style={styles.modalSearchContainer}>
<Ionicons
name="search-outline"
size={moderateScale(17)}
color={Colors.textSecondary}
/>
<TextInput
value={countrySearch}
onChangeText={setCountrySearch}
placeholder="Search country or code..."
placeholderTextColor={Colors.textSecondary}
style={styles.modalSearchInput}
autoCapitalize="none"
autoCorrect={false}
/>
{countrySearch.length > 0 && (
<Pressable
hitSlop={8}
onPress={() => setCountrySearch("")}
>
<Ionicons
name="close-circle"
size={moderateScale(17)}
color={Colors.textSecondary}
/>
</Pressable>
)}
</View>
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={styles.countryList}
keyboardShouldPersistTaps="handled"
>
{COMMON_COUNTRIES.map((c) => {
const isSelected = country === c;
return (
<Pressable
key={c}
style={({ pressed }) => [
styles.countryItem,
isSelected && styles.countryItemSelected,
pressed && styles.countryItemPressed,
]}
onPress={() => handleCountrySelect(c)}
>
<Text
style={[
styles.countryName,
isSelected && styles.countryNameSelected,
{filteredCountries.length === 0 ? (
<View style={styles.emptyContainer}>
<Text style={styles.emptyText}>No countries found</Text>
</View>
) : (
filteredCountries.map((c) => {
const isSelected = country === c.country;
return (
<Pressable
key={c.iso2 + c.country}
style={({ pressed }) => [
styles.countryItem,
isSelected && styles.countryItemSelected,
pressed && styles.countryItemPressed,
]}
onPress={() => handleCountrySelect(c.country)}
>
{c}
</Text>
{isSelected && (
<Ionicons
name="checkmark"
size={moderateScale(18)}
color={Colors.primary}
/>
)}
</Pressable>
);
})}
<View style={styles.countryRow}>
<Text style={styles.countryDialCode}>{c.code}</Text>
<Text
style={[
styles.countryName,
isSelected && styles.countryNameSelected,
]}
>
{c.country}
</Text>
</View>
{isSelected && (
<Ionicons
name="checkmark"
size={moderateScale(18)}
color={Colors.primary}
/>
)}
</Pressable>
);
})
)}
</ScrollView>
</View>
</Pressable>
</Pressable>
</Modal>
</View>
@ -334,6 +377,52 @@ const styles = StyleSheet.create({
color: Colors.textPrimary,
},
modalSearchContainer: {
flexDirection: "row",
alignItems: "center",
marginHorizontal: scale(16),
marginTop: verticalScale(10),
marginBottom: verticalScale(4),
paddingHorizontal: scale(12),
paddingVertical: verticalScale(8),
backgroundColor: "#F8FAFC",
borderRadius: moderateScale(10),
borderWidth: 1,
borderColor: "#E2E8F0",
gap: scale(8),
},
modalSearchInput: {
flex: 1,
fontSize: moderateScale(14),
color: Colors.textPrimary,
padding: 0,
},
emptyContainer: {
paddingVertical: verticalScale(24),
alignItems: "center",
},
emptyText: {
fontSize: moderateScale(14),
color: Colors.textSecondary,
},
countryRow: {
flexDirection: "row",
alignItems: "center",
gap: scale(10),
flex: 1,
},
countryDialCode: {
fontSize: moderateScale(13),
fontWeight: "700",
color: Colors.textSecondary,
minWidth: scale(46),
},
countryList: {
paddingHorizontal: scale(16),
paddingTop: verticalScale(8),

View File

@ -65,8 +65,9 @@ export default function HomeScreen() {
useFocusEffect(
useCallback(() => {
void modulesQuery.refetch().catch((error) => console.warn("Unable to refresh modules:", error));
void refreshSession().catch((error) => console.warn("Unable to refresh session:", error));
}, [refreshSession]),
}, [modulesQuery.refetch, refreshSession]),
);
const unlockedModules = useMemo(() => {

View File

@ -77,12 +77,15 @@ export default function ModulesIndexScreen() {
useFocusEffect(
useCallback(() => {
isNavigatingRef.current = false;
void modulesQuery.refetch().catch((error) => {
console.warn("Unable to refresh modules:", error);
});
if (accessToken) {
void refreshAccess().catch((error) => {
console.warn("Unable to refresh module access:", error);
});
}
}, [accessToken, refreshAccess]),
}, [accessToken, modulesQuery.refetch, refreshAccess]),
);
const items = useMemo(

View File

@ -1,7 +1,5 @@
import React from "react";
import React, { useState } from "react";
import {
Alert,
Platform,
ScrollView,
StyleSheet,
View,
@ -21,42 +19,23 @@ import ProfileHeader from "@/features/profile/components/ProfileHeader";
import ProfileAvatar from "@/features/profile/components/ProfileAvatar";
import ProfileOverviewCard from "@/features/profile/components/ProfileOverviewCard";
import LogoutButton from "@/features/settings/components/LogoutButton";
import LogoutConfirmModal from "@/components/LogoutConfirmModal";
import { useAuthStore } from "@/store/auth.store";
export default function ProfileOverviewScreen() {
const { user, accessToken, logout } = useAuthStore();
const [logoutModalVisible, setLogoutModalVisible] = useState(false);
const displayName = user?.name || "User Name";
const displayEmail = user?.email || "user@example.com";
const handleLogout = () => {
const doLogout = () => {
logout();
router.replace("/login");
};
const doLogout = () => {
setLogoutModalVisible(false);
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 }
);
}
const handleLogout = () => {
setLogoutModalVisible(true);
};
if (!accessToken) {
@ -125,6 +104,12 @@ export default function ProfileOverviewScreen() {
<LogoutButton onPress={handleLogout} />
</View>
</ScrollView>
<LogoutConfirmModal
visible={logoutModalVisible}
onCancel={() => setLogoutModalVisible(false)}
onConfirm={doLogout}
/>
</SafeAreaView>
);
}

View File

@ -1,7 +1,5 @@
import React, { useState } from "react";
import {
Alert,
Platform,
ScrollView,
StyleSheet,
View,
@ -14,6 +12,7 @@ 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 LogoutConfirmModal from "@/components/LogoutConfirmModal";
import {
ACCOUNT_SETTINGS,
PREFERENCE_SETTINGS,
@ -28,6 +27,7 @@ import EnvironmentSelectorModal from "@/components/EnvironmentSelectorModal";
export default function SettingsScreen() {
const [envModalVisible, setEnvModalVisible] = useState(false);
const [logoutModalVisible, setLogoutModalVisible] = useState(false);
const activeConfig = useEnvironmentStore((state) => state.getActiveConfig());
const user = useAuthStore((state) => state.user);
const logout = useAuthStore((state) => state.logout);
@ -87,35 +87,14 @@ export default function SettingsScreen() {
: []),
];
const handleLogout = () => {
const doLogout = () => {
logout();
router.replace("/login");
};
const doLogout = () => {
setLogoutModalVisible(false);
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 }
);
}
const handleLogout = () => {
setLogoutModalVisible(true);
};
return (
@ -153,6 +132,12 @@ export default function SettingsScreen() {
onClose={() => setEnvModalVisible(false)}
/>
)}
<LogoutConfirmModal
visible={logoutModalVisible}
onCancel={() => setLogoutModalVisible(false)}
onConfirm={doLogout}
/>
</SafeAreaView>
);
}