/
MariaTsys
/
courseworkPP
Обзор
Документация
Войти
/
MariaTsys
/
courseworkPP
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/app/_components/mainPage/UserPanel.tsx
53 строки
1 KB
Maria
first_commit
09 май 2025, 12:17
09 май 2025, 12:17
af55308
Код
Авторство
О чём код?
import { db } from "~/server/db"; import { auth } from "~/server/auth"; import { Section } from "../book/Section"; import Link from "next/link"; import { UserName } from "./UserName"; export async function UserPanel() { const session = await auth(); if (!session) return null; const bestBooks = await db.book.findMany({ where: { rating: { gt: 4.5 } }, take: 5, orderBy: { rating: "desc" }, }); const newBooks = await db.book.findMany({ take: 5, orderBy: { createdAt: "desc" }, }); return ( <main className="flex-1 px-4 py-6"> {!session.user.name && <UserName />} <h1 className="main-heading text-3xl font-bold mb-4">Главное</h1> {/* Лучшее */} <div className="mb-8"> <div className="flex items-center justify-between mb-4"> <h2 className="text-2xl font-semibold">Лучшее</h2> <Link href="/collections/best" className="btn btn-sm btn-outline"> Смотреть все </Link> </div> <Section title="" books={bestBooks} /> </div> {/* Новое */} <div className="mb-8"> <div className="flex items-center justify-between mb-4"> <h2 className="text-2xl font-semibold">Новое</h2> <Link href="/collections/new" className="btn btn-sm btn-outline"> Смотреть все </Link> </div> <Section title="" books={newBooks} /> </div> </main> ); }