2021-08-02 13:43:27 +00:00
|
|
|
import { NotFoundError, resolver } from "blitz";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-07-31 15:57:43 +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) => {
|
2021-07-31 15:57:43 +00:00
|
|
|
const customer = await getCurrentCustomer(null, context);
|
2021-08-02 10:02:49 +00:00
|
|
|
if (!customer) {
|
2021-08-02 13:43:27 +00:00
|
|
|
throw new NotFoundError();
|
2021-08-02 10:02:49 +00:00
|
|
|
}
|
|
|
|
|
2021-07-31 14:33:18 +00:00
|
|
|
return db.phoneNumber.findFirst({
|
2021-08-02 10:02:49 +00:00
|
|
|
where: { customerId: customer.id },
|
2021-07-31 14:33:18 +00:00
|
|
|
select: {
|
|
|
|
id: true,
|
|
|
|
phoneNumber: true,
|
|
|
|
phoneNumberSid: true,
|
|
|
|
},
|
2021-07-31 15:57:43 +00:00
|
|
|
});
|
|
|
|
});
|