feat(medications): 优化药物显示逻辑,未服用药品优先排序并更新计数逻辑
This commit is contained in:
@@ -177,12 +177,24 @@ export default function MedicationsScreen() {
|
||||
if (activeFilter === 'all') {
|
||||
return medicationsWithImages;
|
||||
}
|
||||
|
||||
// "未服用" tab 包含 missed(已错过)和 upcoming(待服用)两种状态
|
||||
if (activeFilter === 'missed') {
|
||||
return medicationsWithImages.filter((item: any) =>
|
||||
item.status === 'missed' || item.status === 'upcoming'
|
||||
);
|
||||
}
|
||||
|
||||
// 其他状态按原逻辑过滤
|
||||
return medicationsWithImages.filter((item: any) => item.status === activeFilter);
|
||||
}, [activeFilter, medicationsWithImages]);
|
||||
|
||||
const counts = useMemo(() => {
|
||||
const taken = medicationsWithImages.filter((item: any) => item.status === 'taken').length;
|
||||
const missed = medicationsWithImages.filter((item: any) => item.status === 'missed').length;
|
||||
// "未服用"计数包含 missed(已错过)和 upcoming(待服用)
|
||||
const missed = medicationsWithImages.filter((item: any) =>
|
||||
item.status === 'missed' || item.status === 'upcoming'
|
||||
).length;
|
||||
return {
|
||||
all: medicationsWithImages.length,
|
||||
taken,
|
||||
|
||||
Reference in New Issue
Block a user