2021-08-02 13:43:27 +00:00
|
|
|
import { NotFoundError, useQuery } from "blitz";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-08-05 17:07:15 +00:00
|
|
|
import useCurrentPhoneNumber from "../..//core/hooks/use-current-phone-number";
|
2021-07-31 15:57:43 +00:00
|
|
|
import getPhoneCalls from "../queries/get-phone-calls";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
|
|
|
export default function usePhoneCalls() {
|
2021-08-05 17:07:15 +00:00
|
|
|
const phoneNumber = useCurrentPhoneNumber();
|
|
|
|
if (!phoneNumber) {
|
2021-08-02 13:43:27 +00:00
|
|
|
throw new NotFoundError();
|
2021-07-31 14:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-08-05 17:07:15 +00:00
|
|
|
return useQuery(getPhoneCalls, { phoneNumberId: phoneNumber.id });
|
2021-07-31 14:33:18 +00:00
|
|
|
}
|