mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-05-09 11:01:45 +00:00
fix(inbox): melhorar filtros e identidade visual
This commit is contained in:
@@ -39,18 +39,26 @@ export async function fetchInboxItemsPage(
|
||||
{
|
||||
page,
|
||||
pageSize,
|
||||
sourceApp,
|
||||
}: {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
sourceApp?: string | null;
|
||||
},
|
||||
): Promise<{
|
||||
items: InboxItem[];
|
||||
pagination: InboxPaginationState;
|
||||
}> {
|
||||
const where = and(
|
||||
eq(inboxItems.userId, userId),
|
||||
eq(inboxItems.status, status),
|
||||
sourceApp ? eq(inboxItems.sourceAppName, sourceApp) : undefined,
|
||||
);
|
||||
|
||||
const [countRow] = await db
|
||||
.select({ total: count() })
|
||||
.from(inboxItems)
|
||||
.where(and(eq(inboxItems.userId, userId), eq(inboxItems.status, status)));
|
||||
.where(where);
|
||||
|
||||
const totalItems = Number(countRow?.total ?? 0);
|
||||
const totalPages = Math.max(Math.ceil(totalItems / pageSize), 1);
|
||||
@@ -60,7 +68,7 @@ export async function fetchInboxItemsPage(
|
||||
const items = await db
|
||||
.select()
|
||||
.from(inboxItems)
|
||||
.where(and(eq(inboxItems.userId, userId), eq(inboxItems.status, status)))
|
||||
.where(where)
|
||||
.orderBy(desc(inboxItems.notificationTimestamp), desc(inboxItems.createdAt))
|
||||
.limit(pageSize)
|
||||
.offset(offset);
|
||||
@@ -76,6 +84,22 @@ export async function fetchInboxItemsPage(
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchInboxSourceApps(
|
||||
userId: string,
|
||||
status: InboxStatus,
|
||||
): Promise<string[]> {
|
||||
const rows = await db
|
||||
.select({ name: inboxItems.sourceAppName })
|
||||
.from(inboxItems)
|
||||
.where(and(eq(inboxItems.userId, userId), eq(inboxItems.status, status)));
|
||||
|
||||
const seen = new Set<string>();
|
||||
for (const row of rows) {
|
||||
if (row.name) seen.add(row.name);
|
||||
}
|
||||
return [...seen].sort();
|
||||
}
|
||||
|
||||
export async function fetchInboxStatusCounts(
|
||||
userId: string,
|
||||
): Promise<InboxStatusCounts> {
|
||||
|
||||
Reference in New Issue
Block a user