Admin package summary sheet
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { resolveOnboardingRedirect } from './onboardingGuard';
|
||||
import {
|
||||
ADMIN_WELCOME_BASE_PATH,
|
||||
ADMIN_WELCOME_EVENT_PATH,
|
||||
ADMIN_WELCOME_SUMMARY_PATH,
|
||||
ADMIN_BILLING_PATH,
|
||||
} from '../../constants';
|
||||
|
||||
describe('resolveOnboardingRedirect', () => {
|
||||
@@ -11,23 +9,8 @@ describe('resolveOnboardingRedirect', () => {
|
||||
const result = resolveOnboardingRedirect({
|
||||
hasEvents: true,
|
||||
hasActivePackage: false,
|
||||
selectedPackageId: null,
|
||||
remainingEvents: null,
|
||||
pathname: '/event-admin/mobile/dashboard',
|
||||
isWelcomePath: false,
|
||||
isBillingPath: false,
|
||||
isOnboardingDismissed: false,
|
||||
isOnboardingCompleted: false,
|
||||
});
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for welcome paths', () => {
|
||||
const result = resolveOnboardingRedirect({
|
||||
hasEvents: false,
|
||||
hasActivePackage: false,
|
||||
selectedPackageId: null,
|
||||
pathname: ADMIN_WELCOME_BASE_PATH,
|
||||
isWelcomePath: true,
|
||||
isBillingPath: false,
|
||||
isOnboardingDismissed: false,
|
||||
isOnboardingCompleted: false,
|
||||
@@ -39,9 +22,8 @@ describe('resolveOnboardingRedirect', () => {
|
||||
const result = resolveOnboardingRedirect({
|
||||
hasEvents: false,
|
||||
hasActivePackage: false,
|
||||
selectedPackageId: null,
|
||||
pathname: '/event-admin/mobile/billing',
|
||||
isWelcomePath: false,
|
||||
remainingEvents: null,
|
||||
pathname: ADMIN_BILLING_PATH,
|
||||
isBillingPath: true,
|
||||
isOnboardingDismissed: false,
|
||||
isOnboardingCompleted: false,
|
||||
@@ -53,9 +35,8 @@ describe('resolveOnboardingRedirect', () => {
|
||||
const result = resolveOnboardingRedirect({
|
||||
hasEvents: false,
|
||||
hasActivePackage: true,
|
||||
selectedPackageId: null,
|
||||
remainingEvents: 1,
|
||||
pathname: '/event-admin/mobile/events/new',
|
||||
isWelcomePath: false,
|
||||
isBillingPath: false,
|
||||
isOnboardingDismissed: false,
|
||||
isOnboardingCompleted: false,
|
||||
@@ -63,55 +44,51 @@ describe('resolveOnboardingRedirect', () => {
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('redirects to event setup when package active', () => {
|
||||
it('redirects to billing when no active package', () => {
|
||||
const result = resolveOnboardingRedirect({
|
||||
hasEvents: false,
|
||||
hasActivePackage: false,
|
||||
remainingEvents: null,
|
||||
pathname: '/event-admin/mobile/dashboard',
|
||||
isBillingPath: false,
|
||||
isOnboardingDismissed: false,
|
||||
isOnboardingCompleted: false,
|
||||
});
|
||||
expect(result).toBe(ADMIN_BILLING_PATH);
|
||||
});
|
||||
|
||||
it('redirects to billing when no remaining events', () => {
|
||||
const result = resolveOnboardingRedirect({
|
||||
hasEvents: false,
|
||||
hasActivePackage: true,
|
||||
selectedPackageId: null,
|
||||
remainingEvents: 0,
|
||||
pathname: '/event-admin/mobile/dashboard',
|
||||
isWelcomePath: false,
|
||||
isBillingPath: false,
|
||||
isOnboardingDismissed: false,
|
||||
isOnboardingCompleted: false,
|
||||
});
|
||||
expect(result).toBe(ADMIN_WELCOME_EVENT_PATH);
|
||||
expect(result).toBe(ADMIN_BILLING_PATH);
|
||||
});
|
||||
|
||||
it('redirects to summary when selection exists', () => {
|
||||
it('returns null when remaining events are available', () => {
|
||||
const result = resolveOnboardingRedirect({
|
||||
hasEvents: false,
|
||||
hasActivePackage: false,
|
||||
selectedPackageId: 5,
|
||||
hasActivePackage: true,
|
||||
remainingEvents: 2,
|
||||
pathname: '/event-admin/mobile/dashboard',
|
||||
isWelcomePath: false,
|
||||
isBillingPath: false,
|
||||
isOnboardingDismissed: false,
|
||||
isOnboardingCompleted: false,
|
||||
});
|
||||
expect(result).toBe(ADMIN_WELCOME_SUMMARY_PATH);
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('redirects to landing when no selection exists', () => {
|
||||
it('returns null when remaining events are unlimited', () => {
|
||||
const result = resolveOnboardingRedirect({
|
||||
hasEvents: false,
|
||||
hasActivePackage: false,
|
||||
selectedPackageId: null,
|
||||
hasActivePackage: true,
|
||||
remainingEvents: null,
|
||||
pathname: '/event-admin/mobile/dashboard',
|
||||
isWelcomePath: false,
|
||||
isBillingPath: false,
|
||||
isOnboardingDismissed: false,
|
||||
isOnboardingCompleted: false,
|
||||
});
|
||||
expect(result).toBe(ADMIN_WELCOME_BASE_PATH);
|
||||
});
|
||||
|
||||
it('does not redirect when already on target', () => {
|
||||
const result = resolveOnboardingRedirect({
|
||||
hasEvents: false,
|
||||
hasActivePackage: false,
|
||||
selectedPackageId: null,
|
||||
pathname: ADMIN_WELCOME_BASE_PATH,
|
||||
isWelcomePath: false,
|
||||
isBillingPath: false,
|
||||
isOnboardingDismissed: false,
|
||||
isOnboardingCompleted: false,
|
||||
@@ -123,9 +100,8 @@ describe('resolveOnboardingRedirect', () => {
|
||||
const result = resolveOnboardingRedirect({
|
||||
hasEvents: false,
|
||||
hasActivePackage: false,
|
||||
selectedPackageId: null,
|
||||
remainingEvents: null,
|
||||
pathname: '/event-admin/mobile/dashboard',
|
||||
isWelcomePath: false,
|
||||
isBillingPath: false,
|
||||
isOnboardingDismissed: true,
|
||||
isOnboardingCompleted: false,
|
||||
@@ -137,11 +113,9 @@ describe('resolveOnboardingRedirect', () => {
|
||||
const result = resolveOnboardingRedirect({
|
||||
hasEvents: false,
|
||||
hasActivePackage: false,
|
||||
selectedPackageId: null,
|
||||
remainingEvents: null,
|
||||
pathname: '/event-admin/mobile/dashboard',
|
||||
isWelcomePath: false,
|
||||
isBillingPath: false,
|
||||
isOnboardingDismissed: false,
|
||||
isOnboardingCompleted: true,
|
||||
});
|
||||
expect(result).toBeNull();
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import {
|
||||
ADMIN_EVENT_CREATE_PATH,
|
||||
ADMIN_WELCOME_BASE_PATH,
|
||||
ADMIN_WELCOME_EVENT_PATH,
|
||||
ADMIN_WELCOME_SUMMARY_PATH,
|
||||
ADMIN_BILLING_PATH,
|
||||
} from '../../constants';
|
||||
|
||||
type OnboardingRedirectInput = {
|
||||
hasEvents: boolean;
|
||||
hasActivePackage: boolean;
|
||||
selectedPackageId?: number | null;
|
||||
remainingEvents?: number | null;
|
||||
pathname: string;
|
||||
isWelcomePath: boolean;
|
||||
isBillingPath: boolean;
|
||||
isOnboardingDismissed?: boolean;
|
||||
isOnboardingCompleted?: boolean;
|
||||
@@ -19,22 +16,17 @@ type OnboardingRedirectInput = {
|
||||
export function resolveOnboardingRedirect({
|
||||
hasEvents,
|
||||
hasActivePackage,
|
||||
selectedPackageId,
|
||||
remainingEvents,
|
||||
pathname,
|
||||
isWelcomePath,
|
||||
isBillingPath,
|
||||
isOnboardingDismissed,
|
||||
isOnboardingCompleted,
|
||||
}: OnboardingRedirectInput): string | null {
|
||||
if (hasEvents) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isOnboardingDismissed || isOnboardingCompleted) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isWelcomePath || isBillingPath) {
|
||||
if (isBillingPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -42,16 +34,9 @@ export function resolveOnboardingRedirect({
|
||||
return null;
|
||||
}
|
||||
|
||||
const shouldContinueSummary = Boolean(selectedPackageId && selectedPackageId > 0);
|
||||
const target = hasActivePackage
|
||||
? ADMIN_WELCOME_EVENT_PATH
|
||||
: shouldContinueSummary
|
||||
? ADMIN_WELCOME_SUMMARY_PATH
|
||||
: ADMIN_WELCOME_BASE_PATH;
|
||||
|
||||
if (pathname === target) {
|
||||
return null;
|
||||
if (!hasEvents && (!hasActivePackage || (remainingEvents !== null && remainingEvents <= 0))) {
|
||||
return ADMIN_BILLING_PATH;
|
||||
}
|
||||
|
||||
return target;
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user