Compare commits
5 Commits
fix/issue-
...
main
| Author | SHA1 | Date |
|---|---|---|
|
|
ededd6f0c1 | |
|
|
053d08eb5d | |
|
|
967aec6403 | |
|
|
5d76e8ba19 | |
|
|
6291c325eb |
|
|
@ -56,10 +56,11 @@ export default function LibraryScreen() {
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
isNavigatingRef.current = false;
|
isNavigatingRef.current = false;
|
||||||
|
void modulesQuery.refetch().catch((error) => console.warn("Unable to refresh modules:", error));
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
void refreshAccess().catch((error) => console.warn("Unable to refresh library access:", error));
|
void refreshAccess().catch((error) => console.warn("Unable to refresh library access:", error));
|
||||||
}
|
}
|
||||||
}, [accessToken, refreshAccess]),
|
}, [accessToken, modulesQuery.refetch, refreshAccess]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const items = useMemo(
|
const items = useMemo(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useState } from "react";
|
||||||
import {
|
import {
|
||||||
KeyboardAvoidingView,
|
KeyboardAvoidingView,
|
||||||
Platform,
|
Platform,
|
||||||
|
|
@ -8,25 +8,17 @@ import {
|
||||||
Alert,
|
Alert,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { SafeAreaView } from "react-native-safe-area-context";
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
import { router } from "expo-router";
|
||||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||||
|
|
||||||
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
import SettingsHeader from "@/features/settings/components/SettingsHeader";
|
||||||
import PasswordInput from "@/components/forms/PasswordInput";
|
import PasswordInput from "@/components/forms/PasswordInput";
|
||||||
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
import PrimaryButton from "@/components/buttons/PrimaryButton";
|
||||||
import FieldLabel from "@/components/forms/FieldLabel";
|
import FieldLabel from "@/components/forms/FieldLabel";
|
||||||
import { changePassword } from "@/features/auth/api/auth.api";
|
|
||||||
import { resetNavigationToLogin } from "@/features/auth/utils/navigation";
|
|
||||||
import { useAuthStore } from "@/store/auth.store";
|
|
||||||
import { Colors } from "@/theme";
|
import { Colors } from "@/theme";
|
||||||
|
import { apiClient } from "@/api";
|
||||||
|
|
||||||
export default function ChangePasswordScreen() {
|
export default function ChangePasswordScreen() {
|
||||||
const isAuthenticated = useAuthStore((state) => Boolean(state.accessToken));
|
|
||||||
const logout = useAuthStore((state) => state.logout);
|
|
||||||
const [hasHydrated, setHasHydrated] = useState(() =>
|
|
||||||
useAuthStore.persist.hasHydrated(),
|
|
||||||
);
|
|
||||||
const isCompletingReloginRef = useRef(false);
|
|
||||||
|
|
||||||
const [currentPassword, setCurrentPassword] = useState("");
|
const [currentPassword, setCurrentPassword] = useState("");
|
||||||
const [newPassword, setNewPassword] = useState("");
|
const [newPassword, setNewPassword] = useState("");
|
||||||
const [confirmPassword, setConfirmPassword] = useState("");
|
const [confirmPassword, setConfirmPassword] = useState("");
|
||||||
|
|
@ -36,25 +28,7 @@ export default function ChangePasswordScreen() {
|
||||||
const [confirmError, setConfirmError] = useState("");
|
const [confirmError, setConfirmError] = useState("");
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (hasHydrated) return;
|
|
||||||
return useAuthStore.persist.onFinishHydration(() => {
|
|
||||||
setHasHydrated(true);
|
|
||||||
});
|
|
||||||
}, [hasHydrated]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (hasHydrated && !isAuthenticated && !isCompletingReloginRef.current) {
|
|
||||||
resetNavigationToLogin();
|
|
||||||
}
|
|
||||||
}, [hasHydrated, isAuthenticated]);
|
|
||||||
|
|
||||||
if (hasHydrated && !isAuthenticated && !isCompletingReloginRef.current) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleUpdatePassword = async () => {
|
const handleUpdatePassword = async () => {
|
||||||
if (isLoading || isCompletingReloginRef.current) return;
|
|
||||||
let hasError = false;
|
let hasError = false;
|
||||||
setCurrentError("");
|
setCurrentError("");
|
||||||
setNewError("");
|
setNewError("");
|
||||||
|
|
@ -97,38 +71,19 @@ export default function ChangePasswordScreen() {
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
await changePassword({
|
await apiClient.post("/auth/change-password", {
|
||||||
old_password: currentPassword,
|
old_password: currentPassword,
|
||||||
new_password: newPassword,
|
new_password: newPassword,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Force full session termination immediately so the user must
|
const msg = "Password updated successfully!";
|
||||||
// re-authenticate with the new password before reopening the app.
|
|
||||||
isCompletingReloginRef.current = true;
|
|
||||||
setCurrentPassword("");
|
|
||||||
setNewPassword("");
|
|
||||||
setConfirmPassword("");
|
|
||||||
logout();
|
|
||||||
|
|
||||||
let hasRedirected = false;
|
|
||||||
const redirectToLogin = () => {
|
|
||||||
if (hasRedirected) return;
|
|
||||||
hasRedirected = true;
|
|
||||||
resetNavigationToLogin();
|
|
||||||
};
|
|
||||||
|
|
||||||
const msg =
|
|
||||||
"Password updated successfully! Please log in with your new password.";
|
|
||||||
if (Platform.OS === "web") {
|
if (Platform.OS === "web") {
|
||||||
window.alert(msg);
|
window.alert(msg);
|
||||||
redirectToLogin();
|
router.back();
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(
|
Alert.alert("Success", msg, [
|
||||||
"Password Updated",
|
{ text: "OK", onPress: () => router.back() },
|
||||||
msg,
|
]);
|
||||||
[{ text: "Log In", onPress: redirectToLogin }],
|
|
||||||
{ cancelable: false, onDismiss: redirectToLogin },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
const errMsg =
|
const errMsg =
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import apiClient from "@/api/client";
|
||||||
import { API_ENDPOINTS } from "@/api/endpoints";
|
import { API_ENDPOINTS } from "@/api/endpoints";
|
||||||
import type {
|
import type {
|
||||||
AuthTokenResponse,
|
AuthTokenResponse,
|
||||||
ChangePasswordRequest,
|
|
||||||
ForgotPasswordRequest,
|
ForgotPasswordRequest,
|
||||||
LoginRequest,
|
LoginRequest,
|
||||||
RegisterRequest,
|
RegisterRequest,
|
||||||
|
|
@ -58,19 +57,6 @@ export async function resetPassword(
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the authenticated user's password via the auth change-password endpoint.
|
|
||||||
*/
|
|
||||||
export async function changePassword(
|
|
||||||
payload: ChangePasswordRequest,
|
|
||||||
): Promise<StatusMessageResponse> {
|
|
||||||
const response = await apiClient.post<StatusMessageResponse>(
|
|
||||||
API_ENDPOINTS.AUTH.CHANGE_PASSWORD,
|
|
||||||
payload,
|
|
||||||
);
|
|
||||||
return response.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ProfileUpdatePayload {
|
export interface ProfileUpdatePayload {
|
||||||
full_name?: string | null;
|
full_name?: string | null;
|
||||||
email?: string | null;
|
email?: string | null;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useCallback, useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Pressable, StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
import { Pressable, StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { useFocusEffect, useRouter } from "expo-router";
|
import { useRouter } from "expo-router";
|
||||||
import {
|
import {
|
||||||
moderateScale,
|
moderateScale,
|
||||||
scale,
|
scale,
|
||||||
|
|
@ -16,15 +16,8 @@ import EnvironmentSelectorModal from "@/components/EnvironmentSelectorModal";
|
||||||
export default function LoginHeader() {
|
export default function LoginHeader() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [modalVisible, setModalVisible] = useState(false);
|
const [modalVisible, setModalVisible] = useState(false);
|
||||||
const [canGoBack, setCanGoBack] = useState(false);
|
|
||||||
const activeConfig = useEnvironmentStore((state) => state.getActiveConfig());
|
const activeConfig = useEnvironmentStore((state) => state.getActiveConfig());
|
||||||
|
|
||||||
useFocusEffect(
|
|
||||||
useCallback(() => {
|
|
||||||
setCanGoBack(router.canGoBack());
|
|
||||||
}, [router]),
|
|
||||||
);
|
|
||||||
|
|
||||||
const badgeColor =
|
const badgeColor =
|
||||||
activeConfig.key === "prod"
|
activeConfig.key === "prod"
|
||||||
? "#10B981"
|
? "#10B981"
|
||||||
|
|
@ -35,26 +28,18 @@ export default function LoginHeader() {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View style={styles.topRow}>
|
<View style={styles.topRow}>
|
||||||
{canGoBack ? (
|
<Pressable
|
||||||
<Pressable
|
accessibilityRole="button"
|
||||||
accessibilityRole="button"
|
accessibilityLabel="Go Back"
|
||||||
accessibilityLabel="Go Back"
|
hitSlop={10}
|
||||||
hitSlop={10}
|
onPress={() => router.back()}
|
||||||
onPress={() => {
|
style={styles.backButton}
|
||||||
if (router.canGoBack()) {
|
>
|
||||||
router.back();
|
<Ionicons
|
||||||
}
|
name="arrow-back"
|
||||||
}}
|
size={moderateScale(24)}
|
||||||
style={styles.backButton}
|
/>
|
||||||
>
|
</Pressable>
|
||||||
<Ionicons
|
|
||||||
name="arrow-back"
|
|
||||||
size={moderateScale(24)}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
) : (
|
|
||||||
<View style={styles.backButton} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{ENABLE_ENV_SWITCHER && (
|
{ENABLE_ENV_SWITCHER && (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
import { router, type Href } from "expo-router";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collapses pushed stack screens before replacing the current route so
|
|
||||||
* back navigation cannot return to prior screens in the stack.
|
|
||||||
*/
|
|
||||||
export function resetNavigationToRoute(href: Href): void {
|
|
||||||
if (router.canDismiss()) {
|
|
||||||
router.dismissAll();
|
|
||||||
}
|
|
||||||
router.replace(href);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears the navigation stack and replaces the active route with the login screen.
|
|
||||||
*/
|
|
||||||
export function resetNavigationToLogin(): void {
|
|
||||||
resetNavigationToRoute("/login");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@ export function useModulesQuery() {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: contentQueryKeys.modules(preview),
|
queryKey: contentQueryKeys.modules(preview),
|
||||||
queryFn: () => contentApi.getModules(preview),
|
queryFn: () => contentApi.getModules(preview),
|
||||||
staleTime: 10 * 60 * 1000,
|
staleTime: 30 * 1000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import React, { useMemo } from "react";
|
||||||
import { ScrollView } from "react-native";
|
import { ScrollView } from "react-native";
|
||||||
|
|
||||||
import type { DetailRendererProps } from "../types/renderer.types";
|
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 { ContentValue } from "./shared/ContentValue";
|
||||||
import { Hero } from "./shared/Hero";
|
import { Hero } from "./shared/Hero";
|
||||||
import { ImageGallery } from "./shared/ImageGallery";
|
import { ImageGallery } from "./shared/ImageGallery";
|
||||||
|
|
@ -40,10 +40,7 @@ export function GenericDetailRenderer({
|
||||||
);
|
);
|
||||||
|
|
||||||
const definitionMap = useMemo(
|
const definitionMap = useMemo(
|
||||||
() =>
|
() => buildDefinitionLabelMap(definitions),
|
||||||
new Map(
|
|
||||||
(definitions ?? []).map((d) => [d.code, d.label]),
|
|
||||||
),
|
|
||||||
[definitions],
|
[definitions],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -73,8 +70,7 @@ export function GenericDetailRenderer({
|
||||||
!(isTherapeutic && key.toLowerCase() === "name"),
|
!(isTherapeutic && key.toLowerCase() === "name"),
|
||||||
)
|
)
|
||||||
.map(([key, value]) => {
|
.map(([key, value]) => {
|
||||||
const rawLabel = definitionMap.get(key) || key;
|
const label = resolveAttributeLabel(key, definitionMap);
|
||||||
const label = humanizeKey(rawLabel);
|
|
||||||
return (
|
return (
|
||||||
<SectionCard key={key} title={label}>
|
<SectionCard key={key} title={label}>
|
||||||
<ContentValue value={value} />
|
<ContentValue value={value} />
|
||||||
|
|
|
||||||
|
|
@ -549,7 +549,13 @@ export function GynecologyDiseaseCollectionRenderer(
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
||||||
return <CollectionScaffold {...props} header={header} />;
|
return (
|
||||||
|
<CollectionScaffold
|
||||||
|
{...props}
|
||||||
|
header={header}
|
||||||
|
countLabel="Identifications of patterns"
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createGynecologyDiseaseCollectionRenderer(templateCode: string) {
|
export function createGynecologyDiseaseCollectionRenderer(templateCode: string) {
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,21 @@ import { useRouter } from "expo-router";
|
||||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||||
|
|
||||||
import { Colors } from "@/theme";
|
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 { CollectionScaffold } from "../shared/CollectionScaffold";
|
||||||
import { ContentCountBadge } from "../shared/ContentCountBadge";
|
import { ContentCountBadge } from "../shared/ContentCountBadge";
|
||||||
import { greenTone } from "../shared/reading-palette";
|
import { greenTone } from "../shared/reading-palette";
|
||||||
import {
|
import {
|
||||||
useModuleContentDetailQuery,
|
useModuleContentDetailQuery,
|
||||||
useModuleTemplateContentDetailsQuery,
|
useModuleTemplateContentDetailsQuery,
|
||||||
|
useTemplateDefinitionsQuery,
|
||||||
} from "../../hooks/use-content-queries";
|
} from "../../hooks/use-content-queries";
|
||||||
import type {
|
import type {
|
||||||
CollectionItemRendererProps,
|
CollectionItemRendererProps,
|
||||||
|
|
@ -35,6 +43,10 @@ export function ModuleCatalogCollectionRenderer(props: CollectionRendererProps)
|
||||||
return <CollectionScaffold {...props} />;
|
return <CollectionScaffold {...props} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stripTrailingPeriod(value: string): string {
|
||||||
|
return value.replace(/\s*\.+\s*$/, "").trim();
|
||||||
|
}
|
||||||
|
|
||||||
function normalizePointCode(raw: string): string {
|
function normalizePointCode(raw: string): string {
|
||||||
let code = raw.replace(/\s*\([^)]*\)/g, "").trim().toLowerCase();
|
let code = raw.replace(/\s*\([^)]*\)/g, "").trim().toLowerCase();
|
||||||
code = code.replace(/^ren-/, "cv-");
|
code = code.replace(/^ren-/, "cv-");
|
||||||
|
|
@ -70,6 +82,16 @@ export function PatternAccordionCardRenderer({
|
||||||
contentId,
|
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
|
// Query all acupuncture points from m0001 to resolve links
|
||||||
const { data: pointsData } = useModuleTemplateContentDetailsQuery({
|
const { data: pointsData } = useModuleTemplateContentDetailsQuery({
|
||||||
module_code: "m0001",
|
module_code: "m0001",
|
||||||
|
|
@ -138,8 +160,8 @@ export function PatternAccordionCardRenderer({
|
||||||
? rawManifestations.split("\n").map((s) => s.trim()).filter(Boolean)
|
? rawManifestations.split("\n").map((s) => s.trim()).filter(Boolean)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
const tongue = asString(detailData.tongue);
|
const tongue = stripTrailingPeriod(asString(detailData.tongue));
|
||||||
const pulse = asString(detailData.pulse);
|
const pulse = stripTrailingPeriod(asString(detailData.pulse));
|
||||||
const rawPrinciples = detailData.treatment_principle;
|
const rawPrinciples = detailData.treatment_principle;
|
||||||
const treatmentPrinciples: string[] = Array.isArray(rawPrinciples)
|
const treatmentPrinciples: string[] = Array.isArray(rawPrinciples)
|
||||||
? (rawPrinciples as string[]).map(String).map((s) => s.trim()).filter(Boolean)
|
? (rawPrinciples as string[]).map(String).map((s) => s.trim()).filter(Boolean)
|
||||||
|
|
@ -213,7 +235,7 @@ export function PatternAccordionCardRenderer({
|
||||||
{clinicalManifestations.length > 0 ? (
|
{clinicalManifestations.length > 0 ? (
|
||||||
<View style={accordionStyles.section}>
|
<View style={accordionStyles.section}>
|
||||||
<Text style={accordionStyles.sectionTitle}>
|
<Text style={accordionStyles.sectionTitle}>
|
||||||
Clinical Manifestations
|
{resolveAttributeLabel("clinical_manifestations", labelMap, "Clinical Manifestations")}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={accordionStyles.bulletList}>
|
<View style={accordionStyles.bulletList}>
|
||||||
{clinicalManifestations.map((itemText, idx) => (
|
{clinicalManifestations.map((itemText, idx) => (
|
||||||
|
|
@ -226,22 +248,23 @@ export function PatternAccordionCardRenderer({
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{/* 2. Tongue & Pulse (Side-by-Side as drawn) */}
|
{/* 2. Tongue */}
|
||||||
{tongue || pulse ? (
|
{tongue ? (
|
||||||
<View style={accordionStyles.twoColumnBox}>
|
<View style={accordionStyles.section}>
|
||||||
{tongue ? (
|
<Text style={accordionStyles.sectionTitle}>
|
||||||
<View style={accordionStyles.column}>
|
{resolveAttributeLabel("tongue", labelMap, "Tongue")}
|
||||||
<Text style={accordionStyles.columnLabel}>Tongue</Text>
|
</Text>
|
||||||
<Text style={accordionStyles.columnValue}>{tongue}</Text>
|
<Text style={accordionStyles.sectionText}>{tongue}</Text>
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
{tongue && pulse ? <View style={accordionStyles.columnDivider} /> : null}
|
|
||||||
{pulse ? (
|
{/* 3. Pulse */}
|
||||||
<View style={accordionStyles.column}>
|
{pulse ? (
|
||||||
<Text style={accordionStyles.columnLabel}>Pulse</Text>
|
<View style={accordionStyles.section}>
|
||||||
<Text style={accordionStyles.columnValue}>{pulse}</Text>
|
<Text style={accordionStyles.sectionTitle}>
|
||||||
</View>
|
{resolveAttributeLabel("pulse", labelMap, "Pulse")}
|
||||||
) : null}
|
</Text>
|
||||||
|
<Text style={accordionStyles.sectionText}>{pulse}</Text>
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|
@ -249,7 +272,7 @@ export function PatternAccordionCardRenderer({
|
||||||
{treatmentPrinciples.length > 0 ? (
|
{treatmentPrinciples.length > 0 ? (
|
||||||
<View style={accordionStyles.section}>
|
<View style={accordionStyles.section}>
|
||||||
<Text style={accordionStyles.sectionTitle}>
|
<Text style={accordionStyles.sectionTitle}>
|
||||||
Treatment Principle
|
{resolveAttributeLabel("treatment_principle", labelMap, "Treatment Principle")}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={accordionStyles.bulletList}>
|
<View style={accordionStyles.bulletList}>
|
||||||
{treatmentPrinciples.map((itemText, idx) => (
|
{treatmentPrinciples.map((itemText, idx) => (
|
||||||
|
|
@ -262,42 +285,44 @@ export function PatternAccordionCardRenderer({
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{/* 4. Acupuncture Points & Method */}
|
{/* 4. Acupuncture Points */}
|
||||||
{pointChips.length > 0 || acuMethod ? (
|
{pointChips.length > 0 ? (
|
||||||
<View style={accordionStyles.section}>
|
<View style={accordionStyles.section}>
|
||||||
<Text style={accordionStyles.sectionTitle}>
|
<Text style={accordionStyles.sectionTitle}>
|
||||||
Acupuncture Points
|
{resolveAttributeLabel("acupuncture", labelMap, "Acupuncture Points")}
|
||||||
</Text>
|
</Text>
|
||||||
{pointChips.length > 0 ? (
|
<View style={accordionStyles.chipsContainer}>
|
||||||
<View style={accordionStyles.chipsContainer}>
|
{pointChips.map((pt, idx) => (
|
||||||
{pointChips.map((pt, idx) => (
|
<Pressable
|
||||||
<Pressable
|
key={idx}
|
||||||
key={idx}
|
accessibilityRole="button"
|
||||||
accessibilityRole="button"
|
accessibilityLabel={`View ${pt} acupuncture point`}
|
||||||
accessibilityLabel={`View ${pt} acupuncture point`}
|
onPress={() => handlePointPress(pt)}
|
||||||
onPress={() => handlePointPress(pt)}
|
style={({ pressed }) => [
|
||||||
style={({ pressed }) => [
|
accordionStyles.pointChip,
|
||||||
accordionStyles.pointChip,
|
pressed && accordionStyles.pointChipPressed,
|
||||||
pressed && accordionStyles.pointChipPressed,
|
]}
|
||||||
]}
|
>
|
||||||
>
|
<Text style={accordionStyles.pointChipText}>{pt}</Text>
|
||||||
<Text style={accordionStyles.pointChipText}>{pt}</Text>
|
<Ionicons
|
||||||
<Ionicons
|
name="chevron-forward"
|
||||||
name="chevron-forward"
|
size={12}
|
||||||
size={12}
|
color="#35664E"
|
||||||
color="#35664E"
|
style={{ marginLeft: 2 }}
|
||||||
style={{ marginLeft: 2 }}
|
/>
|
||||||
/>
|
</Pressable>
|
||||||
</Pressable>
|
))}
|
||||||
))}
|
</View>
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
{acuMethod ? (
|
|
||||||
<View style={accordionStyles.methodContainer}>
|
{/* 5. Method */}
|
||||||
<Text style={accordionStyles.subSectionLabel}>Method:</Text>
|
{acuMethod ? (
|
||||||
<Text style={accordionStyles.methodText}>{acuMethod}</Text>
|
<View style={accordionStyles.section}>
|
||||||
</View>
|
<Text style={accordionStyles.sectionTitle}>
|
||||||
) : null}
|
{resolveAttributeLabel("acupuncture.method", labelMap, "Method")}
|
||||||
|
</Text>
|
||||||
|
<Text style={accordionStyles.sectionText}>{acuMethod}</Text>
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|
@ -305,7 +330,7 @@ export function PatternAccordionCardRenderer({
|
||||||
{explanations.length > 0 ? (
|
{explanations.length > 0 ? (
|
||||||
<View style={accordionStyles.section}>
|
<View style={accordionStyles.section}>
|
||||||
<Text style={accordionStyles.sectionTitle}>
|
<Text style={accordionStyles.sectionTitle}>
|
||||||
Explanation
|
{resolveAttributeLabel("explanation", labelMap, "Explanation")}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={accordionStyles.explanationList}>
|
<View style={accordionStyles.explanationList}>
|
||||||
{explanations.map((exp, idx) => (
|
{explanations.map((exp, idx) => (
|
||||||
|
|
@ -321,7 +346,9 @@ export function PatternAccordionCardRenderer({
|
||||||
{/* 6. Category */}
|
{/* 6. Category */}
|
||||||
{category ? (
|
{category ? (
|
||||||
<View style={accordionStyles.categoryRow}>
|
<View style={accordionStyles.categoryRow}>
|
||||||
<Text style={accordionStyles.categoryLabel}>Category:</Text>
|
<Text style={accordionStyles.categoryLabel}>
|
||||||
|
{`${resolveAttributeLabel("category", labelMap, "Category")}:`}
|
||||||
|
</Text>
|
||||||
<View style={accordionStyles.categoryBadge}>
|
<View style={accordionStyles.categoryBadge}>
|
||||||
<Text style={accordionStyles.categoryBadgeText}>{category}</Text>
|
<Text style={accordionStyles.categoryBadgeText}>{category}</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -495,8 +522,7 @@ const accordionStyles = StyleSheet.create({
|
||||||
lineHeight: moderateScale(16),
|
lineHeight: moderateScale(16),
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: "#4A6B5B",
|
color: "#4A6B5B",
|
||||||
textTransform: "uppercase",
|
letterSpacing: 0.15,
|
||||||
letterSpacing: 0.7,
|
|
||||||
},
|
},
|
||||||
bulletList: {
|
bulletList: {
|
||||||
gap: verticalScale(8),
|
gap: verticalScale(8),
|
||||||
|
|
@ -519,38 +545,10 @@ const accordionStyles = StyleSheet.create({
|
||||||
lineHeight: moderateScale(21),
|
lineHeight: moderateScale(21),
|
||||||
color: "#334155",
|
color: "#334155",
|
||||||
},
|
},
|
||||||
twoColumnBox: {
|
sectionText: {
|
||||||
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: {
|
|
||||||
fontSize: moderateScale(14),
|
fontSize: moderateScale(14),
|
||||||
lineHeight: moderateScale(20),
|
lineHeight: moderateScale(21),
|
||||||
color: "#1E293B",
|
color: "#334155",
|
||||||
fontWeight: "600",
|
|
||||||
},
|
},
|
||||||
principleBox: {
|
principleBox: {
|
||||||
backgroundColor: greenTone.soft,
|
backgroundColor: greenTone.soft,
|
||||||
|
|
@ -591,23 +589,6 @@ const accordionStyles = StyleSheet.create({
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: "#35664E",
|
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: {
|
explanationList: {
|
||||||
gap: verticalScale(8),
|
gap: verticalScale(8),
|
||||||
},
|
},
|
||||||
|
|
@ -640,8 +621,7 @@ const accordionStyles = StyleSheet.create({
|
||||||
lineHeight: moderateScale(15),
|
lineHeight: moderateScale(15),
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: "#597064",
|
color: "#597064",
|
||||||
textTransform: "uppercase",
|
letterSpacing: 0.15,
|
||||||
letterSpacing: 0.5,
|
|
||||||
},
|
},
|
||||||
categoryBadge: {
|
categoryBadge: {
|
||||||
backgroundColor: "#EEF7F1",
|
backgroundColor: "#EEF7F1",
|
||||||
|
|
|
||||||
|
|
@ -234,8 +234,7 @@ const styles = StyleSheet.create({
|
||||||
lineHeight: 17,
|
lineHeight: 17,
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: "#597064",
|
color: "#597064",
|
||||||
textTransform: "uppercase",
|
letterSpacing: 0.15,
|
||||||
letterSpacing: 0.4,
|
|
||||||
},
|
},
|
||||||
pathway: {
|
pathway: {
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,6 @@ const styles = StyleSheet.create({
|
||||||
lineHeight: 18,
|
lineHeight: 18,
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: "#536F61",
|
color: "#536F61",
|
||||||
textTransform: "uppercase",
|
letterSpacing: 0.15,
|
||||||
letterSpacing: 0.35,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -216,8 +216,7 @@ const styles = StyleSheet.create({
|
||||||
fontSize: moderateScale(12),
|
fontSize: moderateScale(12),
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: Colors.textSecondary,
|
color: Colors.textSecondary,
|
||||||
textTransform: "uppercase",
|
letterSpacing: 0.2,
|
||||||
letterSpacing: 1,
|
|
||||||
marginBottom: verticalScale(12),
|
marginBottom: verticalScale(12),
|
||||||
marginLeft: moderateScale(4),
|
marginLeft: moderateScale(4),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,12 @@ import React, { useMemo } from "react";
|
||||||
import { ScrollView, StyleSheet } from "react-native";
|
import { ScrollView, StyleSheet } from "react-native";
|
||||||
|
|
||||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||||
import { asString, humanizeKey } from "../helpers/value";
|
import {
|
||||||
|
asString,
|
||||||
|
buildDefinitionLabelMap,
|
||||||
|
humanizeKey,
|
||||||
|
resolveAttributeLabel,
|
||||||
|
} from "../helpers/value";
|
||||||
import {
|
import {
|
||||||
findAttributePresentationRule,
|
findAttributePresentationRule,
|
||||||
isEmptyValue,
|
isEmptyValue,
|
||||||
|
|
@ -41,9 +46,7 @@ export function SixStagesDetailRenderer({
|
||||||
const title = humanizeKey(rawTitle);
|
const title = humanizeKey(rawTitle);
|
||||||
|
|
||||||
const orderedSections = useMemo(() => {
|
const orderedSections = useMemo(() => {
|
||||||
const definitionByLabel = new Map(
|
const definitionByLabel = buildDefinitionLabelMap(definitions);
|
||||||
(definitions ?? []).map((d) => [d.code, d.label]),
|
|
||||||
);
|
|
||||||
|
|
||||||
return Object.entries(data)
|
return Object.entries(data)
|
||||||
.filter(
|
.filter(
|
||||||
|
|
@ -55,8 +58,7 @@ export function SixStagesDetailRenderer({
|
||||||
.map(([key, value]) => {
|
.map(([key, value]) => {
|
||||||
const rule = findAttributePresentationRule(key, presentationAttributes);
|
const rule = findAttributePresentationRule(key, presentationAttributes);
|
||||||
const order = presentationDisplayOrder(rule);
|
const order = presentationDisplayOrder(rule);
|
||||||
const rawLabel = definitionByLabel.get(key) || key;
|
const label = resolveAttributeLabel(key, definitionByLabel);
|
||||||
const label = humanizeKey(rawLabel);
|
|
||||||
return { key, value, order, label };
|
return { key, value, order, label };
|
||||||
})
|
})
|
||||||
.sort((a, b) => a.order - b.order || a.label.localeCompare(b.label));
|
.sort((a, b) => a.order - b.order || a.label.localeCompare(b.label));
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,12 @@ import React, { useMemo } from "react";
|
||||||
import { ScrollView, StyleSheet } from "react-native";
|
import { ScrollView, StyleSheet } from "react-native";
|
||||||
|
|
||||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||||
import { asString, humanizeKey } from "../helpers/value";
|
import {
|
||||||
|
asString,
|
||||||
|
buildDefinitionLabelMap,
|
||||||
|
humanizeKey,
|
||||||
|
resolveAttributeLabel,
|
||||||
|
} from "../helpers/value";
|
||||||
import {
|
import {
|
||||||
findAttributePresentationRule,
|
findAttributePresentationRule,
|
||||||
isEmptyValue,
|
isEmptyValue,
|
||||||
|
|
@ -36,9 +41,7 @@ export function TcmPatternDetailRenderer({
|
||||||
const title = humanizeKey(rawTitle);
|
const title = humanizeKey(rawTitle);
|
||||||
|
|
||||||
const orderedSections = useMemo(() => {
|
const orderedSections = useMemo(() => {
|
||||||
const definitionByLabel = new Map(
|
const definitionByLabel = buildDefinitionLabelMap(definitions);
|
||||||
(definitions ?? []).map((d) => [d.code, d.label]),
|
|
||||||
);
|
|
||||||
|
|
||||||
return Object.entries(data)
|
return Object.entries(data)
|
||||||
.filter(
|
.filter(
|
||||||
|
|
@ -49,8 +52,7 @@ export function TcmPatternDetailRenderer({
|
||||||
.map(([key, value]) => {
|
.map(([key, value]) => {
|
||||||
const rule = findAttributePresentationRule(key, presentationAttributes);
|
const rule = findAttributePresentationRule(key, presentationAttributes);
|
||||||
const order = presentationDisplayOrder(rule);
|
const order = presentationDisplayOrder(rule);
|
||||||
const rawLabel = definitionByLabel.get(key) || key;
|
const label = resolveAttributeLabel(key, definitionByLabel);
|
||||||
const label = humanizeKey(rawLabel);
|
|
||||||
return { key, value, order, label };
|
return { key, value, order, label };
|
||||||
})
|
})
|
||||||
.sort((a, b) => a.order - b.order || a.label.localeCompare(b.label));
|
.sort((a, b) => a.order - b.order || a.label.localeCompare(b.label));
|
||||||
|
|
|
||||||
|
|
@ -452,8 +452,7 @@ const styles = StyleSheet.create({
|
||||||
lineHeight: 17,
|
lineHeight: 17,
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: "#597064",
|
color: "#597064",
|
||||||
textTransform: "uppercase",
|
letterSpacing: 0.15,
|
||||||
letterSpacing: 0.4,
|
|
||||||
},
|
},
|
||||||
sectionValue: {
|
sectionValue: {
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import type { AttributeDefinitionResponse } from "../../types/content.types";
|
||||||
|
|
||||||
export function asString(value: unknown): string {
|
export function asString(value: unknown): string {
|
||||||
if (typeof value === "string") return value;
|
if (typeof value === "string") return value;
|
||||||
if (typeof value === "number" || typeof value === "boolean") return String(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");
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import { Colors } from "@/theme";
|
||||||
import type { CollectionRendererProps } from "../../types/renderer.types";
|
import type { CollectionRendererProps } from "../../types/renderer.types";
|
||||||
|
|
||||||
export function CollectionScaffold(
|
export function CollectionScaffold(
|
||||||
props: CollectionRendererProps & { header?: React.ReactNode },
|
props: CollectionRendererProps & { header?: React.ReactNode; countLabel?: string },
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<FlatList
|
<FlatList
|
||||||
|
|
@ -30,7 +30,7 @@ export function CollectionScaffold(
|
||||||
<>
|
<>
|
||||||
{props.header}
|
{props.header}
|
||||||
<Text style={styles.resultCount} accessibilityLiveRegion="polite">
|
<Text style={styles.resultCount} accessibilityLiveRegion="polite">
|
||||||
{props.total} {props.total === 1 ? "result" : "results"}
|
{props.countLabel ?? `${props.total} ${props.total === 1 ? "result" : "results"}`}
|
||||||
</Text>
|
</Text>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
@ -86,8 +86,7 @@ const styles = StyleSheet.create({
|
||||||
fontSize: moderateScale(12),
|
fontSize: moderateScale(12),
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: Colors.textSecondary,
|
color: Colors.textSecondary,
|
||||||
textTransform: "uppercase",
|
letterSpacing: 0.2,
|
||||||
letterSpacing: 1,
|
|
||||||
marginBottom: verticalScale(8),
|
marginBottom: verticalScale(8),
|
||||||
marginLeft: moderateScale(4),
|
marginLeft: moderateScale(4),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,6 @@ const styles = StyleSheet.create({
|
||||||
lineHeight: 17,
|
lineHeight: 17,
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: Colors.textSecondary,
|
color: Colors.textSecondary,
|
||||||
textTransform: "uppercase",
|
letterSpacing: 0.15,
|
||||||
letterSpacing: 0.35,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,7 @@ const styles = StyleSheet.create({
|
||||||
lineHeight: 17,
|
lineHeight: 17,
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: "#597064",
|
color: "#597064",
|
||||||
textTransform: "uppercase",
|
letterSpacing: 0.15,
|
||||||
letterSpacing: 0.4,
|
|
||||||
},
|
},
|
||||||
value: { fontSize: 16, lineHeight: 25, color: "#334155" },
|
value: { fontSize: 16, lineHeight: 25, color: "#334155" },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,6 @@ const styles = StyleSheet.create({
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
lineHeight: 18,
|
lineHeight: 18,
|
||||||
color: "#536F61",
|
color: "#536F61",
|
||||||
textTransform: "uppercase",
|
letterSpacing: 0.15,
|
||||||
letterSpacing: 0.35,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,7 @@ const styles = StyleSheet.create({
|
||||||
lineHeight: 17,
|
lineHeight: 17,
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: "#617468",
|
color: "#617468",
|
||||||
textTransform: "uppercase",
|
letterSpacing: 0.15,
|
||||||
letterSpacing: 0.35,
|
|
||||||
},
|
},
|
||||||
value: { fontSize: 15, lineHeight: 23, color: "#334155" },
|
value: { fontSize: 15, lineHeight: 23, color: "#334155" },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ export interface ModuleResponse extends ModuleSummary {
|
||||||
release_version: string | null;
|
release_version: string | null;
|
||||||
expected_release_date: string | null;
|
expected_release_date: string | null;
|
||||||
release_notes: string | null;
|
release_notes: string | null;
|
||||||
|
plan_code?: string | null;
|
||||||
metadata: Record<string, unknown>;
|
metadata: Record<string, unknown>;
|
||||||
created_by: string | null;
|
created_by: string | null;
|
||||||
updated_by: string | null;
|
updated_by: string | null;
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,7 @@ export function toModuleIndexItem(module: ModuleResponse): ModuleIndexItem {
|
||||||
const visual = MODULE_VISUALS[module.code.toLowerCase()];
|
const visual = MODULE_VISUALS[module.code.toLowerCase()];
|
||||||
const metadataIcon = readMetadataString(module, "icon");
|
const metadataIcon = readMetadataString(module, "icon");
|
||||||
const metadataColor = readMetadataString(module, "color");
|
const metadataColor = readMetadataString(module, "color");
|
||||||
|
const apiPlanCode = asNonBlankString(module.plan_code);
|
||||||
const metadataPlanCode = readMetadataString(module, "plan_code");
|
const metadataPlanCode = readMetadataString(module, "plan_code");
|
||||||
const metadataIsDefaultFree = readMetadataBoolean(module, "is_default_free");
|
const metadataIsDefaultFree = readMetadataBoolean(module, "is_default_free");
|
||||||
|
|
||||||
|
|
@ -241,7 +242,7 @@ export function toModuleIndexItem(module: ModuleResponse): ModuleIndexItem {
|
||||||
icon: metadataIcon ?? visual?.icon ?? "folder-outline",
|
icon: metadataIcon ?? visual?.icon ?? "folder-outline",
|
||||||
color: metadataColor ?? visual?.color ?? "#4F46E5",
|
color: metadataColor ?? visual?.color ?? "#4F46E5",
|
||||||
isDefaultFree: metadataIsDefaultFree ?? visual?.isDefaultFree ?? false,
|
isDefaultFree: metadataIsDefaultFree ?? visual?.isDefaultFree ?? false,
|
||||||
planCode: metadataPlanCode ?? visual?.planCode ?? "",
|
planCode: apiPlanCode ?? metadataPlanCode ?? visual?.planCode ?? "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,9 @@ export default function HomeScreen() {
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
|
void modulesQuery.refetch().catch((error) => console.warn("Unable to refresh modules:", error));
|
||||||
void refreshSession().catch((error) => console.warn("Unable to refresh session:", error));
|
void refreshSession().catch((error) => console.warn("Unable to refresh session:", error));
|
||||||
}, [refreshSession]),
|
}, [modulesQuery.refetch, refreshSession]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const unlockedModules = useMemo(() => {
|
const unlockedModules = useMemo(() => {
|
||||||
|
|
|
||||||
|
|
@ -77,12 +77,15 @@ export default function ModulesIndexScreen() {
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
isNavigatingRef.current = false;
|
isNavigatingRef.current = false;
|
||||||
|
void modulesQuery.refetch().catch((error) => {
|
||||||
|
console.warn("Unable to refresh modules:", error);
|
||||||
|
});
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
void refreshAccess().catch((error) => {
|
void refreshAccess().catch((error) => {
|
||||||
console.warn("Unable to refresh module access:", error);
|
console.warn("Unable to refresh module access:", error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [accessToken, refreshAccess]),
|
}, [accessToken, modulesQuery.refetch, refreshAccess]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const items = useMemo(
|
const items = useMemo(
|
||||||
|
|
|
||||||
|
|
@ -92,11 +92,6 @@ export interface ResetPasswordRequest {
|
||||||
new_password: string;
|
new_password: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChangePasswordRequest {
|
|
||||||
old_password: string;
|
|
||||||
new_password: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface StatusMessageResponse {
|
export interface StatusMessageResponse {
|
||||||
status: string;
|
status: string;
|
||||||
message: string;
|
message: string;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue