Initial commit - Horux Despachos NL
This commit is contained in:
22
apps/web/lib/onboarding.ts
Normal file
22
apps/web/lib/onboarding.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { UserInfo } from '@horux/shared';
|
||||
|
||||
/**
|
||||
* Threshold de logins tras el cual el onboarding deja de mostrarse aunque el
|
||||
* user no haya completado todos los pasos. Cubre el caso "el user prefiere
|
||||
* ignorar el onboarding y ya pasaron varias sesiones".
|
||||
*/
|
||||
export const ONBOARDING_LOGIN_THRESHOLD = 4;
|
||||
|
||||
/**
|
||||
* Decide si la pantalla de onboarding debe mostrarse en el siguiente redirect
|
||||
* post-login. Reglas (lo que pase primero):
|
||||
* 1. El user ya hizo dismiss explícito → no se muestra
|
||||
* 2. El user ya acumuló > THRESHOLD logins → no se muestra
|
||||
* 3. Caso contrario → se muestra
|
||||
*/
|
||||
export function shouldShowOnboarding(user: Pick<UserInfo, 'loginCount' | 'onboardingDismissedAt'> | null): boolean {
|
||||
if (!user) return false;
|
||||
if (user.onboardingDismissedAt) return false;
|
||||
if ((user.loginCount ?? 0) > ONBOARDING_LOGIN_THRESHOLD) return false;
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user