DB-backed workspace + LangGraph agent
This commit is contained in:
30
Frontend/server/api/contacts.get.ts
Normal file
30
Frontend/server/api/contacts.get.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { prisma } from "../utils/prisma";
|
||||
import { getAuthContext } from "../utils/auth";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const auth = await getAuthContext(event);
|
||||
const items = await prisma.contact.findMany({
|
||||
where: { teamId: auth.teamId },
|
||||
include: {
|
||||
note: { select: { content: true, updatedAt: true } },
|
||||
messages: { select: { occurredAt: true }, orderBy: { occurredAt: "desc" }, take: 1 },
|
||||
},
|
||||
orderBy: { updatedAt: "desc" },
|
||||
take: 500,
|
||||
});
|
||||
|
||||
return {
|
||||
items: items.map((c) => ({
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
avatar: c.avatarUrl ?? "",
|
||||
company: c.company ?? "",
|
||||
country: c.country ?? "",
|
||||
location: c.location ?? "",
|
||||
channels: [], // derived client-side from comm list for now
|
||||
lastContactAt: c.messages[0]?.occurredAt?.toISOString?.() ?? c.updatedAt.toISOString(),
|
||||
description: c.note?.content ?? "",
|
||||
})),
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user