Compare commits

..

1 Commits

Author SHA1 Message Date
ShivaniKhaire 2945f43d38 fix(auth): redirect to login after password change 2026-11-30 11:55:21 +05:30
26 changed files with 275 additions and 212 deletions

View File

@ -56,11 +56,10 @@ 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, modulesQuery.refetch, refreshAccess]),
}, [accessToken, refreshAccess]),
);
const items = useMemo(

View File

@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useEffect, useRef, useState } from "react";
import {
KeyboardAvoidingView,
Platform,
@ -8,17 +8,25 @@ import {
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 { 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 { apiClient } from "@/api";
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 [newPassword, setNewPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
@ -28,7 +36,25 @@ export default function ChangePasswordScreen() {
const [confirmError, setConfirmError] = useState("");
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 () => {
if (isLoading || isCompletingReloginRef.current) return;
let hasError = false;
setCurrentError("");
setNewError("");
@ -71,19 +97,38 @@ export default function ChangePasswordScreen() {
setIsLoading(true);
try {
await apiClient.post("/auth/change-password", {
await changePassword({
old_password: currentPassword,
new_password: newPassword,
});
const msg = "Password updated successfully!";
// Force full session termination immediately so the user must
// 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") {
window.alert(msg);
router.back();
redirectToLogin();
} else {
Alert.alert("Success", msg, [
{ text: "OK", onPress: () => router.back() },
]);
Alert.alert(
"Password Updated",
msg,
[{ text: "Log In", onPress: redirectToLogin }],
{ cancelable: false, onDismiss: redirectToLogin },
);
}
} catch (err: any) {
const errMsg =

View File

@ -2,6 +2,7 @@ import apiClient from "@/api/client";
import { API_ENDPOINTS } from "@/api/endpoints";
import type {
AuthTokenResponse,
ChangePasswordRequest,
ForgotPasswordRequest,
LoginRequest,
RegisterRequest,
@ -57,6 +58,19 @@ export async function resetPassword(
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 {
full_name?: string | null;
email?: string | null;

View File

@ -1,7 +1,7 @@
import React, { useState } from "react";
import React, { useCallback, useState } from "react";
import { Pressable, StyleSheet, Text, TouchableOpacity, View } from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { useRouter } from "expo-router";
import { useFocusEffect, useRouter } from "expo-router";
import {
moderateScale,
scale,
@ -16,8 +16,15 @@ import EnvironmentSelectorModal from "@/components/EnvironmentSelectorModal";
export default function LoginHeader() {
const router = useRouter();
const [modalVisible, setModalVisible] = useState(false);
const [canGoBack, setCanGoBack] = useState(false);
const activeConfig = useEnvironmentStore((state) => state.getActiveConfig());
useFocusEffect(
useCallback(() => {
setCanGoBack(router.canGoBack());
}, [router]),
);
const badgeColor =
activeConfig.key === "prod"
? "#10B981"
@ -28,18 +35,26 @@ export default function LoginHeader() {
return (
<View style={styles.container}>
<View style={styles.topRow}>
<Pressable
accessibilityRole="button"
accessibilityLabel="Go Back"
hitSlop={10}
onPress={() => router.back()}
style={styles.backButton}
>
<Ionicons
name="arrow-back"
size={moderateScale(24)}
/>
</Pressable>
{canGoBack ? (
<Pressable
accessibilityRole="button"
accessibilityLabel="Go Back"
hitSlop={10}
onPress={() => {
if (router.canGoBack()) {
router.back();
}
}}
style={styles.backButton}
>
<Ionicons
name="arrow-back"
size={moderateScale(24)}
/>
</Pressable>
) : (
<View style={styles.backButton} />
)}
{ENABLE_ENV_SWITCHER && (
<TouchableOpacity

View File

@ -0,0 +1,20 @@
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");
}

View File

@ -15,7 +15,7 @@ export function useModulesQuery() {
return useQuery({
queryKey: contentQueryKeys.modules(preview),
queryFn: () => contentApi.getModules(preview),
staleTime: 30 * 1000,
staleTime: 10 * 60 * 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 { buildDefinitionLabelMap, humanizeKey, resolveAttributeLabel } from "./helpers/value";
import { humanizeKey } from "./helpers/value";
import { ContentValue } from "./shared/ContentValue";
import { Hero } from "./shared/Hero";
import { ImageGallery } from "./shared/ImageGallery";
@ -40,7 +40,10 @@ export function GenericDetailRenderer({
);
const definitionMap = useMemo(
() => buildDefinitionLabelMap(definitions),
() =>
new Map(
(definitions ?? []).map((d) => [d.code, d.label]),
),
[definitions],
);
@ -70,7 +73,8 @@ export function GenericDetailRenderer({
!(isTherapeutic && key.toLowerCase() === "name"),
)
.map(([key, value]) => {
const label = resolveAttributeLabel(key, definitionMap);
const rawLabel = definitionMap.get(key) || key;
const label = humanizeKey(rawLabel);
return (
<SectionCard key={key} title={label}>
<ContentValue value={value} />

View File

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

View File

@ -14,21 +14,13 @@ import { useRouter } from "expo-router";
import { moderateScale, verticalScale } from "react-native-size-matters";
import { Colors } from "@/theme";
import {
asNumber,
asString,
asStringArray,
buildDefinitionLabelMap,
humanizeKey,
resolveAttributeLabel,
} from "../helpers/value";
import { asNumber, asString, asStringArray, humanizeKey } 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,
@ -43,10 +35,6 @@ 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-");
@ -82,16 +70,6 @@ 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",
@ -160,8 +138,8 @@ export function PatternAccordionCardRenderer({
? rawManifestations.split("\n").map((s) => s.trim()).filter(Boolean)
: [];
const tongue = stripTrailingPeriod(asString(detailData.tongue));
const pulse = stripTrailingPeriod(asString(detailData.pulse));
const tongue = asString(detailData.tongue);
const pulse = 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)
@ -235,7 +213,7 @@ export function PatternAccordionCardRenderer({
{clinicalManifestations.length > 0 ? (
<View style={accordionStyles.section}>
<Text style={accordionStyles.sectionTitle}>
{resolveAttributeLabel("clinical_manifestations", labelMap, "Clinical Manifestations")}
Clinical Manifestations
</Text>
<View style={accordionStyles.bulletList}>
{clinicalManifestations.map((itemText, idx) => (
@ -248,23 +226,22 @@ export function PatternAccordionCardRenderer({
</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>
{/* 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}
</View>
) : null}
@ -272,7 +249,7 @@ export function PatternAccordionCardRenderer({
{treatmentPrinciples.length > 0 ? (
<View style={accordionStyles.section}>
<Text style={accordionStyles.sectionTitle}>
{resolveAttributeLabel("treatment_principle", labelMap, "Treatment Principle")}
Treatment Principle
</Text>
<View style={accordionStyles.bulletList}>
{treatmentPrinciples.map((itemText, idx) => (
@ -285,44 +262,42 @@ export function PatternAccordionCardRenderer({
</View>
) : null}
{/* 4. Acupuncture Points */}
{pointChips.length > 0 ? (
{/* 4. Acupuncture Points & Method */}
{pointChips.length > 0 || acuMethod ? (
<View style={accordionStyles.section}>
<Text style={accordionStyles.sectionTitle}>
{resolveAttributeLabel("acupuncture", labelMap, "Acupuncture Points")}
Acupuncture Points
</Text>
<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>
{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>
) : null}
@ -330,7 +305,7 @@ export function PatternAccordionCardRenderer({
{explanations.length > 0 ? (
<View style={accordionStyles.section}>
<Text style={accordionStyles.sectionTitle}>
{resolveAttributeLabel("explanation", labelMap, "Explanation")}
Explanation
</Text>
<View style={accordionStyles.explanationList}>
{explanations.map((exp, idx) => (
@ -346,9 +321,7 @@ export function PatternAccordionCardRenderer({
{/* 6. Category */}
{category ? (
<View style={accordionStyles.categoryRow}>
<Text style={accordionStyles.categoryLabel}>
{`${resolveAttributeLabel("category", labelMap, "Category")}:`}
</Text>
<Text style={accordionStyles.categoryLabel}>Category:</Text>
<View style={accordionStyles.categoryBadge}>
<Text style={accordionStyles.categoryBadgeText}>{category}</Text>
</View>
@ -522,7 +495,8 @@ const accordionStyles = StyleSheet.create({
lineHeight: moderateScale(16),
fontWeight: "700",
color: "#4A6B5B",
letterSpacing: 0.15,
textTransform: "uppercase",
letterSpacing: 0.7,
},
bulletList: {
gap: verticalScale(8),
@ -545,10 +519,38 @@ const accordionStyles = StyleSheet.create({
lineHeight: moderateScale(21),
color: "#334155",
},
sectionText: {
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: {
fontSize: moderateScale(14),
lineHeight: moderateScale(21),
color: "#334155",
lineHeight: moderateScale(20),
color: "#1E293B",
fontWeight: "600",
},
principleBox: {
backgroundColor: greenTone.soft,
@ -589,6 +591,23 @@ 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),
},
@ -621,7 +640,8 @@ const accordionStyles = StyleSheet.create({
lineHeight: moderateScale(15),
fontWeight: "700",
color: "#597064",
letterSpacing: 0.15,
textTransform: "uppercase",
letterSpacing: 0.5,
},
categoryBadge: {
backgroundColor: "#EEF7F1",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,7 +31,6 @@ 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

@ -224,7 +224,6 @@ 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");
@ -242,7 +241,7 @@ export function toModuleIndexItem(module: ModuleResponse): ModuleIndexItem {
icon: metadataIcon ?? visual?.icon ?? "folder-outline",
color: metadataColor ?? visual?.color ?? "#4F46E5",
isDefaultFree: metadataIsDefaultFree ?? visual?.isDefaultFree ?? false,
planCode: apiPlanCode ?? metadataPlanCode ?? visual?.planCode ?? "",
planCode: metadataPlanCode ?? visual?.planCode ?? "",
};
}

View File

@ -65,9 +65,8 @@ 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));
}, [modulesQuery.refetch, refreshSession]),
}, [refreshSession]),
);
const unlockedModules = useMemo(() => {

View File

@ -77,15 +77,12 @@ 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, modulesQuery.refetch, refreshAccess]),
}, [accessToken, refreshAccess]),
);
const items = useMemo(

View File

@ -92,6 +92,11 @@ export interface ResetPasswordRequest {
new_password: string;
}
export interface ChangePasswordRequest {
old_password: string;
new_password: string;
}
export interface StatusMessageResponse {
status: string;
message: string;