shellphone.app/app/phone-numbers/queries/get-current-phone-number.ts

22 lines
541 B
TypeScript
Raw Normal View History

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