shellphone.app/app/phone-calls/hooks/use-phone-calls.ts

16 lines
417 B
TypeScript
Raw Normal View History

import { useQuery } from "blitz";
2021-07-31 14:33:18 +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() {
const { customer } = useCurrentCustomer();
2021-07-31 14:33:18 +00:00
if (!customer) {
throw new Error("customer not found");
2021-07-31 14:33:18 +00:00
}
const { phoneCalls } = useQuery(getPhoneCalls, { customerId: customer.id })[0];
2021-07-31 14:33:18 +00:00
return phoneCalls;
2021-07-31 14:33:18 +00:00
}