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 },
|
2021-08-13 15:54:13 +00:00
|
|
|
orderBy: { createdAt: Prisma.SortOrder.desc },
|
2021-08-05 17:07:15 +00:00
|
|
|
});
|
|
|
|
});
|