2021-08-05 17:07:15 +00:00
|
|
|
import { resolver } from "blitz";
|
|
|
|
import { z } from "zod";
|
|
|
|
|
|
|
|
import db from "db";
|
|
|
|
import { enforceSuperAdminIfNotCurrentOrganization, setDefaultOrganizationId } from "../../core/utils";
|
|
|
|
|
|
|
|
export default resolver.pipe(
|
|
|
|
resolver.zod(z.object({ organizationId: z.string().optional() })),
|
|
|
|
resolver.authorize(),
|
|
|
|
setDefaultOrganizationId,
|
|
|
|
enforceSuperAdminIfNotCurrentOrganization,
|
|
|
|
async ({ organizationId }) => {
|
|
|
|
return db.phoneNumber.findFirst({
|
2021-10-20 22:24:18 +00:00
|
|
|
// TODO: use the active number, not the first one
|
2021-08-05 17:07:15 +00:00
|
|
|
where: { organizationId },
|
|
|
|
select: {
|
|
|
|
id: true,
|
2021-08-08 06:37:53 +00:00
|
|
|
organizationId: true,
|
2021-08-05 17:07:15 +00:00
|
|
|
number: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|