# All files / composer/entities ServiceLocation.js

100% Statements 15/15
100% Branches 8/8
100% Functions 2/2
100% Lines 15/15

    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
    30
    31
    32
    33
    34

    10x
    10x

    10x
    1x

    9x

    10x
    10x

    3x
    2x
    2x
    2x

    2x
    1x

    1x

    1x

     class ServiceLocation {
      constructor(id, name, pictureUrl, checkins, address) {
        this.id = id;
        this.name = name;

        if (pictureUrl.data && pictureUrl.data.url) {
          this.pictureUrl = pictureUrl.data.url;
        } else {
          this.pictureUrl = pictureUrl;
        }

        this.checkins = checkins;
        this.address = address;
      }

      get formattedAddressWithCheckins() {
        if (this.checkins) {
          const numbersInGroupsOf3 = /\B(?=(\d{3})+(?!\d))/g;
          const formattedNumber = this.checkins.toString().replace(numbersInGroupsOf3, ',');
          const formattedCheckins = `${formattedNumber} people checked in here`;

          if (this.address) {
            return `${this.address} · ${formattedCheckins}`;
          }

          return formattedCheckins;
        }

        return '';
      }
    }

    export default ServiceLocation;