22 lines
541 B
TypeScript
22 lines
541 B
TypeScript
|
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({
|
||
|
where: { organizationId },
|
||
|
select: {
|
||
|
id: true,
|
||
|
number: true,
|
||
|
},
|
||
|
});
|
||
|
},
|
||
|
);
|