2021-07-31 15:57:43 +00:00
|
|
|
import { resolver } from "blitz";
|
|
|
|
import db from "db";
|
|
|
|
import { z } from "zod";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
|
|
|
const GetCustomerPhoneNumber = z.object({
|
|
|
|
// This accepts type of undefined, but is required at runtime
|
|
|
|
customerId: z.string().optional().refine(Boolean, "Required"),
|
2021-07-31 15:57:43 +00:00
|
|
|
});
|
2021-07-31 14:33:18 +00:00
|
|
|
|
|
|
|
export default resolver.pipe(resolver.zod(GetCustomerPhoneNumber), async ({ customerId }) =>
|
|
|
|
db.phoneNumber.findFirst({
|
|
|
|
where: { customerId },
|
|
|
|
select: {
|
|
|
|
id: true,
|
|
|
|
phoneNumber: true,
|
|
|
|
phoneNumberSid: true,
|
|
|
|
},
|
2021-08-01 12:04:04 +00:00
|
|
|
}),
|
2021-07-31 15:57:43 +00:00
|
|
|
);
|