28 lines
776 B
TypeScript
28 lines
776 B
TypeScript
import { prisma } from "../utils/prisma";
|
|
import { getAuthContext } from "../utils/auth";
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const auth = await getAuthContext(event);
|
|
|
|
const items = await prisma.feedCard.findMany({
|
|
where: { teamId: auth.teamId },
|
|
include: { contact: { select: { name: true } } },
|
|
orderBy: { happenedAt: "desc" },
|
|
take: 200,
|
|
});
|
|
|
|
return {
|
|
items: items.map((c) => ({
|
|
id: c.id,
|
|
at: c.happenedAt.toISOString(),
|
|
contact: c.contact?.name ?? "",
|
|
text: c.text,
|
|
proposal: c.proposalJson as any,
|
|
decision:
|
|
c.decision === "ACCEPTED" ? "accepted" : c.decision === "REJECTED" ? "rejected" : ("pending" as const),
|
|
decisionNote: c.decisionNote ?? undefined,
|
|
})),
|
|
};
|
|
});
|
|
|