feat(classes): optimize teacher dashboard ui and implement grade management
This commit is contained in:
45
src/modules/users/data-access.ts
Normal file
45
src/modules/users/data-access.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import "server-only"
|
||||
|
||||
import { cache } from "react"
|
||||
import { eq } from "drizzle-orm"
|
||||
|
||||
import { db } from "@/shared/db"
|
||||
import { users } from "@/shared/db/schema"
|
||||
|
||||
export type UserProfile = {
|
||||
id: string
|
||||
name: string | null
|
||||
email: string
|
||||
image: string | null
|
||||
role: string | null
|
||||
phone: string | null
|
||||
address: string | null
|
||||
gender: string | null
|
||||
age: number | null
|
||||
onboardedAt: Date | null
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
}
|
||||
|
||||
export const getUserProfile = cache(async (userId: string): Promise<UserProfile | null> => {
|
||||
const user = await db.query.users.findFirst({
|
||||
where: eq(users.id, userId),
|
||||
})
|
||||
|
||||
if (!user) return null
|
||||
|
||||
return {
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
email: user.email,
|
||||
image: user.image,
|
||||
role: user.role,
|
||||
phone: user.phone,
|
||||
address: user.address,
|
||||
gender: user.gender,
|
||||
age: user.age,
|
||||
onboardedAt: user.onboardedAt,
|
||||
createdAt: user.createdAt,
|
||||
updatedAt: user.updatedAt,
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user