2021-08-05 17:07:15 +00:00
|
|
|
import { resolver } from "blitz";
|
|
|
|
import { z } from "zod";
|
|
|
|
import db, { Prisma } from "db";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-08-05 17:07:15 +00:00
|
|
|
const Body = z.object({
|
|
|
|
phoneNumberId: z.string(),
|
|
|
|
});
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-08-05 17:07:15 +00:00
|
|
|
export default resolver.pipe(resolver.zod(Body), resolver.authorize(), async ({ phoneNumberId }, context) => {
|
|
|
|
const organizationId = context.session.orgId;
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-08-05 17:07:15 +00:00
|
|
|
return db.phoneCall.findMany({
|
|
|
|
where: { organizationId, phoneNumberId },
|
|
|
|
orderBy: { createdAt: Prisma.SortOrder.asc },
|
|
|
|
});
|
|
|
|
});
|