shellphone.app/app/core/hooks/use-require-onboarding.ts

28 lines
713 B
TypeScript
Raw Normal View History

import { Routes, useRouter } from "blitz";
2021-07-31 14:33:18 +00:00
import useCurrentCustomer from "./use-current-customer";
import useCustomerPhoneNumber from "./use-customer-phone-number";
2021-07-31 14:33:18 +00:00
export default function useRequireOnboarding() {
const router = useRouter();
2021-08-01 14:01:51 +00:00
const { hasFilledTwilioCredentials, hasCompletedOnboarding } = useCurrentCustomer();
const customerPhoneNumber = useCustomerPhoneNumber();
2021-07-31 14:33:18 +00:00
2021-08-01 14:01:51 +00:00
if (hasCompletedOnboarding) {
return;
}
if (!hasFilledTwilioCredentials) {
throw router.push(Routes.StepTwo());
2021-07-31 14:33:18 +00:00
}
/*if (!customer.paddleCustomerId || !customer.paddleSubscriptionId) {
throw router.push(Routes.StepTwo());
return;
}*/
if (!customerPhoneNumber) {
throw router.push(Routes.StepThree());
2021-07-31 14:33:18 +00:00
}
}