2021-07-31 15:57:43 +00:00
|
|
|
import { useQuery } from "blitz";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-07-31 15:57:43 +00:00
|
|
|
import useCurrentCustomer from "../../core/hooks/use-current-customer";
|
|
|
|
import getPhoneCalls from "../queries/get-phone-calls";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
|
|
|
export default function usePhoneCalls() {
|
2021-07-31 15:57:43 +00:00
|
|
|
const { customer } = useCurrentCustomer();
|
2021-07-31 14:33:18 +00:00
|
|
|
if (!customer) {
|
2021-07-31 15:57:43 +00:00
|
|
|
throw new Error("customer not found");
|
2021-07-31 14:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-07-31 15:57:43 +00:00
|
|
|
const { phoneCalls } = useQuery(getPhoneCalls, { customerId: customer.id })[0];
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-07-31 15:57:43 +00:00
|
|
|
return phoneCalls;
|
2021-07-31 14:33:18 +00:00
|
|
|
}
|