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

21 lines
468 B
TypeScript
Raw Normal View History

import { resolver } from "blitz";
2021-07-31 14:33:18 +00:00
import db from "db";
import getCurrentCustomer from "../../customers/queries/get-current-customer";
2021-07-31 14:33:18 +00:00
export default resolver.pipe(resolver.authorize(), async (_ = null, context) => {
const customer = await getCurrentCustomer(null, context);
if (!customer) {
return;
}
2021-07-31 14:33:18 +00:00
return db.phoneNumber.findFirst({
where: { customerId: customer.id },
2021-07-31 14:33:18 +00:00
select: {
id: true,
phoneNumber: true,
phoneNumberSid: true,
},
});
});