From 013b3f4afe571db487fea0747c70de15e2ff5dbb Mon Sep 17 00:00:00 2001 From: xyx Date: Mon, 13 Jul 2026 17:18:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8A=BC=E9=87=91=E9=A1=B5=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=89=B9=E9=87=8F=E6=9E=84=E5=BB=BA=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E7=9A=84=E5=8A=9F=E8=83=BD=E4=BB=A5=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E5=AD=A6=E7=94=9F=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../deposit-student-option.integration.test.ts | 11 ++++++++++- .../src/pages/Deposits/deposit-student-option.ts | 3 +++ apps/admin/src/pages/Deposits/index.tsx | 7 ++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/admin/src/pages/Deposits/deposit-student-option.integration.test.ts b/apps/admin/src/pages/Deposits/deposit-student-option.integration.test.ts index b876ebe..92041e8 100644 --- a/apps/admin/src/pages/Deposits/deposit-student-option.integration.test.ts +++ b/apps/admin/src/pages/Deposits/deposit-student-option.integration.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import { buildDepositStudentOption } from './deposit-student-option'; +import { buildDepositStudentOption, buildDepositStudentOptions } from './deposit-student-option'; describe('deposit student option', () => { it('uses the student number as the non-sensitive identifier', () => { @@ -17,4 +17,13 @@ describe('deposit student option', () => { label: '张三 (#23)', }); }); + + it('uses lookup rows without requiring a status field', () => { + expect(buildDepositStudentOptions([{ id: 23, name: '张三', studentNo: 'S2026001' }])).toEqual([ + { + value: 23, + label: '张三 (S2026001)', + }, + ]); + }); }); diff --git a/apps/admin/src/pages/Deposits/deposit-student-option.ts b/apps/admin/src/pages/Deposits/deposit-student-option.ts index 732d6b2..3346453 100644 --- a/apps/admin/src/pages/Deposits/deposit-student-option.ts +++ b/apps/admin/src/pages/Deposits/deposit-student-option.ts @@ -8,3 +8,6 @@ export const buildDepositStudentOption = (student: DepositStudentLookup) => ({ value: student.id, label: `${student.name} (${student.studentNo || `#${student.id}`})`, }); + +export const buildDepositStudentOptions = (students: DepositStudentLookup[]) => + students.map(buildDepositStudentOption); diff --git a/apps/admin/src/pages/Deposits/index.tsx b/apps/admin/src/pages/Deposits/index.tsx index bc37853..b1911e7 100644 --- a/apps/admin/src/pages/Deposits/index.tsx +++ b/apps/admin/src/pages/Deposits/index.tsx @@ -19,7 +19,7 @@ import dayjs from 'dayjs'; import api from '../../api'; import PermissionButton from '../../components/PermissionButton'; import { message } from '../../ui/app-message'; -import { buildDepositStudentOption } from './deposit-student-option'; +import { buildDepositStudentOptions } from './deposit-student-option'; const statusMap: Record = { paid: { text: '已缴', color: 'green' }, @@ -86,10 +86,7 @@ const DepositsPage: React.FC = () => { }, [data, searchText, filterStatus]); const studentOptions = useMemo( - () => - students - .filter((s: any) => s.status === 'active') - .map(buildDepositStudentOption), + () => buildDepositStudentOptions(students), [students], );