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

/** Daily zone check-in requires the explicit effective ZONE_CHECKIN permission. */
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;
}
