feat(me): organize personal dashboard and localize user actions
This commit is contained in:
1 parent
2840ef5d9d
commit
85a6df162b
9 files changed
+768
-576
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import "server-only";
|
||||
import { and, asc, count, desc, eq, gt, or } from "drizzle-orm";
|
||||
import { and, asc, count, desc, eq, gt, inArray, or } from "drizzle-orm";
|
||||
import {
|
||||
db,
|
||||
MessengerFriendships,
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
User,
|
||||
UserReferrals,
|
||||
UsersBadges,
|
||||
UsersCurrency,
|
||||
UsersSettings,
|
||||
} from "@/lib/db";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
@@ -27,6 +28,7 @@ export async function loadUserDashboard(userId: number) {
|
||||
unreadCountRows,
|
||||
referralsRows,
|
||||
friends,
|
||||
currencyRows,
|
||||
] = await Promise.all([
|
||||
db
|
||||
.select({
|
||||
@@ -34,7 +36,6 @@ export async function loadUserDashboard(userId: number) {
|
||||
username: User.username,
|
||||
look: User.look,
|
||||
motto: User.motto,
|
||||
rank: User.rank,
|
||||
credits: User.credits,
|
||||
accountCreated: User.accountCreated,
|
||||
lastLogin: User.lastLogin,
|
||||
@@ -132,6 +133,16 @@ export async function loadUserDashboard(userId: number) {
|
||||
),
|
||||
)
|
||||
.catch(() => []),
|
||||
db
|
||||
.select({ type: UsersCurrency.type, amount: UsersCurrency.amount })
|
||||
.from(UsersCurrency)
|
||||
.where(
|
||||
and(
|
||||
eq(UsersCurrency.userId, userId),
|
||||
inArray(UsersCurrency.type, [0, 5]),
|
||||
),
|
||||
)
|
||||
.catch(() => null),
|
||||
]);
|
||||
|
||||
return {
|
||||
@@ -148,5 +159,6 @@ export async function loadUserDashboard(userId: number) {
|
||||
unreadCountRows,
|
||||
referralsRows,
|
||||
friends,
|
||||
currencyRows,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user