# All files / utils types.js

100% Statements 3/3
100% Branches 0/0
100% Functions 0/0
100% Lines 3/3

    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
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93

    3x

    3x

    3x

     // types/index.js
    /* TODO -> Use this Types accross the App once Storybook generates correctly the
    *  documentation when importing propTypes
    */
    import {
      shape, bool, oneOf, instanceOf, number, string, object,
    } from 'prop-types';
    import { messagesTypes, messagesStatus, personTypes } from './constants';

    const FileDataType = shape({
      uri: string,
      status: {
        click: bool,
        loading: number,
      },
      width: number,
      height: number,
      latitude: string,
      longitude: string,
    });

    const PersonType = shape({
      id: number,
      name: string,
      internal_name: string,
      active: bool,
      email: string,
      avatar: string,
      role: string,
      status_name: string,
      availability_status_name: string,
      type: oneOf(Object.values(personTypes)),
    });

    const MessageType = shape({
      /**
       * Id: Message unique identifier
       */
      id: number,
      /**
       * Position: What side the message is displayed inside the chatbox
       */
      position: oneOf(['left', 'right']),
      /**
       * Type of Message: Type of the message. Values are defined as constants.
       * The current supported types are: SYSTEM, TEXT, TYPING, TIME, ACTIONABLE, FILE, PHOTO.
       */
      type: oneOf(Object.values(messagesTypes)),
      /**
      * forwarded: bool that indicates if message was forwareded. If this is false (default) onForwardClick
      * handler has no effect at all
      */
      forwarded: bool,
      theme: string,
      view: string,
      /**
       * Title: Message title. Is used to display as a first line. It is also possible to make it clickable
       */
      title: string,
      /**
       * Text: Actual message content text.
       */
      text: string,
      /**
       * data: Object with extra data used to display information about the message
       */
      data: object,
      /**
       * status: Message status. Values are defined as constants.
       * Current supported values are: WAITING, SENT, RECEIVED, READ
       */
      status: oneOf(Object.values(messagesStatus)),
      /**
       * date: Message creation date.
       */
      date: instanceOf(Date),
      /**
       * dateFormat: Formated date string to show. This is the default to use.
       * If this is not provided by default to show the 'HH:mm' is used.
       */
      dateFormat: string,
      /**
       * person: Object representing the person that created or submited this message.
       */
      person: PersonType,
    });

    export {
      MessageType,
      PersonType,
      FileDataType,
    };