shellphone.app/app/core/hooks/use-customer-phone-number.ts

13 lines
544 B
TypeScript
Raw Normal View History

import { useQuery } from "blitz";
2021-07-31 14:33:18 +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
return customerPhoneNumber;
2021-07-31 14:33:18 +00:00
}