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 getCurrentCustomerPhoneNumber from "../../phone-numbers/queries/get-current-customer-phone-number";
|
|
|
|
import useCurrentCustomer from "./use-current-customer";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
|
|
|
export default function useCustomerPhoneNumber() {
|
2021-08-01 14:01:51 +00:00
|
|
|
const { customer } = useCurrentCustomer();
|
|
|
|
const hasFilledTwilioCredentials = Boolean(customer && customer.accountSid && customer.authToken);
|
|
|
|
const [customerPhoneNumber] = useQuery(getCurrentCustomerPhoneNumber, {}, { enabled: hasFilledTwilioCredentials });
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-07-31 15:57:43 +00:00
|
|
|
return customerPhoneNumber;
|
2021-07-31 14:33:18 +00:00
|
|
|
}
|