shellphone.app/app/phone-calls/hooks/use-phone-calls.ts
m5r 2cf53533a3 replace early returns with NotFoundError
test /api/webhook/incoming-message
2021-08-02 21:44:04 +08:00

16 lines
420 B
TypeScript

import { NotFoundError, useQuery } from "blitz";
import useCurrentCustomer from "../../core/hooks/use-current-customer";
import getPhoneCalls from "../queries/get-phone-calls";
export default function usePhoneCalls() {
const { customer } = useCurrentCustomer();
if (!customer) {
throw new NotFoundError();
}
const { phoneCalls } = useQuery(getPhoneCalls, { customerId: customer.id })[0];
return phoneCalls;
}