2021-07-31 15:57:43 +00:00
|
|
|
import { Routes, useRouter } from "blitz";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-08-05 17:07:15 +00:00
|
|
|
import useCurrentUser from "./use-current-user";
|
|
|
|
import useCurrentPhoneNumber from "./use-current-phone-number";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
|
|
|
export default function useRequireOnboarding() {
|
2021-07-31 15:57:43 +00:00
|
|
|
const router = useRouter();
|
2021-08-05 17:07:15 +00:00
|
|
|
const { hasFilledTwilioCredentials, hasCompletedOnboarding } = useCurrentUser();
|
|
|
|
const phoneNumber = useCurrentPhoneNumber();
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-08-01 14:01:51 +00:00
|
|
|
if (hasCompletedOnboarding) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasFilledTwilioCredentials) {
|
2021-07-31 15:57:43 +00:00
|
|
|
throw router.push(Routes.StepTwo());
|
2021-07-31 14:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-08-05 17:07:15 +00:00
|
|
|
/*if (!user.paddleCustomerId || !user.paddleSubscriptionId) {
|
2021-07-31 14:33:18 +00:00
|
|
|
throw router.push(Routes.StepTwo());
|
|
|
|
return;
|
|
|
|
}*/
|
|
|
|
|
2021-08-05 17:07:15 +00:00
|
|
|
if (!phoneNumber) {
|
2021-07-31 15:57:43 +00:00
|
|
|
throw router.push(Routes.StepThree());
|
2021-07-31 14:33:18 +00:00
|
|
|
}
|
|
|
|
}
|