import { hasPermission } from '@/business/auth/permissions';
import type { CurrentUser } from '@/shared/types/auth';

/**
 * Daily zone check-in is a campus-staff workflow. Global/full-access roles may
 * technically pass permission checks, but they should not get self-state nudges.
 */
export function canZoneCheckIn(user: CurrentUser | null | undefined): boolean {
  return hasPermission(user, 'ZONE_CHECKIN');
}

/** Whether to nudge the user to check in: permission + loaded + not yet done today. */
export function shouldNudgeZoneCheckIn(
  user: CurrentUser | null | undefined,
  isLoading: boolean,
  isCheckedInToday: boolean,
): boolean {
  return canZoneCheckIn(user) && !isLoading && !isCheckedInToday;
}
