refactor GetById APIs for Students, Teachers, and UserMetas to use consistent type definitions and expand parameters
```
This commit is contained in:
louiscklaw
2025-05-15 11:12:29 +08:00
parent e523f80123
commit d0215cf23f
4 changed files with 44 additions and 12 deletions

View File

@@ -1,12 +1,16 @@
// src/db/Students/GetById.tsx
//
import { COL_USER_METAS } from '@/constants';
import { pb } from '@/lib/pb';
import type { DBUserMeta, UserMeta } from '@/components/dashboard/user_meta/type.d';
import type { DBStudent, Student } from '@/components/dashboard/student/type';
export async function getStudentById(id: string): Promise<UserMeta> {
const record = await pb.collection(COL_USER_METAS).getOne<DBUserMeta>(id, { expand: 'billingAddress, helloworld' });
export async function getStudentById(id: string): Promise<Student> {
const record = await pb
.collection(COL_USER_METAS)
.getOne<DBStudent>(id, { expand: 'billingAddress, helloworld', requestKey: null });
const temp: UserMeta = {
const temp: Student = {
id: record.id,
name: record.name,
email: record.email,