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

16 lines
420 B
TypeScript
Raw Normal View History

import { NotFoundError, 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 NotFoundError();
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
}