shellphone.app/app/core/hooks/use-require-onboarding.ts
2021-09-27 06:10:48 +08:00

23 lines
556 B
TypeScript

import { Routes, useRouter } from "blitz";
import useCurrentUser from "./use-current-user";
import useCurrentPhoneNumber from "./use-current-phone-number";
export default function useRequireOnboarding() {
const router = useRouter();
const { hasFilledTwilioCredentials, hasCompletedOnboarding } = useCurrentUser();
const phoneNumber = useCurrentPhoneNumber();
if (hasCompletedOnboarding) {
return;
}
if (!hasFilledTwilioCredentials) {
throw router.push(Routes.StepTwo());
}
if (!phoneNumber) {
throw router.push(Routes.StepThree());
}
}