Files
triggerdotdev--trigger.dev/apps/webapp/app/presenters/NewOrganizationPresenter.server.ts
T
2026-07-13 13:32:57 +08:00

26 lines
670 B
TypeScript

import type { PrismaClient, User } from "@trigger.dev/database";
import { prisma } from "~/db.server";
export class NewOrganizationPresenter {
#prismaClient: PrismaClient;
constructor(prismaClient: PrismaClient = prisma) {
this.#prismaClient = prismaClient;
}
public async call({ userId }: { userId: User["id"] }) {
const organizations = await this.#prismaClient.organization.findMany({
select: {
projects: {
where: { deletedAt: null },
},
},
where: { members: { some: { userId } } },
});
return {
hasOrganizations: organizations.filter((o) => o.projects.length > 0).length > 0,
};
}
}