shellphone.app/app/phone-numbers/queries/get-current-phone-number.ts
2021-08-06 01:14:19 +08:00

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,
},
});
},
);