All files / src/utils locationApproximation.ts

100% Statements 17/17
88.88% Branches 8/9
100% Functions 2/2
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29                  1x   1x 6x 6x 6x 6x 6x 6x 6x 6x 1x 1x   1x 2x 1x 1x 2x  
import type { PrivacyLevel } from '@/models/event';
 
interface ApproximateLocationContext {
  privacyLevel: PrivacyLevel;
  isLocationApproximate: boolean;
  isHost: boolean;
  participationStatus: string;
}
 
export const APPROXIMATE_LOCATION_RADIUS_METERS = 250;
 
export function shouldShowApproximateLocationIndicator({
  privacyLevel,
  isLocationApproximate,
  isHost,
  participationStatus,
}: ApproximateLocationContext): boolean {
  if (!isLocationApproximate) return false;
  if (privacyLevel !== 'PROTECTED') return false;
  if (isHost) return false;
  return participationStatus !== 'JOINED';
}
 
export function getApproximateLocationText(hasAddress: boolean): string {
  return hasAddress
    ? 'Approximate location'
    : 'Approximate area shown. Exact address is visible after approval.';
}