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

25 lines
704 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();
const { customer, hasCompletedOnboarding } = useCurrentCustomer();
const customerPhoneNumber = useCustomerPhoneNumber();
2021-07-31 14:33:18 +00:00
if (!hasCompletedOnboarding) {
throw router.push(Routes.StepTwo());
2021-07-31 14:33:18 +00:00
}
/*if (!customer.paddleCustomerId || !customer.paddleSubscriptionId) {
throw router.push(Routes.StepTwo());
return;
}*/
console.log("customerPhoneNumber", customerPhoneNumber);
2021-07-31 14:33:18 +00:00
if (!customerPhoneNumber) {
throw router.push(Routes.StepThree());
2021-07-31 14:33:18 +00:00
}
}