45 lines
935 B
TypeScript
45 lines
935 B
TypeScript
import {
|
|
ADMIN_WELCOME_EVENT_PATH,
|
|
ADMIN_WELCOME_PACKAGES_PATH,
|
|
ADMIN_WELCOME_SUMMARY_PATH,
|
|
} from '../../constants';
|
|
|
|
type OnboardingRedirectInput = {
|
|
hasEvents: boolean;
|
|
hasActivePackage: boolean;
|
|
selectedPackageId?: number | null;
|
|
pathname: string;
|
|
isWelcomePath: boolean;
|
|
isBillingPath: boolean;
|
|
};
|
|
|
|
export function resolveOnboardingRedirect({
|
|
hasEvents,
|
|
hasActivePackage,
|
|
selectedPackageId,
|
|
pathname,
|
|
isWelcomePath,
|
|
isBillingPath,
|
|
}: OnboardingRedirectInput): string | null {
|
|
if (hasEvents) {
|
|
return null;
|
|
}
|
|
|
|
if (isWelcomePath || isBillingPath) {
|
|
return null;
|
|
}
|
|
|
|
const shouldContinueSummary = Boolean(selectedPackageId && selectedPackageId > 0);
|
|
const target = hasActivePackage
|
|
? ADMIN_WELCOME_EVENT_PATH
|
|
: shouldContinueSummary
|
|
? ADMIN_WELCOME_SUMMARY_PATH
|
|
: ADMIN_WELCOME_PACKAGES_PATH;
|
|
|
|
if (pathname === target) {
|
|
return null;
|
|
}
|
|
|
|
return target;
|
|
}
|